0

我是远程演员的新手,我面临一个问题。我需要动态设置我的演员的端口(或者我的测试中已经使用的地址有一些问题),但我不知道如何获取已设置的端口。

我与 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 返回 None

动态设置远程参与者的端口后,如何继续获取它?

4

0 回答 0