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

Function join

example/tutorial/step2/app.py:117–137  ·  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

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