mm_os 3.2.1 → 3.2.3
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 +10 -6
- package/package.json +1 -1
package/core/com/mqtt/index.js
CHANGED
|
@@ -124,7 +124,8 @@ MQTT.prototype.update_after = async function() {
|
|
|
124
124
|
var _this = this;
|
|
125
125
|
var list = this.list;
|
|
126
126
|
for (var i = 0; i < list.length; i++) {
|
|
127
|
-
|
|
127
|
+
var o = list[i];
|
|
128
|
+
if (o.config && o.config.state === 1) {
|
|
128
129
|
o.send = function(topic, msg, qos = 0, retain = false) {
|
|
129
130
|
if (topic) {
|
|
130
131
|
_this.send(topic, msg, qos, retain);
|
|
@@ -261,18 +262,21 @@ MQTT.prototype.receive = async function(push_topic, msg) {
|
|
|
261
262
|
if (msg && (msg.indexOf('[') === 0) || msg.indexOf('{') === 0) {
|
|
262
263
|
try {
|
|
263
264
|
msg = JSON.parse(msg);
|
|
264
|
-
} catch {
|
|
265
|
+
} catch (error) {
|
|
266
|
+
$.log.error("消息结构体不对", error);
|
|
267
|
+
}
|
|
265
268
|
}
|
|
266
269
|
var ret;
|
|
267
270
|
var list = this.list;
|
|
268
|
-
for (var i = 0
|
|
271
|
+
for (var i = 0; i < list.length; i++) {
|
|
272
|
+
var o = list[i];
|
|
269
273
|
if (o.config.state === 1) {
|
|
270
274
|
var topics = o.config.topic;
|
|
271
275
|
if (topics) {
|
|
272
|
-
for (var
|
|
273
|
-
var topic = topics[
|
|
276
|
+
for (var n = 0; n < topics.length; n++) {
|
|
277
|
+
var topic = topics[n];
|
|
274
278
|
if (this.match(push_topic, topic)) {
|
|
275
|
-
ret = await o.exec('handle', push_topic, msg, topic,
|
|
279
|
+
ret = await o.exec('handle', push_topic, msg, topic, n);
|
|
276
280
|
}
|
|
277
281
|
}
|
|
278
282
|
}
|