Ali
Ali

Reputation: 21

Concurrent connections to Tornado WebSocket server

We're trying to build a server that utilizes "tornado.websocket.WebSocketHandler".

Opposite to what is demonstrated on "demos\websocket\chatdemo.py", we want every client to establish its own private session, not to broadcast the message to all connected subscribers.

How to identify individual "waiters" and deliver every message to the other client that is intended to receive it?

Upvotes: 2

Views: 1420

Answers (1)

kimjxie
kimjxie

Reputation: 801

  • First, the first message send to server must have some data for identify the client.
  • The handler save itself into a shared data with the client's id. The simple way is save this into a dict, as the websocket application's property.
  • If some message need to send to some clients, pick up their handlers from shared data, then call the handler's send method.

Upvotes: 1

Related Questions