如何识别远程参与者?
我有一个远程参与者(客户端),它正在向另一个远程参与者(服务器)注册,然后注销(使用关闭挂钩)。 然而,尽管服务器接收到取消注册,但实际的 sender
属性是一个不同的 Channel 对象; 所以在我的服务器日志中我有:
注册了新客户端 [scala.actors.Channel@158e282]; 支持 1 个客户端
已注销客户端 [scala.actors.Channel@1caf0b6]; 支持1个客户端
我如何确定(在服务器端)这是最初向我注册的同一客户端参与者? 显然我可以为每个客户端提供自己的 UUID
但我想知道是否有更简单的方法?
I have a remote actor (client) which is registering with another remote actor (server) and then later deregistering (with a shutdown hook). However, although the server picks up the de-registration, the actual sender
property is a different Channel object; so in my server logs I have:
Registered new client [scala.actors.Channel@158e282]; supporting 1 clients
De-registered client [scala.actors.Channel@1caf0b6]; supporting 1 clients
How can I determine (on the server side) that this was the same client actor which originally registered with me? Obviously I could imbue each client with its own UUID
but I wonder whether there is an easier way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从 scala 用户邮件列表的讨论来看,如果不使用某种替代类型的客户端标识符(如
UUID
),这似乎不可能立即实现。 如果您在注册对象中从客户端发送self
引用,您将收到ObjectNotSerialized
错误。From a discussion on the scala users' mailing list, it seems that this is not immediately possible without using some alternative kind of client identifier (like
UUID
). If you send theself
reference from the client in your registration object, you will get aObjectNotSerializable
error.将发件人明确添加到您的消息中。 使用 RemoteActor.select 获取 scala.actors.remote.Proxy。 使用其 toString 方法来识别发件人。
Explicitly add the sender to your message. Use RemoteActor.select to get a scala.actors.remote.Proxy. Use its toString method to identify the sender.