quart.wrappers.websocket module

class quart.wrappers.websocket.Websocket(path: str, query_string: bytes, scheme: str, headers: werkzeug.datastructures.Headers, root_path: str, http_version: str, subprotocols: List[str], receive: Callable, send: Callable, accept: Callable, close: Callable, scope: hypercorn.typing.WebsocketScope)

Bases: quart.wrappers.base.BaseRequestWebsocket

async accept(headers: Optional[Union[dict, werkzeug.datastructures.Headers]] = None, subprotocol: Optional[str] = None) None

Manually chose to accept the websocket connection.

Parameters
  • headers – Additional headers to send with the acceptance response.

  • subprotocol – The chosen subprotocol, optional.

async close(code: int, reason: str = '') None
async receive() AnyStr
async receive_json() Any
property requested_subprotocols: List[str]
async send(data: AnyStr) None
async send_json(data: Any) None