@@ -253,25 +253,49 @@ or can also be coroutines::
253253If the server includes arguments with an event, those are passed to the
254254handler function as arguments.
255255
256- Catch-All Event Handlers
257- ~~~~~~~~~~~~~~~~~~~~~~~~
256+ Catch-All Event and Namespace Handlers
257+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
258258
259259A "catch-all" event handler is invoked for any events that do not have an
260260event handler. You can define a catch-all handler using ``'*' `` as event name::
261261
262262 @sio.on('*')
263- def catch_all (event, data):
264- pass
263+ def any_event (event, sid , data):
264+ pass
265265
266- Asyncio clients can also use a coroutine::
266+ Asyncio servers can also use a coroutine::
267267
268268 @sio.on('*')
269- async def catch_all (event, data):
270- pass
269+ async def any_event (event, sid , data):
270+ pass
271271
272272A catch-all event handler receives the event name as a first argument. The
273273remaining arguments are the same as for a regular event handler.
274274
275+ The ``connect `` and ``disconnect `` events have to be defined explicitly and are
276+ not invoked on a catch-all event handler.
277+
278+ Similarily, a "catch-all" namespace handler is invoked for any connected
279+ namespaces that do not have an explicitly defined event handler. As with
280+ catch-all events, ``'*' `` is used in place of a namespace::
281+
282+ @sio.on('my_event', namespace='*')
283+ def my_event_any_namespace(namespace, sid, data):
284+ pass
285+
286+ For these events, the namespace is passed as first argument, followed by the
287+ regular arguments of the event.
288+
289+ Lastly, it is also possible to define a "catch-all" handler for all events on
290+ all namespaces::
291+
292+ @sio.on('*', namespace='*')
293+ def any_event_any_namespace(event, namespace, sid, data):
294+ pass
295+
296+ Event handlers with catch-all events and namespaces receive the event name and
297+ the namespace as first and second arguments.
298+
275299Connect, Connect Error and Disconnect Event Handlers
276300~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
277301
0 commit comments