Scala, Play, Akka, Websocket: how to pass actor messages through websocket

后端 未结 2 1941
臣服心动
臣服心动 2021-01-31 12:49

I have an actor which is launched with application, running in the background watching for certain changes and if there are any reporting them. At the moment it just a pri

2条回答
  •  遥遥无期
    2021-01-31 13:24

    Just the other day I wrote this, which will be included in Play 2.3. You can copy it to your own application for now:

    https://github.com/jroper/ReactiveMaps/blob/websocket-actor/app/actors/WebSocketActor.scala

    You pass it a Props object, and it will create the actor for you. You send to the WebSocket by sending to context.parent.

提交回复
热议问题