Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(server): Added await for async functions #14

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Server/websocket_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async def handler(self, websocket):

# check for winning state
if self._game.state.finished:
self._end_game()
await self._end_game()

# announce new game state
else:
Expand Down Expand Up @@ -132,7 +132,7 @@ async def handler(self, websocket):
else:
self._game.state.set_winner(0)

self._end_game()
await self._end_game()

else:
# still in lobby, can terminate without game end.
Expand All @@ -153,7 +153,7 @@ async def handler(self, websocket):
if self._inprogress:
# connection closed, but not nice. we cannot determine winner, so fuck off
self._game.state.set_winner(0)
self._end_game()
await self._end_game()

else:
# request a ping from everyone and delete player list to wait for join messages.
Expand All @@ -176,7 +176,7 @@ async def _end_game(self):
"final_playfield": self._game.state.playfield,
}))

asyncio.sleep(1)
await asyncio.sleep(1)
exit()

async def start_server(self):
Expand Down
Loading