spray-websocket icon indicating copy to clipboard operation
spray-websocket copied to clipboard

Support association of connection with connection handler actor

Open ghost opened this issue 11 years ago • 1 comments

It would be great if there were a means to name the connection handler actor based on some information available in the upgrade request. I'm thinking, for example, of a custom header that provides an ID, and that ID (presumably URL encoded) can be used as the name of the connection handler actor. The problem, of course, is that the connection handler actor already exists, and I don't think there's a way to name the actor after the fact. So presumably the implementation would create a new connection handler with the right name, register it as the handler, and stop the existing connection handler.

The goal is for clients to be able to identify themselves, and for the application to be able to use Akka routers, ActorSelections, etc. to communicate with specific clients (I'm assuming that's what the send() methods are for).

Does this make any sense? Is there a straightforward way to do it?

ghost avatar Nov 21 '14 00:11 ghost

Paul,

Using the WebSocket in order to maintain bidirectional communication between the client and the server can be acheived with no "identification" of the client end.

What you might actually want is to have a specific handler actor responsible for a particular URL such as I tried to exemplify in my template at: https://github.com/cuali/SprayEasterEggs/blob/wandoulabs/src/main/scala/reactive/api/ReactiveApi.scala#L29-L34

In this way, the connection handler remains anonymous while you have a clear route to some explicitly named actor that will handle the effective communication messages.

Would this resolve your concern?

Regards, Alain

Alain-Bearez avatar Jan 23 '15 20:01 Alain-Bearez