Class: WebsocketClientLegacy
Deprecated
Legacy WebSocket client retained for compatibility. Use WebsocketClient for new code.
Extends
EventEmitter
Constructors
Constructor
ts
new WebsocketClientLegacy(options: WSClientConfigurableOptions, logger?: object): WebsocketClientLegacy;Parameters
| Parameter | Type | Description |
|---|---|---|
options | WSClientConfigurableOptions | - |
logger? | { error: (...params: any) => void; info: (...params: any) => void; trace: (..._params: any) => void; } | - |
logger.error? | (...params: any) => void | - |
logger.info? | (...params: any) => void | - |
logger.trace? | (..._params: any) => void | Ping/pong events and other raw messages that might be noisy. Enable this while troubleshooting. |
Returns
WebsocketClientLegacy
Methods
close()
ts
close(wsKey: WsKey, force?: boolean): void;Parameters
| Parameter | Type |
|---|---|
wsKey | WsKey |
force? | boolean |
Returns
void
closeAll()
ts
closeAll(force?: boolean): void;Parameters
| Parameter | Type |
|---|---|
force? | boolean |
Returns
void
connectAll()
ts
connectAll(): Promise<WebSocket | undefined>[];Request connection of all dependent (public & private) websockets, instead of waiting for automatic connection by library
Returns
Promise<WebSocket | undefined>[]
connectPrivate()
ts
connectPrivate(businessEndpoint?: boolean): Promise<WebSocket | undefined>;Parameters
| Parameter | Type |
|---|---|
businessEndpoint? | boolean |
Returns
Promise<WebSocket | undefined>
connectPublic()
ts
connectPublic(businessEndpoint?: boolean): Promise<WebSocket | undefined>;Parameters
| Parameter | Type |
|---|---|
businessEndpoint? | boolean |
Returns
Promise<WebSocket | undefined>
emit()
ts
emit<U extends keyof WSClientEventMap<WsKey, WsDataEvent<any>>>(event: U, ...args: Parameters<WSClientEventMap<WsKey, any>[U]>): boolean;Type Parameters
| Type Parameter |
|---|
U extends keyof WSClientEventMap<WsKey, WsDataEvent<any>> |
Parameters
| Parameter | Type |
|---|---|
event | U |
...args | Parameters<WSClientEventMap<WsKey, any>[U]> |
Returns
boolean
getWsStore()
ts
getWsStore(): WsStore<WsKey, WsChannelSubUnSubRequestArg>;Get the WsStore that tracks websocket & topic state
Returns
WsStore<WsKey, WsChannelSubUnSubRequestArg>
on()
ts
on<U extends keyof WSClientEventMap<WsKey, WsDataEvent<any>>>(event: U, listener: WSClientEventMap<WsKey, any>[U]): this;Type Parameters
| Type Parameter |
|---|
U extends keyof WSClientEventMap<WsKey, WsDataEvent<any>> |
Parameters
| Parameter | Type |
|---|---|
event | U |
listener | WSClientEventMap<WsKey, any>[U] |
Returns
this
subscribe()
ts
subscribe(wsEvents:
| WsChannelSubUnSubRequestArg
| WsChannelSubUnSubRequestArg[], isPrivateTopic?: boolean): void;Subscribe to topics & track/persist them. They will be automatically resubscribed to if the connection drops/reconnects.
Parameters
| Parameter | Type | Description |
|---|---|---|
wsEvents | | WsChannelSubUnSubRequestArg | WsChannelSubUnSubRequestArg[] | topic or list of topics |
isPrivateTopic? | boolean | optional - the library will try to detect private topics, you can use this to mark a topic as private (if the topic isn't recognised yet) |
Returns
void
tryWsSend()
ts
tryWsSend(wsKey: WsKey, wsMessage: string): void;Parameters
| Parameter | Type |
|---|---|
wsKey | WsKey |
wsMessage | string |
Returns
void
unsubscribe()
ts
unsubscribe(wsTopics:
| WsChannelSubUnSubRequestArg
| WsChannelSubUnSubRequestArg[], isPrivateTopic?: boolean): void;Unsubscribe from topics & remove them from memory. They won't be re-subscribed to if the connection reconnects.
Parameters
| Parameter | Type | Description |
|---|---|---|
wsTopics | | WsChannelSubUnSubRequestArg | WsChannelSubUnSubRequestArg[] | topic or list of topics |
isPrivateTopic? | boolean | optional - the library will try to detect private topics, you can use this to mark a topic as private (if the topic isn't recognised yet) |
Returns
void