Hey there folks,
After spending a couple of days trying to understand Akka and the way websockets in Play work, I still don't really get it.
I want to implement them using Actors not Streams.
Every example I can find only shows how to handle messages coming from the client, but isn't the purpose of a websocket more likely related to server-side updates?
(At least that is what I want to use them for)
So I know Akka uses a unique path for each Actor. But Play uses a "random" id (e.g. $a, $b, $c, ...) within that path so it looks like "akka://application/user/*/flowActor" where * is the random part.
Therefore in my eyes it is not possible to use the actorSystem.actorSelection method to identify the Actor(s) for a specific user.
One rather obvious solution for the problem would be to introduce some kind of registry that stores the ActorRefs based on the users uuid, yet this doesn't seem like a really Akka-like way of doing things. Another way would be to make use of a ManagerActor storing all WebsocketActors as named (user uuid) children.
So my main problem is not to find a solution to the problem, but rather the "best practice".
I mean there must be one, right?
I thought of something like using the actorSystem.actorSelection with a path like "akka://application/user/<uuid>/*/flowActor".
That way a user can have multiple open connections (for each tab, browser, device).
This seems like a good way to go, yet I don't know how to implement exactly that.
I'm hoping there is somebody who can help me with this problem (at best giving me some inside on a good implementation).
Looking forward to a response.
Thanks,
Marc