laplace-api 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -62,6 +62,7 @@ export class LivePriceWebSocketClient {
|
|
|
62
62
|
private closedReason: WebSocketCloseReason | null = null;
|
|
63
63
|
private wsUrl: string | null = null;
|
|
64
64
|
private readonly options: Required<WebSocketOptions>;
|
|
65
|
+
private connectPromise: Promise<void> | null = null;
|
|
65
66
|
|
|
66
67
|
constructor(options: WebSocketOptions = {}) {
|
|
67
68
|
this.options = {
|
|
@@ -97,7 +98,12 @@ export class LivePriceWebSocketClient {
|
|
|
97
98
|
|
|
98
99
|
if (!this.ws || this.ws.readyState === WebSocket.CLOSED) {
|
|
99
100
|
this.ws = new WebSocket(url);
|
|
100
|
-
|
|
101
|
+
this.connectPromise = this.setupWebSocket();
|
|
102
|
+
|
|
103
|
+
await this.connectPromise
|
|
104
|
+
|
|
105
|
+
this.connectPromise = null;
|
|
106
|
+
|
|
101
107
|
}
|
|
102
108
|
|
|
103
109
|
return this.ws;
|
|
@@ -304,6 +310,10 @@ export class LivePriceWebSocketClient {
|
|
|
304
310
|
);
|
|
305
311
|
}
|
|
306
312
|
|
|
313
|
+
if (this.connectPromise) {
|
|
314
|
+
await this.connectPromise
|
|
315
|
+
}
|
|
316
|
+
|
|
307
317
|
if (this.ws.readyState !== WebSocket.OPEN) {
|
|
308
318
|
throw new WebSocketError(
|
|
309
319
|
"WebSocket is not connected",
|
|
@@ -328,6 +338,10 @@ export class LivePriceWebSocketClient {
|
|
|
328
338
|
);
|
|
329
339
|
}
|
|
330
340
|
|
|
341
|
+
if (this.connectPromise) {
|
|
342
|
+
await this.connectPromise
|
|
343
|
+
}
|
|
344
|
+
|
|
331
345
|
if (this.ws.readyState !== WebSocket.OPEN) {
|
|
332
346
|
throw new WebSocketError(
|
|
333
347
|
"WebSocket is not connected",
|