class documentation

WebSocket implementation that runs in a separate thread.

Method __del__ Destructor to clean up resources.
Method __init__ Initialize the async WebSocket client.
Method clear Clear the last received data.
Method close Close the WebSocket connection.
Method connect Start the WebSocket connection in a separate thread.
Method ping Send a ping to the WebSocket server.
Method pong Send a pong to the WebSocket server.
Method send Send data to the WebSocket server.
Property error Get the last error message, if any.
Property is_connected Check if the WebSocket is connected.
Property is_running Check if the WebSocket thread is running.
Property last_received Get the last received data.
Method __close_thread Internal method to close the thread.
Method _should_continue Check if the operation should continue running.
Instance Variable _callback Undocumented
Instance Variable _current_task Undocumented
Instance Variable _headers Undocumented
Instance Variable _last_received Undocumented
Instance Variable _lock Undocumented
Instance Variable _running Undocumented
Instance Variable _stack_size Undocumented
Instance Variable _thread Undocumented
Instance Variable _thread_manager Undocumented
Instance Variable _timeout Undocumented
Instance Variable _uri Undocumented
Instance Variable _ws Undocumented
def __del__(self):

Destructor to clean up resources.

def __init__(self, uri: str, headers: dict = None, timeout: float = 10.0, callback: callable = None, thread_manager=None, stack_size: int = 32 * 1024):

Initialize the async WebSocket client.

Parameters
uri:strWebSocket URL (ws:// or wss://).
headers:dictOptional additional headers for the handshake. Defaults to None.
timeout:floatConnection timeout in seconds. Defaults to 10.0.
callback:callableFunction called with received data. Defaults to None.
thread_manager:ThreadManagerManager for threaded connections. Defaults to None.
stack_size:intThread stack size in bytes. Defaults to 32768.
def clear(self):

Clear the last received data.

def close(self):

Close the WebSocket connection.

def connect(self) -> bool:

Start the WebSocket connection in a separate thread.

def ping(self, data: bytes = b'') -> bool:

Send a ping to the WebSocket server.

Parameters
data:bytesPing payload. Defaults to b"".
Returns
boolTrue if sent successfully.
def pong(self, data: bytes = b'') -> bool:

Send a pong to the WebSocket server.

Parameters
data:bytesPong payload. Defaults to b"".
Returns
boolTrue if sent successfully.
def send(self, data) -> bool:

Send data to the WebSocket server.

Parameters
data:str or bytesData to send.
Returns
boolTrue if sent successfully.
@property
error: str =

Get the last error message, if any.

@property
is_connected: bool =

Check if the WebSocket is connected.

@property
is_running: bool =

Check if the WebSocket thread is running.

@property
last_received =

Get the last received data.

def __close_thread(self):

Internal method to close the thread.

def _should_continue(self) -> bool:

Check if the operation should continue running.

_callback: callable =

Undocumented

_current_task =

Undocumented

_headers: dict =

Undocumented

_last_received =

Undocumented

_lock =

Undocumented

_running: bool =

Undocumented

_stack_size =

Undocumented

_thread =

Undocumented

_thread_manager =

Undocumented

_timeout: float =

Undocumented

_uri: str =

Undocumented

Undocumented