WebsocketExtension
Superclasses: Object
Subclasses: WebsocketExtensionDeflate
A WebSocket extension
WebsocketExtension
is the base class for WebSocket extension objects.
Methods
- class WebsocketExtension
- configure(connection_type: WebsocketConnectionType, params: dict[None, None] | None = None) bool
Configures
extension
with the givenparams
.
- get_request_params() str | None
Get the parameters strings to be included in the request header.
If the extension doesn’t include any parameter in the request, this function returns
None
.
- get_response_params() str | None
Get the parameters strings to be included in the response header.
If the extension doesn’t include any parameter in the response, this function returns
None
.
- process_incoming_message(payload: Bytes) tuple[Bytes, int]
Process a message after it’s received.
If the payload isn’t changed the given
payload
is just returned, otherwiseunref
is called on the givenpayload
and a newBytes
is returned with the new data.Extensions using reserved bits of the header will reset them in
header
.- Parameters:
payload – the payload data
- process_outgoing_message(payload: Bytes) tuple[Bytes, int]
Process a message before it’s sent.
If the payload isn’t changed the given
payload
is just returned, otherwiseunref
is called on the givenpayload
and a newBytes
is returned with the new data.Extensions using reserved bits of the header will change them in
header
.- Parameters:
payload – the payload data
Virtual Methods
- class WebsocketExtension
- do_configure(connection_type: WebsocketConnectionType, params: dict[None, None] | None = None) bool
Configures
extension
with the givenparams
.
- do_get_request_params() str | None
Get the parameters strings to be included in the request header.
If the extension doesn’t include any parameter in the request, this function returns
None
.
- do_get_response_params() str | None
Get the parameters strings to be included in the response header.
If the extension doesn’t include any parameter in the response, this function returns
None
.
- do_process_incoming_message(payload: Bytes) tuple[Bytes, int]
Process a message after it’s received.
If the payload isn’t changed the given
payload
is just returned, otherwiseunref
is called on the givenpayload
and a newBytes
is returned with the new data.Extensions using reserved bits of the header will reset them in
header
.- Parameters:
payload – the payload data
- do_process_outgoing_message(payload: Bytes) tuple[Bytes, int]
Process a message before it’s sent.
If the payload isn’t changed the given
payload
is just returned, otherwiseunref
is called on the givenpayload
and a newBytes
is returned with the new data.Extensions using reserved bits of the header will change them in
header
.- Parameters:
payload – the payload data
Fields
- class WebsocketExtension
- parent_instance