@reactoo/watchtogether-sdk-js 2.7.44-beta.2 → 2.7.44-beta.3
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 +34 -17
- 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 +20 -25
- package/src/modules/wt-iot.js +28 -2
|
@@ -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
|
-
|
|
16724
|
-
|
|
16725
|
-
|
|
16726
|
-
|
|
16727
|
-
|
|
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 => {
|
|
16723
|
+
isReconnecting = false;
|
|
16724
|
+
this.iot.$emit('isReconnecting', isReconnecting, false);
|
|
16725
|
+
this.__privates.iot.log('Credentials updated');
|
|
16726
|
+
return Promise.resolve(r);
|
|
16727
|
+
}).catch(error => {
|
|
16735
16728
|
isReconnecting = false;
|
|
16736
|
-
this.iot.$emit('isReconnecting', isReconnecting);
|
|
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: () => {
|
|
@@ -25348,14 +25343,36 @@ class Iot {
|
|
|
25348
25343
|
this.connection.on('connection_failure', error => {
|
|
25349
25344
|
this.emit('connection_failure', error);
|
|
25350
25345
|
});
|
|
25351
|
-
return
|
|
25346
|
+
return new Promise((resolve, reject) => {
|
|
25347
|
+
const timeoutId = setTimeout(() => {
|
|
25348
|
+
reject(new Error('Connection timeout'));
|
|
25349
|
+
}, 10000); // 10 seconds timeout is enough
|
|
25350
|
+
this.connection.connect().then(r => {
|
|
25351
|
+
clearTimeout(timeoutId);
|
|
25352
|
+
resolve(r);
|
|
25353
|
+
}).catch(error => {
|
|
25354
|
+
clearTimeout(timeoutId);
|
|
25355
|
+
reject(error);
|
|
25356
|
+
});
|
|
25357
|
+
});
|
|
25352
25358
|
});
|
|
25353
25359
|
}
|
|
25354
25360
|
disconnect() {
|
|
25355
25361
|
this.log('iot disconnect');
|
|
25356
25362
|
this.stopCredentialsExpirationCheck();
|
|
25357
25363
|
if (this.connection) {
|
|
25358
|
-
return
|
|
25364
|
+
return new Promise((resolve, reject) => {
|
|
25365
|
+
const timeoutId = setTimeout(() => {
|
|
25366
|
+
reject(new Error('Disconnect timeout'));
|
|
25367
|
+
}, 10000); // 10 seconds timeout is enough
|
|
25368
|
+
this.connection.disconnect().then(r => {
|
|
25369
|
+
clearTimeout(timeoutId);
|
|
25370
|
+
resolve(r);
|
|
25371
|
+
}).catch(error => {
|
|
25372
|
+
clearTimeout(timeoutId);
|
|
25373
|
+
reject(error);
|
|
25374
|
+
});
|
|
25375
|
+
});
|
|
25359
25376
|
} else return Promise.resolve();
|
|
25360
25377
|
}
|
|
25361
25378
|
isConnected() {
|