mm_os 3.0.2 → 3.0.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/app/drive.js +0 -2
- package/core/com/mqtt/index.js +2 -3
- package/core/com/mqtt/mm_mqtt.js +8 -5
- package/index.js +9 -7
- package/package.json +1 -1
package/core/com/app/drive.js
CHANGED
package/core/com/mqtt/index.js
CHANGED
|
@@ -43,11 +43,10 @@ class MQTT extends Index {
|
|
|
43
43
|
online_expires: 150000,
|
|
44
44
|
// 在线有效期检测间隔
|
|
45
45
|
online_interval: 10000,
|
|
46
|
-
// 连接超时
|
|
47
|
-
connectTimeout:
|
|
46
|
+
// 连接超时
|
|
47
|
+
connectTimeout: 30000,
|
|
48
48
|
// maxInflight: 20,
|
|
49
49
|
// 重连间隔
|
|
50
|
-
// interval: 6000,
|
|
51
50
|
reconnectPeriod: 6000 // 重连间隔1秒
|
|
52
51
|
}
|
|
53
52
|
// 定时器
|
package/core/com/mqtt/mm_mqtt.js
CHANGED
|
@@ -24,8 +24,10 @@ class MM_mqtt {
|
|
|
24
24
|
topic_receive: "client/message/",
|
|
25
25
|
longtime: 15000,
|
|
26
26
|
// maxInflight: 20,
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
// 重连间隔时间,单位为毫秒, 默认6秒
|
|
28
|
+
reconnectPeriod: 6000,
|
|
29
|
+
// 连接超时时间,单位为毫秒, 默认30秒, 即尝试连接5次
|
|
30
|
+
connectTimeout: 30000
|
|
29
31
|
}, config);
|
|
30
32
|
|
|
31
33
|
// mqtt客户端服务器
|
|
@@ -79,8 +81,9 @@ MM_mqtt.prototype.reconnect = function() {
|
|
|
79
81
|
if (this.retryTimes > 5) {
|
|
80
82
|
try {
|
|
81
83
|
this.client.end();
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
setTimeout(() => {
|
|
85
|
+
this.init();
|
|
86
|
+
}, this.config.reconnectPeriod);
|
|
84
87
|
} catch (error) {
|
|
85
88
|
this.$message.error(error.toString());
|
|
86
89
|
}
|
|
@@ -123,7 +126,7 @@ MM_mqtt.prototype.run = function(config) {
|
|
|
123
126
|
resolve(null);
|
|
124
127
|
reject(err);
|
|
125
128
|
} else {
|
|
126
|
-
this.client.on('message', async(topic, message) => {
|
|
129
|
+
this.client.on('message', async (topic, message) => {
|
|
127
130
|
await this.receive(topic, message.toString());
|
|
128
131
|
});
|
|
129
132
|
resolve(packet);
|
package/index.js
CHANGED
|
@@ -90,9 +90,9 @@ OS.prototype.initData = function(config) {
|
|
|
90
90
|
} else if (p.substring(p.length - 1) !== $.slash) {
|
|
91
91
|
config.runPath += $.slash;
|
|
92
92
|
}
|
|
93
|
-
|
|
93
|
+
|
|
94
94
|
$.runPath = config.runPath;
|
|
95
|
-
|
|
95
|
+
|
|
96
96
|
// 初始化公共函数
|
|
97
97
|
$.func = {};
|
|
98
98
|
|
|
@@ -151,9 +151,6 @@ OS.prototype.loadModule = function(cg) {
|
|
|
151
151
|
$.sql = $.mysql_admin('sys', $.runPath);
|
|
152
152
|
if (cg.mysql) {
|
|
153
153
|
$.sql.setConfig(cg.mysql);
|
|
154
|
-
if (cg.mysql.state) {
|
|
155
|
-
$.sql.open();
|
|
156
|
-
}
|
|
157
154
|
}
|
|
158
155
|
|
|
159
156
|
if (!cg.sys.hot_reload) {
|
|
@@ -201,8 +198,6 @@ OS.prototype.initBase = function(cg) {
|
|
|
201
198
|
this.mqtt = mqtt;
|
|
202
199
|
}
|
|
203
200
|
|
|
204
|
-
// 启动计时器
|
|
205
|
-
$.timer.run();
|
|
206
201
|
}
|
|
207
202
|
|
|
208
203
|
/**
|
|
@@ -210,6 +205,9 @@ OS.prototype.initBase = function(cg) {
|
|
|
210
205
|
* @param {String} state 状态
|
|
211
206
|
*/
|
|
212
207
|
OS.prototype.main = async function(state) {
|
|
208
|
+
// 启动计时器
|
|
209
|
+
$.timer.run();
|
|
210
|
+
|
|
213
211
|
var cg = this.config;
|
|
214
212
|
var web_server = this.web_server;
|
|
215
213
|
var mqtt_server = this.mqtt_server;
|
|
@@ -243,6 +241,10 @@ OS.prototype.main = async function(state) {
|
|
|
243
241
|
* @param {String} state 状态
|
|
244
242
|
*/
|
|
245
243
|
OS.prototype.before = async function(state) {
|
|
244
|
+
var mysql = this.config.mysql;
|
|
245
|
+
if (mysql && mysql.state) {
|
|
246
|
+
await $.sql.open();
|
|
247
|
+
}
|
|
246
248
|
this.app = $.app_admin('sys');
|
|
247
249
|
await this.app.update();
|
|
248
250
|
await this.app.exec(null, 'init');
|