Skip to content
This repository has been archived by the owner on Sep 9, 2023. It is now read-only.

Add retryTimeoutMs param #318

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/BasicClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Watcher } from "./Watcher";
import { Market } from "./Market";

export type MarketMap = Map<string, Market>;
export type WssFactoryFn = (path: string) => SmartWss;
export type WssFactoryFn = (path: string, retryTimeoutMs?: number) => SmartWss;
export type SendFn = (remoteId: string, market: Market) => void;

/**
Expand Down Expand Up @@ -42,6 +42,7 @@ export abstract class BasicClient extends EventEmitter implements IClient {
readonly name: string,
wssFactory?: WssFactoryFn,
watcherMs?: number,
retryTimeoutMs?: number,
) {
super();
this._tickerSubs = new Map();
Expand All @@ -61,7 +62,7 @@ export abstract class BasicClient extends EventEmitter implements IClient {
this.hasLevel2Updates = false;
this.hasLevel3Snapshots = false;
this.hasLevel3Updates = false;
this._wssFactory = wssFactory || (path => new SmartWss(path));
this._wssFactory = wssFactory || (path => new SmartWss(path, retryTimeoutMs));
}

//////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions src/ClientOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export type ClientOptions = {
wssPath?: string;
watcherMs?: number;
throttleMs?: number;
retryTimeoutMs?: number;
l2UpdateDepth?: number;
throttleL2Snapshot?: number;
};
4 changes: 2 additions & 2 deletions src/SmartWss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export class SmartWss extends EventEmitter {
private _connected: boolean;
private _wss: any;

constructor(readonly wssPath: string) {
constructor(readonly wssPath: string, retryTimeoutMs = 15000) {
super();
this._retryTimeoutMs = 15000;
this._retryTimeoutMs = retryTimeoutMs;
this._connected = false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/exchanges/DigifinexClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import * as zlib from "../ZlibUtils";
export class DigifinexClient extends BasicClient {
public id: number;

constructor({ wssPath = "wss://openapi.digifinex.com/ws/v1/", watcherMs }: ClientOptions = {}) {
super(wssPath, "Digifinex", undefined, watcherMs);
constructor({ wssPath = "wss://openapi.digifinex.com/ws/v1/", watcherMs, retryTimeoutMs }: ClientOptions = {}) {
super(wssPath, "Digifinex", undefined, watcherMs, retryTimeoutMs);
this.hasTickers = true;
this.hasTrades = true;
this.hasLevel2Updates = true;
Expand Down