@reactoo/watchtogether-sdk-js 2.7.36 → 2.7.37
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
package/src/models/iot.js
CHANGED
|
@@ -5,12 +5,14 @@ let iot = function () {
|
|
|
5
5
|
let visibilityChangeHandler = null;
|
|
6
6
|
let keepAliveIntervalId = null;
|
|
7
7
|
let shouldBeConnected = false;
|
|
8
|
+
let isReconnecting = false;
|
|
8
9
|
|
|
9
10
|
return {
|
|
10
11
|
|
|
11
12
|
__promise: null,
|
|
12
13
|
|
|
13
14
|
__updateCredentials: () => {
|
|
15
|
+
isReconnecting = true;
|
|
14
16
|
return this.iot.getCredentials()
|
|
15
17
|
.then(response => this.__privates.iot.updateWebSocketCredentials(
|
|
16
18
|
response.data.credentials.accessKeyId,
|
|
@@ -22,6 +24,9 @@ let iot = function () {
|
|
|
22
24
|
this.__privates.iot.log('Failed to update credentials:', error);
|
|
23
25
|
// Let the error propagate to be handled by the Iot class
|
|
24
26
|
throw error;
|
|
27
|
+
})
|
|
28
|
+
.finally(() => {
|
|
29
|
+
isReconnecting = false;
|
|
25
30
|
});
|
|
26
31
|
},
|
|
27
32
|
|
|
@@ -36,7 +41,7 @@ let iot = function () {
|
|
|
36
41
|
},
|
|
37
42
|
onClosed: () => {
|
|
38
43
|
this.__privates.iot.log('MQTT client closed');
|
|
39
|
-
if(shouldBeConnected) {
|
|
44
|
+
if(shouldBeConnected && !isReconnecting) {
|
|
40
45
|
this.iot.__updateCredentials();
|
|
41
46
|
}
|
|
42
47
|
},
|
package/src/modules/wt-iot.js
CHANGED
|
@@ -252,20 +252,21 @@ class Iot {
|
|
|
252
252
|
this.log('iot updateWebSocketCredentials');
|
|
253
253
|
this.lastConnectParams = {...this.lastConnectParams, accessKeyId, secretAccessKey, sessionToken, expiration };
|
|
254
254
|
const currentTopics = new Set(this.subscribedTopics);
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
255
|
+
|
|
256
|
+
// disconnect is part of connect process
|
|
257
|
+
|
|
258
|
+
return this.connect(
|
|
259
|
+
this.lastConnectParams.apiMqttUrl,
|
|
260
|
+
this.lastConnectParams.apiMqttClientId,
|
|
261
|
+
this.lastConnectParams.region,
|
|
262
|
+
accessKeyId,
|
|
263
|
+
secretAccessKey,
|
|
264
|
+
sessionToken,
|
|
265
|
+
expiration
|
|
266
|
+
).then(() => {
|
|
267
|
+
// Resubscribe to topics
|
|
268
|
+
currentTopics.forEach(topic => this.subscribe(topic));
|
|
269
|
+
this.startCredentialsExpirationCheck(expiration);
|
|
269
270
|
})
|
|
270
271
|
}
|
|
271
272
|
|