there is a similar question for nodejs but I need for python also
node.js socket.io How to emit to a particular client?
I want to broadcast a message to an specific client based on some condition using socketio and flask from the connected clients. Basically,
- How I can find the connected clients in socket io?
- How I can emit a message to an specific client?
Sample code for broadcast
@socket_.on('my_broadcast_event', namespace='/test')
def test_broadcast_message(message):
session['receive_count'] = session.get('receive_count', 0) + 1
emit('my_response',
{'data': message['data'], 'count': session['receive_count']},
broadcast=True)