MCPcopy Create free account
hub / github.com/dot-agent/nextpy / on_event

Method on_event

nextpy/app.py:1090–1117  ·  view source on GitHub ↗

Event for receiving front-end websocket events. Args: sid: The Socket.IO session id. data: The event data.

(self, sid, data)

Source from the content-addressed store, hash-verified

1088 )
1089
1090 async def on_event(self, sid, data):
1091 """Event for receiving front-end websocket events.
1092
1093 Args:
1094 sid: The Socket.IO session id.
1095 data: The event data.
1096 """
1097 # Get the event.
1098 event = Event.parse_raw(data)
1099
1100 # Get the event environment.
1101 assert self.app.sio is not None
1102 environ = self.app.sio.get_environ(sid, self.namespace)
1103 assert environ is not None
1104
1105 # Get the client headers.
1106 headers = {
1107 k.decode("utf-8"): v.decode("utf-8")
1108 for (k, v) in environ["asgi.scope"]["headers"]
1109 }
1110
1111 # Get the client IP
1112 client_ip = environ["REMOTE_ADDR"]
1113
1114 # Process the events.
1115 async for update in process(self.app, event, sid, headers, client_ip):
1116 # Emit the update from processing the event.
1117 await self.emit_update(update=update, sid=sid)
1118
1119 async def on_ping(self, sid):
1120 """Event for testing the API endpoint.

Callers

nothing calls this directly

Calls 3

emit_updateMethod · 0.95
processFunction · 0.85
decodeMethod · 0.45

Tested by

no test coverage detected