How can I identify a remote actor?

2019-03-31 03:46发布

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?

2条回答
别忘想泡老子
2楼-- · 2019-03-31 03:58

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.

查看更多
再贱就再见
3楼-- · 2019-03-31 04:02

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.

查看更多
登录 后发表回答