init app of test arena

This commit is contained in:
2025-11-24 02:14:25 +01:00
parent d778206940
commit 4df7501aba
41 changed files with 5542 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
from fastapi import WebSocket
from typing import List
class ConnectionManager:
def __init__(self):
self.active_connections: List[WebSocket] = []
async def connect(self, websocket: WebSocket):
await websocket.accept()
self.active_connections.append(websocket)
def disconnect(self, websocket: WebSocket):
self.active_connections.remove(websocket)
async def broadcast(self, message: str):
for connection in self.active_connections:
try:
await connection.send_text(message)
except:
self.disconnect(connection)
manager = ConnectionManager()