WebSocketBaseΒΆ

Defined in dccd.transport.ws

class WebSocketBase(url)[source]

Bases: object

Base async WebSocket client with exponential reconnect.

Subclasses override on_connect to send subscription messages and parse_message to yield domain records from raw frames.

For adapters that need a raw-frame async generator (e.g. to maintain local order-book state across messages), use stream_raw instead.

Parameters:
urlstr

WebSocket endpoint URL.

async on_connect(ws)[source]

Called once after each (re)connect. Override to send subscriptions.

async parse_message(raw)[source]

Parse a raw frame and yield domain records. Override in subclass.

stop()[source]

Request graceful shutdown.

async stream()[source]

Yield parsed domain records, reconnecting on errors.

Delegates to parse_message for frame parsing.

async stream_raw()[source]

Yield raw WebSocket frames, reconnecting with exponential backoff.

Use this in adapters where parse_message is not convenient (e.g. stateful order-book reconstruction that spans multiple frames).