For reference, this question has roots from Scala method performance (collect or foreach or other) looping through sockets?
I'm storing a reference to a websocket inside an actor, and then subscribing that actor to an Akka EventStream:
val socketActor = system.actorOf(Props(new Actor {
val socket = WebSocketConnection
def receive = {
case d: AppMessage ⇒ socket.send(d)
}
}))
system.eventStream.subscribe(socketActor, classOf[AppMessage])
What bugs me is that the only classifier I can make with an EventStream is a class type. So if you want to route messages to different actors, say based on userId, do you need to create multiple EventStreams and manually build an EventBus or is there something here that I am missing?
It would be nice if I could do something simply like:
system.eventStream.subscribe(socketActor, Map("userId" -> userId, "teamId" -> teamId) )
This may be simply a conceptual issue, as I'm not quite sure what EventStream represents.