mm_os 2.6.6 → 2.6.7
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/core/com/mqtt/index.js +8 -5
- package/package.json +1 -1
package/core/com/mqtt/index.js
CHANGED
|
@@ -172,9 +172,6 @@ MQTT.prototype.reconnect = function() {
|
|
|
172
172
|
*/
|
|
173
173
|
MQTT.prototype.init = function(config) {
|
|
174
174
|
this.config = Object.assign(this.config, config);
|
|
175
|
-
this.client = {
|
|
176
|
-
connected: false
|
|
177
|
-
};
|
|
178
175
|
this.retryTimes = 0;
|
|
179
176
|
this.connecting = false;
|
|
180
177
|
};
|
|
@@ -196,7 +193,7 @@ MQTT.prototype.start = function() {
|
|
|
196
193
|
} else {
|
|
197
194
|
this.client = MQTT_client.connect(cg);
|
|
198
195
|
}
|
|
199
|
-
if (this.client.on) {
|
|
196
|
+
if (this.client && this.client.on) {
|
|
200
197
|
return new Promise((resolve, reject) => {
|
|
201
198
|
this.client.on('connect', (packet, err) => {
|
|
202
199
|
this.connecting = false;
|
|
@@ -334,7 +331,13 @@ MQTT.prototype.unsubscribe = function(topic, key) {
|
|
|
334
331
|
* 结束客户端
|
|
335
332
|
*/
|
|
336
333
|
MQTT.prototype.end = function() {
|
|
337
|
-
this.client
|
|
334
|
+
if (this.client) {
|
|
335
|
+
this.client.end();
|
|
336
|
+
}
|
|
337
|
+
if (this.timer) {
|
|
338
|
+
clearInterval(this.timer);
|
|
339
|
+
this.timer = null;
|
|
340
|
+
}
|
|
338
341
|
};
|
|
339
342
|
|
|
340
343
|
/**
|