MCPcopy Index your code
hub / github.com/python-websockets/websockets / handler

Function handler

example/tutorial/step2/app.py:163–181  ·  view source on GitHub ↗

Handle a connection and dispatch it according to who is connecting.

(websocket)

Source from the content-addressed store, hash-verified

161
162
163async def handler(websocket):
164 """
165 Handle a connection and dispatch it according to who is connecting.
166
167 """
168 # Receive and parse the "init" event from the UI.
169 message = await websocket.recv()
170 event = json.loads(message)
171 assert event["type"] == "init"
172
173 if "join" in event:
174 # Second player joins an existing game.
175 await join(websocket, event["join"])
176 elif "watch" in event:
177 # Spectator watches an existing game.
178 await watch(websocket, event["watch"])
179 else:
180 # First player starts a new game.
181 await start(websocket)
182
183
184async def main():

Callers

nothing calls this directly

Calls 4

joinFunction · 0.70
watchFunction · 0.70
startFunction · 0.70
recvMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…