hume 0.10.4-beta.4 → 0.10.4-beta.5
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.
|
@@ -13,7 +13,7 @@ export declare class CloseEvent extends Event {
|
|
|
13
13
|
code: number;
|
|
14
14
|
reason: string;
|
|
15
15
|
wasClean: boolean;
|
|
16
|
-
willReconnect
|
|
16
|
+
willReconnect?: boolean;
|
|
17
17
|
constructor(code: number | undefined, reason: string | undefined, target: any);
|
|
18
18
|
}
|
|
19
19
|
export interface WebSocketEventMap {
|
package/core/websocket/ws.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export declare class ReconnectingWebSocket {
|
|
|
36
36
|
private readonly _url;
|
|
37
37
|
private readonly _protocols?;
|
|
38
38
|
private readonly _options;
|
|
39
|
+
private readonly _WebSocket;
|
|
39
40
|
constructor(url: UrlProvider, protocols?: string | string[], options?: Options);
|
|
40
41
|
static get CONNECTING(): number;
|
|
41
42
|
static get OPEN(): number;
|
package/core/websocket/ws.js
CHANGED
|
@@ -175,15 +175,18 @@ class ReconnectingWebSocket {
|
|
|
175
175
|
if (this._shouldReconnect)
|
|
176
176
|
this._connect();
|
|
177
177
|
};
|
|
178
|
+
console.log('constructing...');
|
|
178
179
|
this._url = url;
|
|
179
180
|
this._protocols = protocols;
|
|
180
181
|
this._options = options;
|
|
181
|
-
|
|
182
|
+
this._WebSocket = this._options.WebSocket || getGlobalWebSocket();
|
|
183
|
+
if (!isWebSocket(this._WebSocket)) {
|
|
182
184
|
throw Error("No valid WebSocket class provided");
|
|
183
185
|
}
|
|
184
186
|
if (this._options.startClosed) {
|
|
185
187
|
this._shouldReconnect = false;
|
|
186
188
|
}
|
|
189
|
+
console.log('all good');
|
|
187
190
|
this._connect();
|
|
188
191
|
}
|
|
189
192
|
static get CONNECTING() {
|
|
@@ -432,7 +435,7 @@ class ReconnectingWebSocket {
|
|
|
432
435
|
}
|
|
433
436
|
// Set lock for this attempt
|
|
434
437
|
this._connectLock = true;
|
|
435
|
-
const { maxRetries = DEFAULT.maxRetries, connectionTimeout = DEFAULT.connectionTimeout,
|
|
438
|
+
const { maxRetries = DEFAULT.maxRetries, connectionTimeout = DEFAULT.connectionTimeout, } = this._options;
|
|
436
439
|
// Max retries check
|
|
437
440
|
if (this._retryCount >= maxRetries) {
|
|
438
441
|
this._shutdown(new Error(`Max retries (${maxRetries}) reached. Giving up.`), "Max retries reached");
|
|
@@ -453,7 +456,7 @@ class ReconnectingWebSocket {
|
|
|
453
456
|
return;
|
|
454
457
|
}
|
|
455
458
|
this._debug("connect", { url, protocols: this._protocols });
|
|
456
|
-
this._ws = this._protocols ? new
|
|
459
|
+
this._ws = this._protocols ? new (this._WebSocket)(url, this._protocols) : new (this._WebSocket)(url);
|
|
457
460
|
this._ws.binaryType = this._binaryType;
|
|
458
461
|
this._addListeners();
|
|
459
462
|
this._connectLock = false;
|
|
@@ -13,7 +13,7 @@ export declare class CloseEvent extends Event {
|
|
|
13
13
|
code: number;
|
|
14
14
|
reason: string;
|
|
15
15
|
wasClean: boolean;
|
|
16
|
-
willReconnect
|
|
16
|
+
willReconnect?: boolean;
|
|
17
17
|
constructor(code: number | undefined, reason: string | undefined, target: any);
|
|
18
18
|
}
|
|
19
19
|
export interface WebSocketEventMap {
|
|
@@ -36,6 +36,7 @@ export declare class ReconnectingWebSocket {
|
|
|
36
36
|
private readonly _url;
|
|
37
37
|
private readonly _protocols?;
|
|
38
38
|
private readonly _options;
|
|
39
|
+
private readonly _WebSocket;
|
|
39
40
|
constructor(url: UrlProvider, protocols?: string | string[], options?: Options);
|
|
40
41
|
static get CONNECTING(): number;
|
|
41
42
|
static get OPEN(): number;
|
|
@@ -175,15 +175,18 @@ class ReconnectingWebSocket {
|
|
|
175
175
|
if (this._shouldReconnect)
|
|
176
176
|
this._connect();
|
|
177
177
|
};
|
|
178
|
+
console.log('constructing...');
|
|
178
179
|
this._url = url;
|
|
179
180
|
this._protocols = protocols;
|
|
180
181
|
this._options = options;
|
|
181
|
-
|
|
182
|
+
this._WebSocket = this._options.WebSocket || getGlobalWebSocket();
|
|
183
|
+
if (!isWebSocket(this._WebSocket)) {
|
|
182
184
|
throw Error("No valid WebSocket class provided");
|
|
183
185
|
}
|
|
184
186
|
if (this._options.startClosed) {
|
|
185
187
|
this._shouldReconnect = false;
|
|
186
188
|
}
|
|
189
|
+
console.log('all good');
|
|
187
190
|
this._connect();
|
|
188
191
|
}
|
|
189
192
|
static get CONNECTING() {
|
|
@@ -432,7 +435,7 @@ class ReconnectingWebSocket {
|
|
|
432
435
|
}
|
|
433
436
|
// Set lock for this attempt
|
|
434
437
|
this._connectLock = true;
|
|
435
|
-
const { maxRetries = DEFAULT.maxRetries, connectionTimeout = DEFAULT.connectionTimeout,
|
|
438
|
+
const { maxRetries = DEFAULT.maxRetries, connectionTimeout = DEFAULT.connectionTimeout, } = this._options;
|
|
436
439
|
// Max retries check
|
|
437
440
|
if (this._retryCount >= maxRetries) {
|
|
438
441
|
this._shutdown(new Error(`Max retries (${maxRetries}) reached. Giving up.`), "Max retries reached");
|
|
@@ -453,7 +456,7 @@ class ReconnectingWebSocket {
|
|
|
453
456
|
return;
|
|
454
457
|
}
|
|
455
458
|
this._debug("connect", { url, protocols: this._protocols });
|
|
456
|
-
this._ws = this._protocols ? new
|
|
459
|
+
this._ws = this._protocols ? new (this._WebSocket)(url, this._protocols) : new (this._WebSocket)(url);
|
|
457
460
|
this._ws.binaryType = this._binaryType;
|
|
458
461
|
this._addListeners();
|
|
459
462
|
this._connectLock = false;
|