Kind: Class
Source: atloria-monorepo/packages/api-client/src/clients/WebSocketClient.ts
WebSocket client for real-time updates
Methods
| Method | Signature | Returns |
|---|---|---|
connect | connect(url: string, token: string) | void |
disconnect | disconnect() | void |
subscribe | subscribe(channel: string, callback: (data: unknown) => void) | () => void |
unsubscribe | unsubscribe(channel: string, callback: (data: unknown) => void) | void |
send | send(channel: string, data: unknown) | void |
getState | getState() | WebSocketState |
isConnected | isConnected() | boolean |
Where it refuses work
WebSocketClientstops the work with an early return when!channelSubscriptions.WebSocketClientstops the work with an early return whenmessage.type === 'pong'.WebSocketClientstops the work with an early return whenthis.config.heartbeatInterval <= 0.
When something fails
WebSocketClienthandles failure in 4 places: it logs it and continues in all 4.
Was this page helpful?