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[Any, Any] | None = None) bool#

Configures extension with the given params.

Parameters:
  • connection_type – either CLIENT or SERVER

  • params – the parameters

do_configure(self, connection_type: WebsocketConnectionType, params: dict[Any, Any] | None = None) bool#
Parameters:
  • connection_type

  • params

do_get_request_params(self) str | None#
do_get_response_params(self) str | None#
do_process_incoming_message(self, header: int, payload: Bytes) Tuple[Bytes, int]#
Parameters:
  • header

  • payload

do_process_outgoing_message(self, header: int, payload: Bytes) Tuple[Bytes, int]#
Parameters:
  • header

  • payload

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(header: int, 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:
  • header – the message header

  • payload – the payload data

process_outgoing_message(header: int, 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:
  • header – the message header

  • payload – the payload data

Virtual Methods#

class WebsocketExtension
do_configure(connection_type: WebsocketConnectionType, params: dict[Any, Any] | 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(header: int, 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:
  • header – the message header

  • payload – the payload data

do_process_outgoing_message(header: int, 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:
  • header – the message header

  • payload – the payload data

Fields#

class WebsocketExtension
parent_instance#