WebsocketExtension

class WebsocketExtension(**properties: Any)

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 given params.

Parameters:
  • connection_type – either CLIENT or SERVER

  • params – the parameters

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, otherwise unref is called on the given payload and a new Bytes 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, otherwise unref is called on the given payload and a new Bytes 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 given params.

Parameters:
  • connection_type – either CLIENT or SERVER

  • params – the parameters

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, otherwise unref is called on the given payload and a new Bytes 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, otherwise unref is called on the given payload and a new Bytes 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