Ramesh-vani commited on
Commit
1a16e71
·
verified ·
1 Parent(s): 7d5e3bf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -18
app.py CHANGED
@@ -125,6 +125,7 @@ async def exe(websocket,connected):
125
  Receive and process moves from a player.
126
 
127
  """
 
128
  async for message in websocket:
129
  # Parse a "play" event from the UI.
130
  event = json.loads(message)
@@ -133,8 +134,7 @@ async def exe(websocket,connected):
133
 
134
  try:
135
  if "command" in event:
136
- # Second player joins an existing game.
137
- await execute_command(websocket, event["project_name"], event["command"])
138
  elif "write" in event:
139
  # Spectator watches an existing game.
140
  await watch(websocket, event["watch"]) #Todo
@@ -147,22 +147,22 @@ async def exe(websocket,connected):
147
  await error(websocket, str(exc))
148
  continue
149
 
150
- # Send a "play" event to update the UI.
151
- event = {
152
- "type": "play",
153
- "player": player,
154
- "column": column,
155
- "row": row,
156
- }
157
- websockets.broadcast(connected, json.dumps(event))
158
-
159
- # If move is winning, send a "win" event.
160
- if game.winner is not None:
161
- event = {
162
- "type": "win",
163
- "player": game.winner,
164
- }
165
- websockets.broadcast(connected, json.dumps(event))
166
 
167
  async def start(websocket,events):
168
  """
@@ -197,6 +197,7 @@ async def start(websocket,events):
197
  # Receive and process moves from the first player.
198
  # await play(websocket, game, PLAYER1, connected)
199
  await create_file_structure(websocket,data, base_path=base_path)
 
200
  finally:
201
  del JOIN[join_key]
202
  del WATCH[watch_key]
 
125
  Receive and process moves from a player.
126
 
127
  """
128
+ print('in exe')
129
  async for message in websocket:
130
  # Parse a "play" event from the UI.
131
  event = json.loads(message)
 
134
 
135
  try:
136
  if "command" in event:
137
+ await execute_command(websocket, event["project_name"], event["command"])
 
138
  elif "write" in event:
139
  # Spectator watches an existing game.
140
  await watch(websocket, event["watch"]) #Todo
 
147
  await error(websocket, str(exc))
148
  continue
149
 
150
+ # # Send a "play" event to update the UI.
151
+ # event = {
152
+ # "type": "play",
153
+ # "player": player,
154
+ # "column": column,
155
+ # "row": row,
156
+ # }
157
+ # websockets.broadcast(connected, json.dumps(event))
158
+
159
+ # # If move is winning, send a "win" event.
160
+ # if game.winner is not None:
161
+ # event = {
162
+ # "type": "win",
163
+ # "player": game.winner,
164
+ # }
165
+ # websockets.broadcast(connected, json.dumps(event))
166
 
167
  async def start(websocket,events):
168
  """
 
197
  # Receive and process moves from the first player.
198
  # await play(websocket, game, PLAYER1, connected)
199
  await create_file_structure(websocket,data, base_path=base_path)
200
+ await exe(websocket,connected)
201
  finally:
202
  del JOIN[join_key]
203
  del WATCH[watch_key]