fix(disconnect): Await, also remove metadata

parent cf9cbaf9
......@@ -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)
......
......@@ -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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment