How to access an actor created in websocket?

I have a websocket created using the play 2.3 function for the play 2.3 web clip. How can I access an actor created to send messages in another function?

def websocket: WebSocket[JsValue, JsValue] = 
  WebSocket.acceptWithActor[JsValue, JsValue] {
    req => out => Props(new MyActor(out))
  }
+4
source share
1 answer

Give your actor a link to the manager:

def websocket: WebSocket[JsValue, JsValue] = 
  WebSocket.acceptWithActor[JsValue, JsValue] {
    req => out => Props(new MyActor(managerRef, out))
  }

And make your actor registration manager at preStart.

+5
source

Source: https://habr.com/ru/post/1544646/


All Articles