Archived
Attempt to fix #12
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
"""Handles communication between one WebSocket tunnel and the game"""
|
"""Handles communication between one WebSocket tunnel and the game"""
|
||||||
|
|
||||||
from typing import Callable, Any, TYPE_CHECKING
|
from typing import Callable, Any, TYPE_CHECKING, Awaitable
|
||||||
from pydantic import ValidationError
|
from pydantic import ValidationError
|
||||||
|
|
||||||
from websockets.server import WebSocketServerProtocol
|
from websockets.server import WebSocketServerProtocol
|
||||||
@@ -45,6 +45,8 @@ class ClientController:
|
|||||||
|
|
||||||
track_connection: Callable
|
track_connection: Callable
|
||||||
|
|
||||||
|
on_message = Callable[[Message], Awaitable[None]]
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
game_controller: "GameController",
|
game_controller: "GameController",
|
||||||
@@ -53,7 +55,10 @@ class ClientController:
|
|||||||
self.websocket = websocket
|
self.websocket = websocket
|
||||||
self.game_controller = game_controller
|
self.game_controller = game_controller
|
||||||
self.game_controller.clients.append(self)
|
self.game_controller.clients.append(self)
|
||||||
self.on_message = lambda _: None
|
self.on_message = self.on_message_stub
|
||||||
|
|
||||||
|
async def on_message_stub(self, message: Message):
|
||||||
|
pass
|
||||||
|
|
||||||
async def close(self):
|
async def close(self):
|
||||||
"""Remove self from Game broadcasting list"""
|
"""Remove self from Game broadcasting list"""
|
||||||
|
|||||||
@@ -158,4 +158,6 @@ class LobbyClientController:
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def game_context(self, message: Message) -> None:
|
async def game_context(self, message: Message) -> None:
|
||||||
|
if self.game_client is None:
|
||||||
|
return
|
||||||
await self.game_client.on_message(message)
|
await self.game_client.on_message(message)
|
||||||
|
|||||||
Reference in New Issue
Block a user