Skip to content

Commit

Permalink
Send new_game message to all tournament_sockets of the players
Browse files Browse the repository at this point in the history
  • Loading branch information
gbtami committed Jan 18, 2025
1 parent 8f1b411 commit 8af2000
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
26 changes: 10 additions & 16 deletions server/tournament.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,26 +755,20 @@ async def create_games(self, pairing):
"bplayer": bp.username,
}

ws_ok = True
try:
ws = next(iter(wp.tournament_sockets[self.id]))
except (KeyError, StopIteration):
ws_ok = False

if ws_ok and wp.title != "TEST":
ws_ok = await ws_send_json(ws, response)
ws_ok = False
if wp.title != "TEST":
for ws in list(wp.tournament_sockets[self.id]):
ok = await ws_send_json(ws, response)
ws_ok = ws_ok or ok
if not ws_ok:
await self.pause(wp)
log.debug("White player %s left the tournament (ws send failed)", wp.username)

ws_ok = True
try:
ws = next(iter(bp.tournament_sockets[self.id]))
except (KeyError, StopIteration):
ws_ok = False

if ws_ok and bp.title != "TEST":
ws_ok = await ws_send_json(ws, response)
ws_ok = False
if bp.title != "TEST":
for ws in list(bp.tournament_sockets[self.id]):
ok = await ws_send_json(ws, response)
ws_ok = ws_ok or ok
if not ws_ok:
await self.pause(bp)
log.debug("Black player %s left the tournament (ws send failed)", bp.username)
Expand Down
2 changes: 1 addition & 1 deletion server/wsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ async def handle_accept_seek(app_state: PychessGlobalAppState, ws, user, data):
seek.creator.game_queues[gameId] = asyncio.Queue()
await seek.creator.event_queue.put(challenge(seek, response))
else:
ws_set = seek.creator.lobby_sockets
ws_set = list(seek.creator.lobby_sockets)
if len(ws_set) == 0:
remove_seek(app_state.seeks, seek)
await app_state.lobby.lobby_broadcast_seeks()
Expand Down

0 comments on commit 8af2000

Please sign in to comment.