Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -214,26 +214,26 @@ async def handler(websocket):
|
|
| 214 |
message = await websocket.recv()
|
| 215 |
event = json.loads(message)
|
| 216 |
project_name = event["project_name"]
|
| 217 |
-
assert event["type"] == "init"
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
|
| 232 |
-
assert event["type"] == "cmd"
|
| 233 |
|
| 234 |
-
if "command" in event:
|
| 235 |
-
|
| 236 |
-
|
| 237 |
# elif "watch" in event:
|
| 238 |
# # Spectator watches an existing game.
|
| 239 |
# await watch(websocket, event["watch"])
|
|
|
|
| 214 |
message = await websocket.recv()
|
| 215 |
event = json.loads(message)
|
| 216 |
project_name = event["project_name"]
|
| 217 |
+
# assert event["type"] == "init"
|
| 218 |
+
if event["type"] == "init":
|
| 219 |
+
if "join" in event:
|
| 220 |
+
# Second player joins an existing game.
|
| 221 |
+
await join(websocket, event["join"])
|
| 222 |
+
elif "watch" in event:
|
| 223 |
+
# Spectator watches an existing game.
|
| 224 |
+
await watch(websocket, event["watch"])
|
| 225 |
+
elif "command" in event:
|
| 226 |
+
|
| 227 |
+
await execute_command(websocket, event["project_name"], event["command"])
|
| 228 |
+
else:
|
| 229 |
+
# First player starts a new game.
|
| 230 |
+
await start(websocket, message)
|
| 231 |
|
| 232 |
+
# assert event["type"] == "cmd"
|
| 233 |
|
| 234 |
+
# if "command" in event:
|
| 235 |
+
# # Second player joins an existing game.
|
| 236 |
+
# await execute_command(websocket, project_name, event["command"])
|
| 237 |
# elif "watch" in event:
|
| 238 |
# # Spectator watches an existing game.
|
| 239 |
# await watch(websocket, event["watch"])
|