mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 09:26:08 -05:00
Added @socketio.on(connect) and @socketio.on(disconnect) handlers to log and manage Socket.IO connections. The intention is to resolve connection issues by ensuring the server properly acknowledges incoming WebSocket clients.
This commit is contained in:
@@ -3,6 +3,15 @@ from flask_socketio import join_room, leave_room
|
|||||||
|
|
||||||
|
|
||||||
def register_socket_handlers(socketio):
|
def register_socket_handlers(socketio):
|
||||||
|
@socketio.on("connect")
|
||||||
|
def on_connect():
|
||||||
|
current_app.logger.info(f"Socket {request.sid} connected from {request.environ.get('HTTP_ORIGIN')}")
|
||||||
|
return True # Accept the connection
|
||||||
|
|
||||||
|
@socketio.on("disconnect")
|
||||||
|
def on_disconnect():
|
||||||
|
current_app.logger.info(f"Socket {request.sid} disconnected")
|
||||||
|
|
||||||
@socketio.on("join")
|
@socketio.on("join")
|
||||||
def on_join(data): # noqa: F401
|
def on_join(data): # noqa: F401
|
||||||
room = data.get("room")
|
room = data.get("room")
|
||||||
|
|||||||
Reference in New Issue
Block a user