Appearance
Live socket
One socket per terminal carries everything: prices, account events, CRM notifications. Which frames arrive depends on the session, rights and group scope.
ts
const socket = staff.socket() // or "trader"
socket.on("welcome", (f) => console.log("signed in as", f.login))
socket.on("trade", (f) => applyTrade(f.data)) // typed from the gateway's AsyncAPI document
socket.on("prices", (prices) => render(prices)) // decoded binary frames
socket.on("open", ({ reconnect }) => reconnect && reloadEverything())
socket.on("close", ({ reason, willReconnect }) => console.log(reason, willReconnect))
await socket.connect()
socket.watch([1, 2, 7])What the SDK does for you
- Sign-in: browsers open
/{side}/v1/wswith the session cookie; apps open/wswith the bearer token in the subprotocol. - Reconnect from 1 s, doubling up to 30 s, with jitter. Not after
"session ended"(a new sign-in elsewhere) orclose(). - Restores watched symbols and the journal switch after reconnecting. Frames missed meanwhile are lost: reload over REST when
opensaysreconnect: true. - Decodes binary price frames into exact decimal strings.
Sending messages
ts
socket.send({ type: "journal", on: true }) // staff with server.logs
socket.send({ type: "ping" })All frames and messages: socket reference.
Limits
20 messages per second and 4096 bytes per message from the client; 1000 watched symbols per socket (fewer when the group sets a symbol limit, raw and normal watches count together); 8 sockets per login per gateway. Symbols over the limit are ignored, not refused.