Is there a way to get socket id of current client? I have seen it is possible to get socket id in node.js. But it seems flask's socket.io extension is a little bit different than node's socketio.
In the flask's request object there is a socket object which has an id. from flask import request # .... @socketio. on('connect') def onConnect(): currentSocketId = request.
Flask-SocketIO gives Flask applications access to low latency bi-directional communications between the clients and the server.
socket-io. client is the code for the client-side implementation of socket.io. That code may be used either by a browser client or by a server process that is initiating a socket.io connection to some other server (thus playing the client-side role in a socket.io connection).
From Flask-SocketIO documentation:
The request object defines
request.namespace
as the name of the namespace being handled, and addsrequest.sid
, defined as the unique session ID for the client connection
Consider using request.sid
which gets its value populated from the FlaskSocketIO library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With