mm_os 3.0.3 → 3.0.5

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.
@@ -155,7 +155,7 @@ Drive.prototype.restart = async function(option) {
155
155
  Drive.prototype.init_before = async function(option) {
156
156
  this.plugin = $.plugin_admin(this.config.name, this.config.title);
157
157
  await this.plugin.update();
158
- await this.plugin.exec(null, 'init');
158
+ this.plugin.exec(null, 'init');
159
159
  }
160
160
 
161
161
  /**
@@ -209,9 +209,7 @@ Drive.prototype.start_after = async function(opiton) {
209
209
  for (var i = 0; i < list.length; i++) {
210
210
  var o = list[i];
211
211
  if (o.config.state) {
212
- await o.run('start');
213
- // 等待0.5秒
214
- await $.sleep(500);
212
+ o.exec('start');
215
213
  }
216
214
  }
217
215
  return msg;
@@ -43,11 +43,10 @@ class MQTT extends Index {
43
43
  online_expires: 150000,
44
44
  // 在线有效期检测间隔
45
45
  online_interval: 10000,
46
- // 连接超时
47
- connectTimeout: 6000,
46
+ // 连接超时
47
+ connectTimeout: 30000,
48
48
  // maxInflight: 20,
49
49
  // 重连间隔
50
- // interval: 6000,
51
50
  reconnectPeriod: 6000 // 重连间隔1秒
52
51
  }
53
52
  // 定时器
@@ -24,8 +24,10 @@ class MM_mqtt {
24
24
  topic_receive: "client/message/",
25
25
  longtime: 15000,
26
26
  // maxInflight: 20,
27
- // 重连间隔
28
- interval: 6000
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
- $.sleep(this.config.interval);
83
- this.init();
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_os",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "description": "这是超级美眉服务端框架,用于快速构建应用程序。",
5
5
  "main": "index.js",
6
6
  "scripts": {