diff options
Diffstat (limited to 'swiftstory/interface/ws.py')
-rw-r--r-- | swiftstory/interface/ws.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/swiftstory/interface/ws.py b/swiftstory/interface/ws.py index 2485b4f..a86c730 100644 --- a/swiftstory/interface/ws.py +++ b/swiftstory/interface/ws.py @@ -1,6 +1,7 @@ import contextlib import json import logging +from typing import Union import websockets.exceptions from websockets.server import WebSocketServerProtocol @@ -16,7 +17,7 @@ class WebsocketsInterface: def __init__(self, game_manager: GameManager): self.game_manager = game_manager - async def connection_handler(self, websocket: WebSocketServerProtocol, path: str): + async def connection_handler(self, websocket: WebSocketServerProtocol, path: str) -> None: client = Client(websocket, self.game_manager) with contextlib.suppress(websockets.exceptions.ConnectionClosed): @@ -25,8 +26,8 @@ class WebsocketsInterface: client.disconnect() - def message_received_handler(self, client, message): - def join_game(): + def message_received_handler(self, client: Client, message: Union[bytes, str]) -> str: + def join_game() -> str: try: game_name = json_msg['game_name'] except KeyError: @@ -35,7 +36,7 @@ class WebsocketsInterface: lang = json_msg.get('lang') return client.join_game(game_name, lang) - def designate_card(): + def designate_card() -> str: card_id = None try: card_id = int(json_msg['card_id']) @@ -44,7 +45,7 @@ class WebsocketsInterface: finally: return client.designate_card(card_id) - def play_white_card(): + def play_white_card() -> str: try: card_id = int(json_msg['card_id']) except KeyError: |