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

Multiple connections to same sessionId ?

Open labe-me opened this issue 10 years ago • 2 comments

Hello,

Is it possible to have multiple connections using the same sessionId (browser tabs for instance), each connection receiving the same messages ?

If it's not possible how can I pass the HttpRequest cookie SID along the ConnectionContext so I can handle the duplicity from by ActorSubscriber ?

If it is not possible to extends the ConnectionContext may be it is possible to send a custom message from the SocketIOServerWorker.postReceive() to the ActorSubscriber ? How would you do that from client code ?

Best regards Laurent

labe-me avatar Jan 29 '15 10:01 labe-me

Here's an example:

   override def sessionIdGenerator: HttpRequest => Future[String] = {
      req =>
        val sid = req.uri.query.get("sessionid") match {
          case Some(sessionId) => sessionId
          case None            => UUID.randomUUID.toString
        }
        Future.successful(sid)
    }

dcaoyuan avatar Feb 03 '15 07:02 dcaoyuan

Thank you for the reply, I'll try again this solution.

In my former test it looked like the first connected socket (two browser tabs on same sessionId) wasn't receiving messages anymore.

labe-me avatar Feb 03 '15 08:02 labe-me