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

Function handler

example/tutorial/step3/app.py:166–184  ·  view source on GitHub ↗

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

(websocket)

Source from the content-addressed store, hash-verified

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

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…