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

Class ConnectionManager

ml-yolo/backend/main.py:28–46  ·  view source on GitHub ↗

Web socket connection manager.

Source from the content-addressed store, hash-verified

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

Callers 1

main.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected