@reactoo/watchtogether-sdk-js 2.7.63 → 2.7.65
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
|
@@ -182,23 +182,28 @@ let iot = function () {
|
|
|
182
182
|
if(!__currentTopics.has(topic)) {
|
|
183
183
|
__currentTopics.add(topic);
|
|
184
184
|
if(!this.iot.__promise) return Promise.reject('not_connected');
|
|
185
|
-
// if subscription fails, remove the topic from the current topics
|
|
186
185
|
return this.iot.__promise
|
|
187
186
|
.then(() => this.__privates.iot.subscribe(topic))
|
|
188
187
|
.catch((error) => {
|
|
189
188
|
|
|
189
|
+
// if subscription fails, remove the topic from the current topics
|
|
190
|
+
__currentTopics.delete(topic);
|
|
191
|
+
|
|
190
192
|
if(error?.cause === -1) {
|
|
191
|
-
__currentTopics.delete(topic);
|
|
192
193
|
return Promise.reject('invalid_topic');
|
|
193
194
|
}
|
|
194
195
|
|
|
196
|
+
if(!shouldBeConnected || isReconnecting) {
|
|
197
|
+
return Promise.reject('subscription_failed');
|
|
198
|
+
}
|
|
199
|
+
|
|
195
200
|
if(shouldBeConnected && !isReconnecting && subscriptionFailureCount > 5) {
|
|
196
201
|
this.__privates.iot.log('Subscription failure exceeded, reconnecting...');
|
|
197
202
|
this.iot.__updateCredentials();
|
|
198
203
|
return Promise.reject('subscription_failed');
|
|
199
204
|
}
|
|
200
|
-
subscriptionFailureCount++;
|
|
201
205
|
|
|
206
|
+
subscriptionFailureCount++;
|
|
202
207
|
return this.subscribe(topic)
|
|
203
208
|
});
|
|
204
209
|
}
|
|
@@ -207,10 +212,10 @@ let iot = function () {
|
|
|
207
212
|
unsubscribe: (topic) => {
|
|
208
213
|
__currentTopics.delete(topic);
|
|
209
214
|
if(!this.iot.__promise) return Promise.reject('not_connected');
|
|
210
|
-
// if unsubscription fails add the topic back to the current topics
|
|
211
215
|
return this.iot.__promise
|
|
212
216
|
.then(() => this.__privates.iot.unsubscribe(topic))
|
|
213
217
|
.catch(() => {
|
|
218
|
+
// if unsubscription fails add the topic back to the current topics
|
|
214
219
|
__currentTopics.add(topic);
|
|
215
220
|
return Promise.reject('unsubscription_failed');
|
|
216
221
|
});
|