Skip to content

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 ​

ParameterTypeDescription
optionsWSClientConfigurableOptions-
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) => voidPing/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 ​

ParameterType
wsKeyWsKey
force?boolean

Returns ​

void


closeAll() ​

ts
closeAll(force?: boolean): void;

Parameters ​

ParameterType
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 ​

ParameterType
businessEndpoint?boolean

Returns ​

Promise<WebSocket | undefined>


connectPublic() ​

ts
connectPublic(businessEndpoint?: boolean): Promise<WebSocket | undefined>;

Parameters ​

ParameterType
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 ​

ParameterType
eventU
...argsParameters<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 ​

ParameterType
eventU
listenerWSClientEventMap<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 ​

ParameterTypeDescription
wsEvents| WsChannelSubUnSubRequestArg | WsChannelSubUnSubRequestArg[]topic or list of topics
isPrivateTopic?booleanoptional - 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 ​

ParameterType
wsKeyWsKey
wsMessagestring

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 ​

ParameterTypeDescription
wsTopics| WsChannelSubUnSubRequestArg | WsChannelSubUnSubRequestArg[]topic or list of topics
isPrivateTopic?booleanoptional - 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

Built by Siebly. Open source SDKs for exchange APIs.