Websocket
WebSocketHandler
- class usernado.websocket.WebSocketHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)
Every websocket handler MUST inherit from
WebSocketHandler
.- broadcast(participants: Set[WebSocketHandler], message: Union[bytes, str, Dict[str, Any]], binary: bool = False) None
Broadcast a message to all participants.
- Parameters
participants (Set[usernado.WebSocketHandler]) – Participants to send message.
message (Union[bytes, str, Dict[str, Any]]) – Message to send.
binary (bool, optional) – Type of message, defaults to False.
- send(message: Union[bytes, str, Dict[str, Any]], binary: bool = False) None
Send a message to the particular participant.
- Parameters
message (Union[bytes, str, Dict[str, Any]]) – Message to send.
binary (bool, optional) – Type of the message, defaults to False.