mardi 4 mai 2021

(Flask) how to detect client disconnect in flask sockets

I want to print something when a client disconnected, but this isn't working

Javascript client:

socket.on("connect", () => {
   
    socket.on("disconnect",  () => {
     
       socket.emit("disconnected", "")

   })

})

Python flask :

@socketio.on("disconnected")
def handle_disconnect(room_num):
   print(f"user in room {room_num} disconnected")



Aucun commentaire:

Enregistrer un commentaire