La referencia de la API está disponible solo en inglés por ahora.

ReconnectingWsClient

class
ws-transport.ts:98

Reconnecting WebSocket client that connects a Yoltra store to the DevTools hub.

- Performs the DevTools protocol handshake on each connection. - Buffers outgoing messages (up to 100) while disconnected, dropping the oldest. - Uses exponential backoff with jitter for reconnection attempts. - Tracks connection epochs to safely discard stale callbacks. - Transport-agnostic: the socket is created by the injected factory.

Constructor

constructor

signature
new(storeId, storeName, capabilities, config, createSocket): ReconnectingWsClient

Parameters

NameTypeDescription
storeIdstring
NameTypeDescription
storeNamestring
NameTypeDescription
capabilitiesStoreCapabilities
NameTypeDescription
configReconnectingWsConfig
NameTypeDescription
createSocketDevtoolsSocketFactory

Returns

ReconnectingWsClient

Methods

connect

Connect to the DevTools hub at host:port.

signature
connect(host, port): void

Connect to the DevTools hub at host:port.

Parameters

NameTypeDescription
hoststring
NameTypeDescription
portnumber

Returns

void

disconnect

Disconnect and stop reconnection attempts.

signature
disconnect(): void

Disconnect and stop reconnection attempts.

Returns

void

getDroppedCount

Total messages dropped due to buffer overflow while disconnected.

signature
getDroppedCount(): number

Total messages dropped due to buffer overflow while disconnected.

Returns

number

getState

Current connection state.

signature
getState(): ConnectionState

Current connection state.

Returns

ConnectionState

onBackpressure

Register a handler fired when a buffered message is dropped because the send buffer overflowed while disconnected (backpressure). Receives the running total of dropped messages so the loss is never silent.

signature
onBackpressure(handler): void

Register a handler fired when a buffered message is dropped because the send buffer overflowed while disconnected (backpressure). Receives the running total of dropped messages so the loss is never silent.

Parameters

NameTypeDescription
handler(droppedTotal: number) => void

Returns

void

onConnected

Register a handler for successful connection (post-handshake).

signature
onConnected(handler): void

Register a handler for successful connection (post-handshake).

Parameters

NameTypeDescription
handler() => void

Returns

void

onDisconnected

Register a handler for disconnection.

signature
onDisconnected(handler): void

Register a handler for disconnection.

Parameters

NameTypeDescription
handler() => void

Returns

void

onMessage

Register a handler for incoming messages (post-handshake).

signature
onMessage(handler): void

Register a handler for incoming messages (post-handshake).

Parameters

NameTypeDescription
handler(data: string) => void

Returns

void

send

Send a message, buffering (FIFO) while disconnected; drops oldest on overflow.

signature
send(message): void

Send a message, buffering (FIFO) while disconnected; drops oldest on overflow.

Parameters

NameTypeDescription
messagestring

Returns

void