# NIKAME GENERATED — DO NOT EDIT DIRECTLY
from fastapi import APIRouter, WebSocket, WebSocketDisconnect
from app.websockets.manager import manager

router = APIRouter()

@router.websocket("/ws/{room_name}")
async def websocket_endpoint(websocket: WebSocket, room_name: str):
    await manager.connect(websocket, room_name)
    try:
        while True:
            data = await websocket.receive_text()
            await manager.broadcast(f"Room {room_name}: {data}", room_name)
    except WebSocketDisconnect:
        manager.disconnect(websocket, room_name)
