@reactoo/watchtogether-sdk-js 2.7.67-beta.0 → 2.7.68
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 +15 -14
- package/src/modules/wt-iot2.js +3 -1
package/package.json
CHANGED
package/src/models/iot.js
CHANGED
|
@@ -10,10 +10,11 @@ let iot = function () {
|
|
|
10
10
|
let subscriptionFailureCount = 0;
|
|
11
11
|
|
|
12
12
|
return {
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
__promise: null,
|
|
15
15
|
|
|
16
16
|
__createNewWorker: () => {
|
|
17
|
+
this.__privates.iot.log('Creating new worker...');
|
|
17
18
|
this.__privates.iot.terminateWorker();
|
|
18
19
|
this.__privates.iot.initWorker();
|
|
19
20
|
},
|
|
@@ -44,11 +45,11 @@ let iot = function () {
|
|
|
44
45
|
return Promise.reject(error);
|
|
45
46
|
});
|
|
46
47
|
},
|
|
47
|
-
|
|
48
|
+
|
|
48
49
|
getCredentials: () => {
|
|
49
50
|
return this.__privates.auth.__client
|
|
50
51
|
.then(client => client.apis.auth.iotSignIn({}, {requestBody: {suggestedTopics:true, domain: location.hostname}}))
|
|
51
|
-
|
|
52
|
+
|
|
52
53
|
},
|
|
53
54
|
|
|
54
55
|
onConnect: (data, connectionId) => {
|
|
@@ -92,7 +93,7 @@ let iot = function () {
|
|
|
92
93
|
interruptCount++;
|
|
93
94
|
this.__privates.iot.log('MQTT client connection_failure');
|
|
94
95
|
},
|
|
95
|
-
|
|
96
|
+
|
|
96
97
|
iotLogin: (subscribeToSuggestedTopics = true) => {
|
|
97
98
|
|
|
98
99
|
interruptCount = 0;
|
|
@@ -151,13 +152,12 @@ let iot = function () {
|
|
|
151
152
|
|
|
152
153
|
return this.iot.__promise;
|
|
153
154
|
},
|
|
154
|
-
|
|
155
|
+
|
|
155
156
|
iotLogout: (keepCurrentTopics = false) => {
|
|
156
157
|
|
|
157
158
|
if(!keepCurrentTopics) {
|
|
158
159
|
__currentTopics.clear();
|
|
159
160
|
this.__privates.iot.clearTopics();
|
|
160
|
-
this.__privates.iot.terminateWorker();
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
interruptCount = 0;
|
|
@@ -169,6 +169,7 @@ let iot = function () {
|
|
|
169
169
|
|
|
170
170
|
return this.__privates.iot.disconnect()
|
|
171
171
|
.finally(() => {
|
|
172
|
+
this.__privates.iot.terminateWorker();
|
|
172
173
|
this.iot.$off('connect', this.iot.onConnect, this);
|
|
173
174
|
this.iot.$off('closed', this.iot.onClosed, this);
|
|
174
175
|
this.iot.$off('error', this.iot.onError, this);
|
|
@@ -182,11 +183,11 @@ let iot = function () {
|
|
|
182
183
|
return true;
|
|
183
184
|
});
|
|
184
185
|
},
|
|
185
|
-
|
|
186
|
+
|
|
186
187
|
isConnected: () => {
|
|
187
188
|
return this.__privates.iot.isConnected();
|
|
188
189
|
},
|
|
189
|
-
|
|
190
|
+
|
|
190
191
|
subscribe: (topic) => {
|
|
191
192
|
if(!__currentTopics.has(topic)) {
|
|
192
193
|
__currentTopics.add(topic);
|
|
@@ -218,7 +219,7 @@ let iot = function () {
|
|
|
218
219
|
});
|
|
219
220
|
}
|
|
220
221
|
},
|
|
221
|
-
|
|
222
|
+
|
|
222
223
|
unsubscribe: (topic) => {
|
|
223
224
|
__currentTopics.delete(topic);
|
|
224
225
|
if(!this.iot.__promise) return Promise.reject('not_connected');
|
|
@@ -230,19 +231,19 @@ let iot = function () {
|
|
|
230
231
|
return Promise.reject('unsubscription_failed');
|
|
231
232
|
});
|
|
232
233
|
},
|
|
233
|
-
|
|
234
|
+
|
|
234
235
|
send: (topic, message) => {
|
|
235
236
|
return this.iot.__promise.then(() => this.__privates.iot.send(topic,message));
|
|
236
237
|
},
|
|
237
|
-
|
|
238
|
+
|
|
238
239
|
$once: (key, callback, that) => {
|
|
239
240
|
return this.__privates.iot.once(key, callback, that || this);
|
|
240
241
|
},
|
|
241
|
-
|
|
242
|
+
|
|
242
243
|
$on: (key, callback, that) => {
|
|
243
244
|
return this.__privates.iot.on(key, callback, that || this);
|
|
244
245
|
},
|
|
245
|
-
|
|
246
|
+
|
|
246
247
|
$off: (key, callback, that) => {
|
|
247
248
|
return this.__privates.iot.off(key, callback, that || this);
|
|
248
249
|
},
|
|
@@ -252,7 +253,7 @@ let iot = function () {
|
|
|
252
253
|
$emit: (key, ...args) => {
|
|
253
254
|
return this.__privates.iot.emit(key, ...args);
|
|
254
255
|
},
|
|
255
|
-
|
|
256
|
+
|
|
256
257
|
checkConnection: () => {
|
|
257
258
|
return this.__privates.iot.checkConnection()
|
|
258
259
|
.catch(error => {
|
package/src/modules/wt-iot2.js
CHANGED
|
@@ -26,11 +26,13 @@ class Iot {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
initWorker() {
|
|
29
|
+
this.log('iot initWorker');
|
|
29
30
|
this.worker = new Worker();
|
|
30
31
|
this.worker.onmessage = this.handleWorkerMessage.bind(this);
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
terminateWorker() {
|
|
35
|
+
this.log('iot terminateWorker');
|
|
34
36
|
this.worker.terminate();
|
|
35
37
|
}
|
|
36
38
|
|
|
@@ -407,4 +409,4 @@ class Iot {
|
|
|
407
409
|
}
|
|
408
410
|
}
|
|
409
411
|
|
|
410
|
-
export default Iot;
|
|
412
|
+
export default Iot;
|