feat: Rebuild as Court Manager Dashboard v2
- Complete rewrite for single Court Manager user - Feature 1: Player Management (CRUD, ELO, skill level) - Feature 2: Court Reservation (timeline, override) - Feature 3: Match Event Builder (3-step wizard) - Step 1: Event setup with player selection + stage calculator - Step 2: Stage configurator (Open/Skill/RR/Tournament) - Step 3: Auto bracket generation - Feature 4: Live Court View (main dashboard, 2x2 grid) - Event Control: score entry, bracket advancement, court assignment - Screen view: TV display per court (/screen/:id) - Seed: 8 players, 4 courts, 1 completed + 1 active event - Routes: / players courts events events/new events/:id screen/:id
This commit is contained in:
40
backend/app/websocket_manager.py
Normal file
40
backend/app/websocket_manager.py
Normal file
@@ -0,0 +1,40 @@
|
||||
from typing import Dict, List
|
||||
from fastapi import WebSocket
|
||||
import json
|
||||
|
||||
|
||||
class ConnectionManager:
|
||||
def __init__(self):
|
||||
self.active_connections: Dict[str, List[WebSocket]] = {}
|
||||
|
||||
async def connect(self, websocket: WebSocket, channel: str):
|
||||
await websocket.accept()
|
||||
if channel not in self.active_connections:
|
||||
self.active_connections[channel] = []
|
||||
self.active_connections[channel].append(websocket)
|
||||
|
||||
def disconnect(self, websocket: WebSocket, channel: str):
|
||||
if channel in self.active_connections:
|
||||
try:
|
||||
self.active_connections[channel].remove(websocket)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
async def broadcast(self, channel: str, data: dict):
|
||||
if channel not in self.active_connections:
|
||||
return
|
||||
dead = []
|
||||
for ws in self.active_connections[channel]:
|
||||
try:
|
||||
await ws.send_json(data)
|
||||
except Exception:
|
||||
dead.append(ws)
|
||||
for ws in dead:
|
||||
self.disconnect(ws, channel)
|
||||
|
||||
async def broadcast_all(self, data: dict):
|
||||
for channel in list(self.active_connections.keys()):
|
||||
await self.broadcast(channel, data)
|
||||
|
||||
|
||||
manager = ConnectionManager()
|
||||
Reference in New Issue
Block a user