MCPcopy Create free account
hub / github.com/miguelgrinberg/python-socketio / trigger_event

Method trigger_event

src/socketio/namespace.py:16–33  ·  view source on GitHub ↗

Dispatch an event to the proper handler method. In the most common usage, this method is not overloaded by subclasses, as it performs the routing of events to methods. However, this method can be overridden if special dispatching rules are needed, or if having a sing

(self, event, *args)

Source from the content-addressed store, hash-verified

14 omitted, the default namespace is used.
15 """
16 def trigger_event(self, event, *args):
17 """Dispatch an event to the proper handler method.
18
19 In the most common usage, this method is not overloaded by subclasses,
20 as it performs the routing of events to methods. However, this
21 method can be overridden if special dispatching rules are needed, or if
22 having a single method that catches all events is desired.
23 """
24 handler_name = 'on_' + (event or '')
25 if hasattr(self, handler_name):
26 try:
27 return getattr(self, handler_name)(*args)
28 except TypeError:
29 # legacy disconnect events do not have a reason argument
30 if event == 'disconnect':
31 return getattr(self, handler_name)(*args[:-1])
32 else: # pragma: no cover
33 raise
34
35 def emit(self, event, data=None, to=None, room=None, skip_sid=None,
36 namespace=None, callback=None, ignore_queue=False):

Callers 15

_trigger_eventMethod · 0.45
_trigger_eventMethod · 0.45
_trigger_eventMethod · 0.45
_trigger_eventMethod · 0.45
test_connect_eventMethod · 0.45
test_disconnect_eventMethod · 0.45
test_sync_eventMethod · 0.45
test_async_eventMethod · 0.45
test_event_not_foundMethod · 0.45

Calls

no outgoing calls