dcaoyuan / spray-socketio

socket.io for spray
Apache License 2.0
253 stars 55 forks source link

Multiple connections to same sessionId ? #70

Open labe-me opened 9 years ago

labe-me commented 9 years ago

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

dcaoyuan commented 9 years ago

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)
    }
labe-me commented 9 years ago

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.