"""WebSocket router for game connections."""
from fastapi import APIRouter, WebSocket, WebSocketDisconnect, Query
from typing import Optional

from app.services.game_server import game_websocket_endpoint

router = APIRouter()


@router.websocket("/ws/game/{game_id}")
async def game_websocket(
    websocket: WebSocket,
    game_id: int,
    player_id: Optional[int] = None,
):
    """WebSocket endpoint for game connections."""
    await websocket.accept()
    await game_websocket_endpoint(websocket, game_id)
