@reactoo/watchtogether-sdk-js 2.7.59 → 2.7.61
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/dist/watchtogether-sdk.min.js +2 -2
- package/package.json +1 -1
- package/src/models/iot.js +6 -0
- package/src/modules/wt-iot2.js +11 -8
package/package.json
CHANGED
package/src/models/iot.js
CHANGED
|
@@ -235,6 +235,12 @@ let iot = function () {
|
|
|
235
235
|
this.__privates.iot.log('Ignoring connection check failure, not connected');
|
|
236
236
|
return Promise.resolve();
|
|
237
237
|
}
|
|
238
|
+
|
|
239
|
+
if(isReconnecting) {
|
|
240
|
+
this.__privates.iot.log('Connection check failed, but we are already reconnecting...');
|
|
241
|
+
return Promise.resolve();
|
|
242
|
+
}
|
|
243
|
+
|
|
238
244
|
this.__privates.iot.log('Connection check failed:', error);
|
|
239
245
|
return this.iot.__updateCredentials();
|
|
240
246
|
});
|
package/src/modules/wt-iot2.js
CHANGED
|
@@ -43,10 +43,6 @@ class Iot {
|
|
|
43
43
|
this.lastConnectParams = { apiMqttUrl, apiMqttClientId, region, accessKeyId, secretAccessKey, sessionToken, expiration };
|
|
44
44
|
|
|
45
45
|
return new Promise((resolve, reject) => {
|
|
46
|
-
const timeoutId = setTimeout(() => {
|
|
47
|
-
this.off('worker:connect_result');
|
|
48
|
-
reject(new Error('Connection timeout'));
|
|
49
|
-
}, 5000);
|
|
50
46
|
|
|
51
47
|
const handleConnectResult = (event) => {
|
|
52
48
|
clearTimeout(timeoutId);
|
|
@@ -59,6 +55,11 @@ class Iot {
|
|
|
59
55
|
}
|
|
60
56
|
};
|
|
61
57
|
|
|
58
|
+
const timeoutId = setTimeout(() => {
|
|
59
|
+
this.off('worker:connect_result', handleConnectResult);
|
|
60
|
+
reject(new Error('Connection timeout'));
|
|
61
|
+
}, 10000);
|
|
62
|
+
|
|
62
63
|
this.on('worker:connect_result', handleConnectResult);
|
|
63
64
|
|
|
64
65
|
this.worker.postMessage({
|
|
@@ -73,10 +74,6 @@ class Iot {
|
|
|
73
74
|
this.log('iot disconnect');
|
|
74
75
|
this.stopCredentialsExpirationCheck();
|
|
75
76
|
return new Promise((resolve, reject) => {
|
|
76
|
-
const timeoutId = setTimeout(() => {
|
|
77
|
-
this.off('worker:disconnect_result');
|
|
78
|
-
reject(new Error('Disconnect timeout'));
|
|
79
|
-
}, 5000);
|
|
80
77
|
|
|
81
78
|
const handleDisconnectResult = (event) => {
|
|
82
79
|
clearTimeout(timeoutId);
|
|
@@ -87,6 +84,12 @@ class Iot {
|
|
|
87
84
|
reject(new Error(event.error));
|
|
88
85
|
}
|
|
89
86
|
};
|
|
87
|
+
|
|
88
|
+
const timeoutId = setTimeout(() => {
|
|
89
|
+
this.off('worker:disconnect_result', handleDisconnectResult);
|
|
90
|
+
reject(new Error('Disconnect timeout'));
|
|
91
|
+
}, 5000);
|
|
92
|
+
|
|
90
93
|
this.on('worker:disconnect_result', handleDisconnectResult);
|
|
91
94
|
this.worker.postMessage({ type: 'disconnect' });
|
|
92
95
|
});
|