python - get current connection in flask socket.io -
i want make multiple emitting individual socket connection using flask's socket.io extension.
from flask.ext.socketio import socketio, emit, join_room, leave_room # creating flask app , io... @io.on("/saysomething") def saying(): emit("said", "hello") saying2() def saying2(): # ... # doing long , important # ... emit("said", "and how you?")
i not know connection saying2 emitting to. should pass current connection saying2 method? how can achieve goal?
in example, saying2()
emitting client sent /saysomething
event. based on concept similar request contexts in standard flask.
the emit function has 2 optional arguments send other clients:
broadcast=true
send connected clients, including client sent/saysomething
event.room=<room-name>
send clients attached given room. if want address individual clients, put each client in different room , target desired room.
Comments
Post a Comment