MCPcopy Create free account
hub / github.com/alpha2phi/python-apps / ConnectionManager

Class ConnectionManager

ocr-ml-viewer/backend/main.py:25–43  ·  view source on GitHub ↗

Web socket connection manager.

Source from the content-addressed store, hash-verified

23
24
25class ConnectionManager:
26 """Web socket connection manager."""
27
28 def __init__(self):
29 self.active_connections: List[WebSocket] = []
30
31 async def connect(self, websocket: WebSocket):
32 await websocket.accept()
33 self.active_connections.append(websocket)
34
35 def disconnect(self, websocket: WebSocket):
36 self.active_connections.remove(websocket)
37
38 async def send_message(self, message: str, websocket: WebSocket):
39 await websocket.send_text(message)
40
41 async def broadcast(self, message: str):
42 for connection in self.active_connections:
43 await connection.send_text(message)
44
45
46conn_mgr = ConnectionManager()

Callers 1

main.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected