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

Function join

example/tutorial/step3/app.py:120–140  ·  view source on GitHub ↗

Handle a connection from the second player: join an existing game.

(websocket, join_key)

Source from the content-addressed store, hash-verified

118
119
120async def join(websocket, join_key):
121 """
122 Handle a connection from the second player: join an existing game.
123
124 """
125 # Find the Connect Four game.
126 try:
127 game, connected = JOIN[join_key]
128 except KeyError:
129 await error(websocket, "Game not found.")
130 return
131
132 # Register to receive moves from this game.
133 connected.add(websocket)
134 try:
135 # Send the first move, in case the first player already played it.
136 await replay(websocket, game)
137 # Receive and process moves from the second player.
138 await play(websocket, game, PLAYER2, connected)
139 finally:
140 connected.remove(websocket)
141
142
143async def watch(websocket, watch_key):

Callers 1

handlerFunction · 0.70

Calls 3

errorFunction · 0.70
replayFunction · 0.70
playFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…