@reactoo/watchtogether-sdk-js 2.7.65 → 2.7.66

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactoo/watchtogether-sdk-js",
3
- "version": "2.7.65",
3
+ "version": "2.7.66",
4
4
  "description": "Javascript SDK for Reactoo",
5
5
  "main": "dist/watchtogether-sdk.min.js",
6
6
  "module": "dist/watchtogether-sdk.min.js",
package/src/models/iot.js CHANGED
@@ -13,6 +13,11 @@ let iot = function () {
13
13
 
14
14
  __promise: null,
15
15
 
16
+ __createNewWorker: () => {
17
+ this.__privates.iot.terminateWorker();
18
+ this.__privates.iot.initWorker();
19
+ },
20
+
16
21
  __updateCredentials: () => {
17
22
  this.__privates.iot.log('Updating Credentials...');
18
23
  interruptCount = 0;
@@ -65,6 +70,7 @@ let iot = function () {
65
70
  onInterrupt: (data, connectionId) => {
66
71
  if(shouldBeConnected && !isReconnecting && interruptCount > 10) {
67
72
  this.__privates.iot.log('Interrupt count exceeded, reconnecting...');
73
+ this.iot.__createNewWorker();
68
74
  this.iot.__updateCredentials();
69
75
  }
70
76
  interruptCount++;
@@ -79,6 +85,7 @@ let iot = function () {
79
85
  onConnectionFailure: (data, connectionId) => {
80
86
  if(shouldBeConnected && !isReconnecting && interruptCount > 10) {
81
87
  this.__privates.iot.log('Interrupt count exceeded, reconnecting...');
88
+ this.iot.__createNewWorker();
82
89
  this.iot.__updateCredentials();
83
90
  }
84
91
  interruptCount++;
@@ -199,6 +206,7 @@ let iot = function () {
199
206
 
200
207
  if(shouldBeConnected && !isReconnecting && subscriptionFailureCount > 5) {
201
208
  this.__privates.iot.log('Subscription failure exceeded, reconnecting...');
209
+ this.iot.__createNewWorker();
202
210
  this.iot.__updateCredentials();
203
211
  return Promise.reject('subscription_failed');
204
212
  }
@@ -30,6 +30,10 @@ class Iot {
30
30
  this.worker.onmessage = this.handleWorkerMessage.bind(this);
31
31
  }
32
32
 
33
+ terminateWorker() {
34
+ this.worker.terminate();
35
+ }
36
+
33
37
  connect(apiMqttUrl, apiMqttClientId, region, accessKeyId, secretAccessKey, sessionToken, expiration) {
34
38
  this.log('iot connect called, we disconnect first just to be sure');
35
39
  return this.disconnect()