Small feature request to trigger a callback on any events, like a generic handler. It can currently be achieved by inheriting the AsyncServer class like so:
import asyncio
from socketio import AsyncServer
class WebSocketServer(AsyncServer):
async def _trigger_event(self, event, namespace, *args):
root = self.handlers['/']
if '*' in root and event not in ['connect', 'disconnect']:
if asyncio.iscoroutinefunction(root['*']):
try:
ret = await root['*'](event, namespace, *args)
except asyncio.CancelledError: # pragma: no cover
ret = None
else:
ret = root['*'](event, namespace, *args)
return ret
return await super()._trigger_event(event, namespace, *args)
Then the callback can be added using the following:
@server.on('*')
async def any_event(event, namespace, sid, data):
pass
Small feature request to trigger a callback on any events, like a generic handler. It can currently be achieved by inheriting the AsyncServer class like so:
Then the callback can be added using the following: