From b43278a5a2cd960c2448dd14ef2f75374ff54c0f Mon Sep 17 00:00:00 2001 From: Paul-Louis NECH Date: Sun, 3 May 2020 14:36:51 +0200 Subject: [PATCH] fix(disconnect): Await, also remove metadata --- server/app.py | 2 +- server/game/lobby.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/server/app.py b/server/app.py index 80ef5c3..0ed681c 100644 --- a/server/app.py +++ b/server/app.py @@ -36,7 +36,7 @@ async def hello_world(): @router.get("/reset") async def reset( ): - return lobby.reset() + return await lobby.reset() app.include_router(router) diff --git a/server/game/lobby.py b/server/game/lobby.py index 2f49b3f..5f9d669 100644 --- a/server/game/lobby.py +++ b/server/game/lobby.py @@ -58,6 +58,7 @@ class LobbyManager(ClientManager): for p in self.players: await self.send(p, MessageToPlayer.Disconnected, extras={"justLeft": name}) + self.metadata.pop(name) return print(f"No player for sid {sid}...", file=stderr) @@ -96,15 +97,15 @@ class LobbyManager(ClientManager): print(f"Game started : {' vs '.join([p.name for p in players])}") await game.new_game() - def reset(self): + async def reset(self): players = len(self.players) games = len(self.games) msg = f"Resetting! sorry for the {players} players / {games} games..." print(msg) for p in self.players: m = self.metadata[p.name] - self.send(p, MessageToPlayer.Reset) - self.sio.disconnect(m.sid) + await self.send(p, MessageToPlayer.Reset) + await self.sio.disconnect(m.sid) self.lobby.clear() self.players.clear() self.metadata.clear() -- libgit2 0.27.0