on(type, handler). There are two
kinds of event: server frames (keyed by the frame’s type) and
lifecycle events (connection-level signals the client raises itself). The
handler payload is typed per event — on("snapshot", …) gives you a
SnapshotFrame, on("reconnecting", …) gives you { attempt, delayMs }.
on returns an unsubscribe function — call it to remove that handler:
Server frames
Every frame carriestype, a v version, and a serverTimestamp. The table
lists the additional fields you’ll use most; the WebSocket API’s
Message catalog documents each frame in full.
A few notes:
snapshot/deltaare the orderbook. Apply the snapshot first, then each delta (achangewithsize: 0deletes that price level).seqis a per-subscription monotonic counter for detecting gaps — see Orderbook channel.statusreportslive,resyncing,closed,unsupported, orunavailable. When the server retires a subscription (closed/unsupported) the client drops it from its resubscribe set so it isn’t replayed on reconnect.errorframes raised during subscription creation carry themarketandchannelthat failed (there’s nosubscriptionIdyet); the client prunes that market so it won’t be retried on reconnect. See Errors for thecodevalues.goodbyeprecedes a close. Some reasons are terminal — see Reconnection & lifecycle.
Lifecycle events
These are raised by the client, not sent by the server. They’re distinct from the server’serror and goodbye frames.
reconnecting versus terminated fires.