@reactoo/watchtogether-sdk-js 2.7.37 → 2.7.38-beta.1
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 +19 -3
package/package.json
CHANGED
package/src/models/iot.js
CHANGED
|
@@ -6,6 +6,7 @@ let iot = function () {
|
|
|
6
6
|
let keepAliveIntervalId = null;
|
|
7
7
|
let shouldBeConnected = false;
|
|
8
8
|
let isReconnecting = false;
|
|
9
|
+
let failureCount = 0;
|
|
9
10
|
|
|
10
11
|
return {
|
|
11
12
|
|
|
@@ -21,6 +22,7 @@ let iot = function () {
|
|
|
21
22
|
response.data.credentials.expiration
|
|
22
23
|
))
|
|
23
24
|
.catch(error => {
|
|
25
|
+
console.log('Failed to update credentials:', error);
|
|
24
26
|
this.__privates.iot.log('Failed to update credentials:', error);
|
|
25
27
|
// Let the error propagate to be handled by the Iot class
|
|
26
28
|
throw error;
|
|
@@ -46,21 +48,35 @@ let iot = function () {
|
|
|
46
48
|
}
|
|
47
49
|
},
|
|
48
50
|
onError: () => {
|
|
51
|
+
console.log('MQTT client error');
|
|
49
52
|
this.__privates.iot.log('MQTT client error');
|
|
50
53
|
},
|
|
51
54
|
onDisconnect: () => {
|
|
55
|
+
console.log('MQTT client disconnect');
|
|
52
56
|
this.__privates.iot.log('MQTT client disconnect');
|
|
53
57
|
},
|
|
54
58
|
onInterrupt: () => {
|
|
59
|
+
console.log('MQTT client interrupt');
|
|
55
60
|
this.__privates.iot.log('MQTT client interrupt');
|
|
56
61
|
},
|
|
57
62
|
onResume: () => {
|
|
63
|
+
console.log('MQTT client resume');
|
|
58
64
|
this.__privates.iot.log('MQTT client resume');
|
|
59
65
|
},
|
|
60
66
|
onConnectionSuccess: () => {
|
|
67
|
+
console.log('MQTT client connection_success');
|
|
61
68
|
this.__privates.iot.log('MQTT client connection_success');
|
|
62
69
|
},
|
|
63
70
|
onConnectionFailure: () => {
|
|
71
|
+
|
|
72
|
+
if(shouldBeConnected && !isReconnecting && failureCount > 10) {
|
|
73
|
+
this.iot.__updateCredentials();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
//failureCount++;
|
|
77
|
+
|
|
78
|
+
console.log('MQTT client connection_failure');
|
|
79
|
+
|
|
64
80
|
this.__privates.iot.log('MQTT client connection_failure');
|
|
65
81
|
},
|
|
66
82
|
|
|
@@ -125,11 +141,11 @@ let iot = function () {
|
|
|
125
141
|
if(!keepCurrentTopics) {
|
|
126
142
|
__currentTopics.clear();
|
|
127
143
|
}
|
|
128
|
-
return this.__privates.iot.disconnect()
|
|
129
|
-
.then(() => {
|
|
130
144
|
|
|
131
|
-
|
|
145
|
+
shouldBeConnected = false;
|
|
132
146
|
|
|
147
|
+
return this.__privates.iot.disconnect()
|
|
148
|
+
.then(() => {
|
|
133
149
|
this.iot.disableVisibilityChangeListener();
|
|
134
150
|
//this.iot.disableKeepAliveInterval();
|
|
135
151
|
this.iot.$off('connect', this.iot.onConnect, this);
|