azad.slipstream.client Module¶
azad.slipstream.client ¶
WebSocket client implementation.
Attributes¶
Classes¶
WebSocketClient ¶
WebSocketClient(handler_factory: Callable[[Any], ProtocolHandler])
Initialize the WebSocket client.
Parameters:
-
handler_factory(Callable[[Any], ProtocolHandler]) –Function that creates a new ProtocolHandler instance
Source code in azad/slipstream/client.py
Attributes¶
Functions¶
connect
async
¶
Connect to a WebSocket server.
Parameters:
-
uri(str, default:'ws://localhost:8765') –The WebSocket URI to connect to
Source code in azad/slipstream/client.py
disconnect
async
¶
Disconnect from the WebSocket server.
Source code in azad/slipstream/client.py
request_response
async
¶
Send a request and wait for a response.
Parameters:
-
data–The request data to send
Returns:
-
–
The response data
Raises:
-
RuntimeError–If not connected
-
ConnectionClosedError–If connection closed normally
-
ConnectionLostError–If connection lost unexpectedly
Source code in azad/slipstream/client.py
request_stream
async
¶
Send a request and receive a stream of responses.
Parameters:
-
data–The request data to send
Returns:
-
–
An async iterator of response items
Raises:
-
RuntimeError–If not connected
-
ConnectionClosedError–If connection closed normally
-
ConnectionLostError–If connection lost unexpectedly
Source code in azad/slipstream/client.py
fire_and_forget
async
¶
Send a one-way message with no response.
Parameters:
-
data–The message data to send
Raises:
-
RuntimeError–If not connected
-
ConnectionClosedError–If connection closed normally
-
ConnectionLostError–If connection lost unexpectedly
Source code in azad/slipstream/client.py
create
async
classmethod
¶
create(handler_factory: Callable[[Any], ProtocolHandler], uri: str = 'ws://localhost:8765')
Create and connect a new WebSocket client.
Parameters:
-
handler_factory(Callable[[Any], ProtocolHandler]) –Function that creates a new ProtocolHandler instance
-
uri(str, default:'ws://localhost:8765') –The WebSocket URI to connect to
Returns:
-
–
A connected WebSocketClient instance
Source code in azad/slipstream/client.py
Functions¶
run_client
async
¶
run_client(handler_factory: Callable[[Any], ProtocolHandler], uri: str = 'ws://localhost:8765')
Run a WebSocket client until interrupted.
Parameters:
-
handler_factory(Callable[[Any], ProtocolHandler]) –Function that creates a new ProtocolHandler instance
-
uri(str, default:'ws://localhost:8765') –The WebSocket URI to connect to