Atmosphere Issue: Previous Client Stops Receiving Messages When Another Client Connects

4 views
Skip to first unread message

John Paul

unread,
Apr 19, 2018, 11:30:31 PM4/19/18
to scalatra-user
When client1 connects, a uuid is assigned and messages are received and sent to client1.  When client2 connects,  a uuid is assigned and messages are received and sent to client2. When client1 makes a request, messages are sent only to client2.  If client1 refreshes browser, a new uuid is generated for client1 and messages are received and sent to client1, and client2 no longer receives messages.

My Servlet is defined like this snippet:

class MyServlet extends ScalatraServlet with ScalateSupport with AtmosphereSupport {
  implicit val system = ActorSystem()
  var receiver: Receiver = null
  val atmosphereClient = new AtmosphereClient {
    def receive: AtmoReceive = {
      case Connected =>
        logger.info(s"Atmosphere client $uuid connected")
      case Disconnected(ClientDisconnected, _) =>
        logger.info(s"Atmosphere client $uuid disconnected")
      case Disconnected(ServerDisconnected, _) =>
        logger.info(s"Atmosphere server disconnected")
      case _: TextMessage =>
        logger.warn(s"Atmosphere received text message. Disregarding message because only JSON is allowed")
      case JsonMessage(json) =>
        logger.info(s"Send json message: $json")
    }
  }
  val messageSender = new MessageSender(atmosphereClient)

  atmosphere("/updates") {
    atmosphereClient
  }
}

Tomcat:7.0.37
Scalatra: 2.6.2
Atmosphere-Runtime-Native: 2.4.2

Any help is greatly appreciated....
Reply all
Reply to author
Forward
0 new messages