Connection Manager
- class bedrock_server_manager.web.websocket_manager.ConnectionManager
Bases:
objectManages WebSocket connections and topic-based subscriptions.
- __init__() None
- async connect(websocket: WebSocket, user: UserResponse) str
Accepts a new WebSocket connection, tracks it, and returns the client ID.
- disconnect(client_id: str)
Removes a client’s connection and all their subscriptions.
- subscribe(client_id: str, topic: str)
Subscribes a client to a given topic.
- unsubscribe(client_id: str, topic: str)
Unsubscribes a client from a given topic.
- async send_to_client(data: Any, client_id: str)
Sends a JSON message to a single client.
- async broadcast_to_topic(topic: str, data: Any)
Broadcasts a JSON message to all clients subscribed to a topic.
- async send_to_user(username: str, data: Any)
Sends a JSON message to all active connections for a specific user.