27 lines
725 B
Python
27 lines
725 B
Python
"""Client connection model used by the signaling server."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
|
|
from websockets.asyncio.server import ServerConnection
|
|
|
|
|
|
@dataclass
|
|
class ClientConnection:
|
|
"""Represents one connected websocket client and its world state."""
|
|
|
|
websocket: ServerConnection
|
|
id: str
|
|
nickname: str = "user..."
|
|
x: int = 20
|
|
y: int = 20
|
|
last_position_update_ms: int = 0
|
|
movement_window_index: int = -1
|
|
movement_window_steps_used: int = 0
|
|
|
|
def summary(self) -> dict[str, str | int]:
|
|
"""Return a compact serializable snapshot for logs/diagnostics."""
|
|
|
|
return {"id": self.id, "nickname": self.nickname, "x": self.x, "y": self.y}
|