heroku-python / flask-sockets

[DEPRECATED] Alternative: https://github.com/miguelgrinberg/flask-sock
MIT License
1.74k stars 164 forks source link

Sending to all clients connected to socket #5

Closed gleitz closed 8 years ago

gleitz commented 10 years ago

Currently the echo server receives a message from one particular client and sends a response back to that client.

        message = ws.receive()
        ws.send(message)

What would need to be done to have the server send the message to all connected sockets on that route? Does gevent-websocket store that data somewhere?

kennethreitz commented 10 years ago

This would be a really interesting thing to include in this extension. I think (if done correctly) it would mesh well with Flask's design philosophies.

Here's how to do this today:

https://github.com/heroku-examples/python-websockets-chat/blob/master/chat.py#L28