@reactoo/watchtogether-sdk-js 2.7.44-beta.2 → 2.7.44-beta.4
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.js +43 -22
- package/dist/watchtogether-sdk.js.map +1 -1
- package/dist/watchtogether-sdk.min.js +2 -2
- package/package.json +1 -1
- package/src/models/iot.js +25 -25
- package/src/modules/wt-iot.js +30 -8
|
@@ -16718,22 +16718,17 @@ let iot = function () {
|
|
|
16718
16718
|
this.__privates.iot.log('Updating Credentials...');
|
|
16719
16719
|
interruptCount = 0;
|
|
16720
16720
|
isReconnecting = true;
|
|
16721
|
-
this.iot.$emit('isReconnecting', isReconnecting);
|
|
16722
|
-
return
|
|
16723
|
-
const timeoutId = setTimeout(() => {
|
|
16724
|
-
reject(new Error('Updating Credentials Timeout...'));
|
|
16725
|
-
}, 10000); // 10 seconds timeout is enough
|
|
16726
|
-
this.iot.getCredentials().then(response => this.__privates.iot.updateWebSocketCredentials(response.data.credentials.accessKeyId, response.data.credentials.secretAccessKey, response.data.credentials.sessionToken, response.data.credentials.expiration)).then(() => {
|
|
16727
|
-
clearTimeout(timeoutId);
|
|
16728
|
-
resolve();
|
|
16729
|
-
}).catch(error => {
|
|
16730
|
-
clearTimeout(timeoutId);
|
|
16731
|
-
this.__privates.iot.log('Failed to update credentials:', error);
|
|
16732
|
-
reject(error);
|
|
16733
|
-
});
|
|
16734
|
-
}).finally(() => {
|
|
16721
|
+
this.iot.$emit('isReconnecting', isReconnecting, true);
|
|
16722
|
+
return this.iot.getCredentials().then(response => this.__privates.iot.updateWebSocketCredentials(response.data.credentials.accessKeyId, response.data.credentials.secretAccessKey, response.data.credentials.sessionToken, response.data.credentials.expiration)).then(r => {
|
|
16735
16723
|
isReconnecting = false;
|
|
16736
|
-
this.iot.$emit('isReconnecting', isReconnecting);
|
|
16724
|
+
this.iot.$emit('isReconnecting', isReconnecting, false);
|
|
16725
|
+
this.__privates.iot.log('Credentials updated');
|
|
16726
|
+
return Promise.resolve(r);
|
|
16727
|
+
}).catch(error => {
|
|
16728
|
+
isReconnecting = false;
|
|
16729
|
+
this.iot.$emit('isReconnecting', isReconnecting, true);
|
|
16730
|
+
this.__privates.iot.log('Failed to update credentials:', error);
|
|
16731
|
+
return Promise.reject(error);
|
|
16737
16732
|
});
|
|
16738
16733
|
},
|
|
16739
16734
|
getCredentials: () => {
|
|
@@ -16895,6 +16890,9 @@ let iot = function () {
|
|
|
16895
16890
|
clearInterval(keepAliveIntervalId);
|
|
16896
16891
|
keepAliveIntervalId = setInterval(() => {
|
|
16897
16892
|
this.__privates.iot.checkConnection().catch(error => {
|
|
16893
|
+
if ((error === null || error === void 0 ? void 0 : error.cause) === -1) {
|
|
16894
|
+
return;
|
|
16895
|
+
}
|
|
16898
16896
|
if (!document.hidden && shouldBeConnected && !isReconnecting) {
|
|
16899
16897
|
this.__privates.iot.log('Keepalive failed:', error);
|
|
16900
16898
|
this.iot.__updateCredentials();
|
|
@@ -25348,14 +25346,36 @@ class Iot {
|
|
|
25348
25346
|
this.connection.on('connection_failure', error => {
|
|
25349
25347
|
this.emit('connection_failure', error);
|
|
25350
25348
|
});
|
|
25351
|
-
return
|
|
25349
|
+
return new Promise((resolve, reject) => {
|
|
25350
|
+
const timeoutId = setTimeout(() => {
|
|
25351
|
+
reject(new Error('Connection timeout'));
|
|
25352
|
+
}, 10000); // 10 seconds timeout is enough
|
|
25353
|
+
this.connection.connect().then(r => {
|
|
25354
|
+
clearTimeout(timeoutId);
|
|
25355
|
+
resolve(r);
|
|
25356
|
+
}).catch(error => {
|
|
25357
|
+
clearTimeout(timeoutId);
|
|
25358
|
+
reject(error);
|
|
25359
|
+
});
|
|
25360
|
+
});
|
|
25352
25361
|
});
|
|
25353
25362
|
}
|
|
25354
25363
|
disconnect() {
|
|
25355
25364
|
this.log('iot disconnect');
|
|
25356
25365
|
this.stopCredentialsExpirationCheck();
|
|
25357
25366
|
if (this.connection) {
|
|
25358
|
-
return
|
|
25367
|
+
return new Promise((resolve, reject) => {
|
|
25368
|
+
const timeoutId = setTimeout(() => {
|
|
25369
|
+
reject(new Error('Disconnect timeout'));
|
|
25370
|
+
}, 10000); // 10 seconds timeout is enough
|
|
25371
|
+
this.connection.disconnect().then(r => {
|
|
25372
|
+
clearTimeout(timeoutId);
|
|
25373
|
+
resolve(r);
|
|
25374
|
+
}).catch(error => {
|
|
25375
|
+
clearTimeout(timeoutId);
|
|
25376
|
+
reject(error);
|
|
25377
|
+
});
|
|
25378
|
+
});
|
|
25359
25379
|
} else return Promise.resolve();
|
|
25360
25380
|
}
|
|
25361
25381
|
isConnected() {
|
|
@@ -25532,17 +25552,18 @@ class Iot {
|
|
|
25532
25552
|
return;
|
|
25533
25553
|
}
|
|
25534
25554
|
if (this.subscribedTopics.size === 0) {
|
|
25535
|
-
reject(new Error('No subscribed topics available for connection check'
|
|
25555
|
+
reject(new Error('No subscribed topics available for connection check', {
|
|
25556
|
+
cause: -1
|
|
25557
|
+
}));
|
|
25536
25558
|
return;
|
|
25537
25559
|
}
|
|
25538
25560
|
|
|
25539
25561
|
// Find a suitable topic for the connection check
|
|
25540
25562
|
let suitableTopic = Array.from(this.subscribedTopics).find(topic => topic.indexOf('user') > -1);
|
|
25541
25563
|
if (!suitableTopic) {
|
|
25542
|
-
|
|
25543
|
-
|
|
25544
|
-
|
|
25545
|
-
reject(new Error('No suitable topic found for connection check'));
|
|
25564
|
+
reject(new Error('No suitable topic found for connection check', {
|
|
25565
|
+
cause: -1
|
|
25566
|
+
}));
|
|
25546
25567
|
return;
|
|
25547
25568
|
}
|
|
25548
25569
|
const testMessage = {
|