How can I identify a remote actor?

送分小仙女□ 提交于 2019-12-05 02:01:37

问题


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?


回答1:


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 the self reference from the client in your registration object, you will get a ObjectNotSerializable error.




回答2:


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.



来源:https://stackoverflow.com/questions/1058450/how-can-i-identify-a-remote-actor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!