(你真的不說哪個演員,所以我假設的答案阿卡是好的爲好)
的sender
方法給你ActorRef
這是在發送站點或明或暗地回升:如果您在演員中使用!
,則會找到並使用其implicit val self: ActorRef
。如果發送者生活在不同的ActorSystem
除接收者,即它是一個遠程消息發送,那麼sender
裁判將包含必要的答覆的所有信息,只要看看它的路徑:
val s = sender // Actor[akka://<system>@<host>:<port>/user/path/to/actor]
val p = s.path // akka://<system>@<host>:<port>/user/path/to/actor
val a = p.address // akka://<system>@<host>:<port>
val host = a.host // Some(<host>), where <host> is the listen address as configured for the remote system
val port = a.port // Some(<port>), where <port> is the actual listen port of the remote system
因此,簡而言之, sender.path.address.host
(和模擬端口)應該給你你需要的。
如果IP地址是郵件的一部分,那麼將它放入郵件中可能會很好嗎? –