我是远程演员的新手,我遇到了问题。我需要动态设置我的actor的端口(或者我的测试中已经使用的地址有一些问题)但是我找不到如何获得已设置的端口。
我和Play一起工作!斯卡拉。我以为我可以通过Play获得端口!像这样的控制器(虽然它似乎不是正确的方式):
def remoteActorsPort = Action.async { implicit request =>
implicit val timeout: akka.util.Timeout = 3.seconds
val saveEventActor = actorSystem.actorSelection("/user/save-event-actor")
saveEventActor ? WhatMyPort() map { maybePort =>
maybePort.asInstanceOf[Option[Int]] match {
case Some(port) => Ok(Json.toJson(port))
case _ => NotFound
}
}
}
在我的演员中:
case whatMyPort: WhatMyPort => sender ! self.path.address.port
但self.path.address.port
返回无。
如何动态设置远程actor的端口?