简体   繁体   中英

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?

  • 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM