from __future__ import annotations import asyncio import json import websockets from loguru import logger from app.webrtc.peer_session import PeerSession from configs.default import WS_HOST, WS_MAX_SIZE, WS_PORT async def handle_client(websocket): client = websocket.remote_address logger.info(f"Client connected: {client}") session = PeerSession() await session.handle(websocket) logger.info(f"Connection closed: {client}") async def main(): logger.info(f"WebRTC signaling server: ws://{WS_HOST}:{WS_PORT}") async with websockets.serve(handle_client, WS_HOST, WS_PORT, max_size=WS_MAX_SIZE): await asyncio.Future()