mm_os 2.2.2 → 2.2.4
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
CHANGED
|
@@ -83,6 +83,14 @@ class MQTT extends Index {
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
/**
|
|
87
|
+
* 设置配置
|
|
88
|
+
* @param {Object} config 配置
|
|
89
|
+
*/
|
|
90
|
+
MQTT.prototype.set_config = function(config) {
|
|
91
|
+
Object.assign(this.config, config);
|
|
92
|
+
}
|
|
93
|
+
|
|
86
94
|
/**
|
|
87
95
|
* 主题匹配
|
|
88
96
|
* @param {String} topic 接收到的主题
|
|
@@ -138,11 +146,11 @@ MQTT.prototype.update_after = function() {
|
|
|
138
146
|
* 重新连接
|
|
139
147
|
*/
|
|
140
148
|
MQTT.prototype.reconnect = function() {
|
|
149
|
+
$.sleep(this.config.interval);
|
|
141
150
|
this.retryTimes += 1;
|
|
142
151
|
if (this.retryTimes > 5) {
|
|
143
152
|
try {
|
|
144
153
|
this.client.end();
|
|
145
|
-
$.sleep(this.config.interval);
|
|
146
154
|
this.init();
|
|
147
155
|
} catch (error) {
|
|
148
156
|
this.$message.error(error.toString());
|
|
@@ -193,7 +201,9 @@ MQTT.prototype.start = function() {
|
|
|
193
201
|
resolve(packet);
|
|
194
202
|
}
|
|
195
203
|
});
|
|
196
|
-
this.client.on("reconnect",
|
|
204
|
+
this.client.on("reconnect", () => {
|
|
205
|
+
this.reconnect();
|
|
206
|
+
});
|
|
197
207
|
this.client.on("error", (error) => {
|
|
198
208
|
console.error("Connection failed", error);
|
|
199
209
|
});
|
package/demo/config/local.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mm_os",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.4",
|
|
4
4
|
"description": "这是超级美眉服务端框架,用于快速构建应用程序。",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"koa-compress": "^5.1.1",
|
|
36
36
|
"koa-send": "^5.0.1",
|
|
37
37
|
"koa-websocket": "^7.0.0",
|
|
38
|
-
"mm_check": "^1.4.
|
|
38
|
+
"mm_check": "^1.4.8",
|
|
39
39
|
"mm_excel": "^1.2.0",
|
|
40
|
-
"mm_expand": "^1.7.
|
|
40
|
+
"mm_expand": "^1.7.2",
|
|
41
41
|
"mm_html": "^1.1.6",
|
|
42
42
|
"mm_koa_proxy": "^1.0.0",
|
|
43
43
|
"mm_logs": "^1.1.4",
|
|
44
|
-
"mm_machine": "^1.7.
|
|
44
|
+
"mm_machine": "^1.7.3",
|
|
45
45
|
"mm_mongodb": "^1.4.2",
|
|
46
46
|
"mm_mqtt": "^1.0.6",
|
|
47
47
|
"mm_mysql": "^1.8.0",
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"mm_tpl": "^2.3.9",
|
|
53
53
|
"mm_xml": "^1.1.5",
|
|
54
54
|
"mosca": "^2.8.3",
|
|
55
|
-
"mqtt": "^5.10.
|
|
55
|
+
"mqtt": "^5.10.2",
|
|
56
|
+
"publish": "^0.6.0"
|
|
56
57
|
}
|
|
57
58
|
}
|