getting socket id of a client in flask socket.io getting socket id of a client in flask socket.io flask flask

getting socket id of a client in flask socket.io


From Flask-SocketIO documentation:

The request object defines request.namespace as the name of the namespace being handled, and adds request.sid, defined as the unique session ID for the client connection


Consider using request.sid which gets its value populated from the FlaskSocketIO library.


I found it is possible in flask too.

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.namespace.socket.sessid# ....