弄乱 erlang 和 gen_event 行为
在我正在开发的概念证明中,我构建了以下方案:
_ A _ _
/ | \ \
SS S H CC
/ \
C C
其中: A-申请
SS - 主管
CC - “真实”客户端
S-gen_server
H - gen_event
C - “内部”客户端
该应用程序的工作方式类似于多路复用器。我连接服务器上的内部客户端并请求一些东西。然后我将此请求传递给我的真实客户端(女巫连接到真实应用程序)并将其分发给任何需要此类内容的内部客户端。
除了事件处理之外,一切都工作正常:我想让我的内部客户端直接向 gen_event 处理程序发送消息,并且他将中介请求真实服务器/从缓存读取并回复客户端的过程。
我认为我需要在事件处理程序和我的客户端处理过程之间建立链接,这是对的吗?也许是这样的情况,使事件处理程序成为一个全局进程,并且只是从客户端之间泵送消息?
抱歉问了这么长的问题。
In a concept proof I'm developing, I've built the folowing scheme:
_ A _ _
/ | \ \
SS S H CC
/ \
C C
In which:
A - Application
SS - Supervisor
CC - "Real" client
S - gen_server
H - gen_event
C - "internal" client
The application works like a multiplexer. I connect on my internal client on my server and request some stuff. Then I pass this request to my real client (witch connects to the real application) and distribute it over any internal client who is demand that kind of stuff.
Everything is working fine except for the event handling: I wanted to make my internal client send messages directly to the gen_event handlers, and he would intermediate the process of requesting to the real server/ reading from cache and replying to the client.
I figured that I need to make a link between the event handler and my client handling process, this is right? Maybe it's the case to make the event handler to be a global process and just pump messages from between clients?
Sorry for the long question.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定我是否理解这个问题,但假设您正在寻求一种消息切换以使客户端能够以分布式方式交换消息,您可以看看我的一个项目就是这样做的:Mswitch。
当然,如果您注册一个“全局进程”(可本地和/或远程访问),您始终可以将消息传递给它,并让该进程根据您认为合适的方式分发所述消息。请务必不要忘记使不同模拟器实例中的进程相互通信的常见陷阱(cookie 同步和注册的虚拟机名称)。
I am not sure I understand the question but assuming you are after a sort of message switch to enable Clients to exchange messages in a distributed fashion, you could look at one my projects that does just that: Mswitch.
Of course if you register a "global process" (accessible locally and/or remotely), you can always shuttle messages to it and have this process distribute the said messages as you see fit. Be sure not to forget about the common pitfalls of making processes in different Emulator instances talk to each other (cookie sync and registered VM name).
如果你注册了处理程序,它将有一个全局已知的名称,然后你可以直接向它发送消息。
If you register the handler, it will have a globally known name , and then you can send messages to it directly.