Using Actor.preStart() hook you can do some tricks to access the actorRef:class MyWebSocketActor( out: ActorRef, firstMessage: Any, actorRegistry: ActorRef) extends Actor { import play.api.libs.json.JsValue override def preStart(): Unit = { self ! firstMessage actorRegistry ! self } ...}def socket = WebSocket.accept[String, String] { request => ActorFlow.actorRef { out => Props(new MyWebSocketActor(out, "First Message", someRegistryActorRef)) }} 这篇关于如何从 ActorFlow 获取演员参考 (ActorRef)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-11 13:56