Search code examples
pythonwebsocket.ioevent-handlingcatch-all

Python Socket.io handle all events (catch all events from client)


The documentation for Python Socket.io is here: https://python-socketio.readthedocs.io/en/latest/api.html#asyncserver-class

That is the server class, with 'event' and 'on' methods for handling events. However, those are named events.

How to handle all events from client (catch all) on server side? I've tried .on("*",...) but it didn't work, the asterisk * seems just a string in Python socket.io.


Solution

  • It doesn't seem to be in the docs explicitly, but you can listen for the 'message' events. Like 'connect' and 'disconnect' it's reserved, and it catches all incoming messages.