Endgame WS messages & docs

This commit is contained in:
Eden Kirin
2023-05-11 19:36:16 +02:00
parent 76ee207bce
commit d660845d30
6 changed files with 47 additions and 115 deletions

View File

@ -15,6 +15,7 @@ from hopper.models.ws_dto import (
WSMessage,
WSPlayerReachedDestinationMessage,
WSProductSelectionDoneMessage,
WSProductSelectionTimeoutMessage,
)
@ -63,7 +64,9 @@ class WSServer(Thread):
try:
# we're expecting nothing from client, but read if client sends a message
rcv_data = await websocket.recv()
await self.handle_rcv_message(client=websocket, raw_message=rcv_data)
await self.handle_rcv_message(
client=websocket, raw_message=rcv_data
)
except ConnectionClosedOK:
logging.info(f"Connection closed OK for client: {websocket.id}")
connected = False
@ -126,6 +129,10 @@ class WSServer(Thread):
message = WSProductSelectionDoneMessage()
await self.send_message_to_clients(message)
async def send_product_selection_timeout_message(self) -> None:
message = WSProductSelectionTimeoutMessage()
await self.send_message_to_clients(message)
async def run_async(self) -> None:
logging.info(
f"Starting FairHopper Websockets Server on {self.host}:{self.port}"