ReconnectingWsClient
classReconnecting 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
Methods
connect
Connect to the DevTools hub at host:port.
disconnect
Disconnect and stop reconnection attempts.
getDroppedCount
Total messages dropped due to buffer overflow while disconnected.
getState
Current connection state.
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.
onConnected
Register a handler for successful connection (post-handshake).
onDisconnected
Register a handler for disconnection.
onMessage
Register a handler for incoming messages (post-handshake).
send
Send a message, buffering (FIFO) while disconnected; drops oldest on overflow.