mm_os 2.5.2 → 2.5.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/eventer/com.js +10 -10
- package/core/com/mqtt/drive.js +12 -0
- package/core/com/mqtt/index.js +3 -3
- package/demo/com/server/index.js +2 -2
- package/demo/config/development.json +1 -2
- package/package.json +3 -3
- package/static/file/image/user/1869/2024_12_07_08_55_53.png +0 -0
- package/static/file/image/user/1890/2024_12_07_08_56_09.png +0 -0
package/core/com/eventer/com.js
CHANGED
|
@@ -143,11 +143,11 @@ Eventer.prototype.do_after = function() {
|
|
|
143
143
|
/**
|
|
144
144
|
* 执行事件
|
|
145
145
|
*/
|
|
146
|
-
Eventer.prototype.doing = async function(o, msg) {
|
|
146
|
+
Eventer.prototype.doing = async function(o, ...msg) {
|
|
147
147
|
o.num++;
|
|
148
148
|
var ret;
|
|
149
149
|
try {
|
|
150
|
-
ret = o.func(msg, o.param, o.num);
|
|
150
|
+
ret = o.func(...msg, o.param, o.num);
|
|
151
151
|
if (types.isPromise(ret)) {
|
|
152
152
|
ret = await ret;
|
|
153
153
|
}
|
|
@@ -167,10 +167,10 @@ Eventer.prototype.doing = async function(o, msg) {
|
|
|
167
167
|
* 运行事件
|
|
168
168
|
* @param {Array} list 列表
|
|
169
169
|
* @param {String} type 类型
|
|
170
|
-
* @param {Object} msg 事件消息
|
|
171
170
|
* @param {Boolean} isBreak 是否中断
|
|
171
|
+
* @param {Object} msg 事件消息
|
|
172
172
|
*/
|
|
173
|
-
Eventer.prototype.run_sub = async function(list,
|
|
173
|
+
Eventer.prototype.run_sub = async function(list, isBreak, ...msg) {
|
|
174
174
|
var ret;
|
|
175
175
|
if (list) {
|
|
176
176
|
for (var i = 0; i < list.length; i++) {
|
|
@@ -179,7 +179,7 @@ Eventer.prototype.run_sub = async function(list, msg, isBreak = false) {
|
|
|
179
179
|
if (o.state == 1) {
|
|
180
180
|
// 判断是否还需要执行
|
|
181
181
|
if (o.count < 0 || o.num < o.count) {
|
|
182
|
-
ret = await this.doing(o, msg);
|
|
182
|
+
ret = await this.doing(o, ...msg);
|
|
183
183
|
if (ret && isBreak) {
|
|
184
184
|
break;
|
|
185
185
|
}
|
|
@@ -201,19 +201,19 @@ Eventer.prototype.run_sub = async function(list, msg, isBreak = false) {
|
|
|
201
201
|
* @param {String} type 类型
|
|
202
202
|
* @param {Object} msg 事件消息
|
|
203
203
|
*/
|
|
204
|
-
Eventer.prototype.run = async function(type, msg) {
|
|
204
|
+
Eventer.prototype.run = async function(type, ...msg) {
|
|
205
205
|
this.do_before();
|
|
206
206
|
var ret;
|
|
207
207
|
var dt = this.dict[type];
|
|
208
208
|
if (dt) {
|
|
209
|
-
ret = await this.run_sub(dt.before,
|
|
210
|
-
ret = await this.run_sub(dt.check,
|
|
209
|
+
ret = await this.run_sub(dt.before, false, ...msg);
|
|
210
|
+
ret = await this.run_sub(dt.check, true, ...msg);
|
|
211
211
|
if (ret) {
|
|
212
212
|
return ret
|
|
213
213
|
}
|
|
214
|
-
ret = await this.run_sub(dt.main,
|
|
214
|
+
ret = await this.run_sub(dt.main, false, ...msg);
|
|
215
215
|
if (ret) {
|
|
216
|
-
var ret_new = await this.run_sub(dt.after,
|
|
216
|
+
var ret_new = await this.run_sub(dt.after, false, ...msg);
|
|
217
217
|
ret = ret_new || ret;
|
|
218
218
|
}
|
|
219
219
|
}
|
package/core/com/mqtt/drive.js
CHANGED
|
@@ -305,6 +305,18 @@ Drive.prototype.pushS = function(clientid, msg, longtime) {
|
|
|
305
305
|
});
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
+
/**
|
|
309
|
+
*
|
|
310
|
+
* @param {Object} clientid
|
|
311
|
+
* @param {Object} online
|
|
312
|
+
* @param {Object} ip
|
|
313
|
+
*/
|
|
314
|
+
Drive.prototype.save_online = async function(clientid, online, ip) {
|
|
315
|
+
if (!clientid) {
|
|
316
|
+
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
308
320
|
/**
|
|
309
321
|
* 更新设备在线
|
|
310
322
|
* @param {String} clientid 客户端ID
|
package/core/com/mqtt/index.js
CHANGED
|
@@ -454,9 +454,7 @@ MQTT.prototype.update_online = async function() {
|
|
|
454
454
|
var dict = list[i].drives;
|
|
455
455
|
for (var clientid in dict) {
|
|
456
456
|
var o = dict[clientid];
|
|
457
|
-
if (o.online ===
|
|
458
|
-
list_offline.push(clientid);
|
|
459
|
-
} else {
|
|
457
|
+
if (o.online === 1) {
|
|
460
458
|
if (o.time_last) {
|
|
461
459
|
var cha = now - o.time_last;
|
|
462
460
|
if (cha > online_expires) {
|
|
@@ -469,6 +467,8 @@ MQTT.prototype.update_online = async function() {
|
|
|
469
467
|
} else {
|
|
470
468
|
list_online.push(clientid);
|
|
471
469
|
}
|
|
470
|
+
} else {
|
|
471
|
+
list_offline.push(clientid);
|
|
472
472
|
}
|
|
473
473
|
}
|
|
474
474
|
}
|
package/demo/com/server/index.js
CHANGED
|
@@ -203,8 +203,8 @@ Server.prototype.exec_log = async function(clientid, log) {
|
|
|
203
203
|
*/
|
|
204
204
|
Server.prototype.check_device = async function(clientid, key) {
|
|
205
205
|
var tip;
|
|
206
|
-
var
|
|
207
|
-
var device = await
|
|
206
|
+
var db_device = dbs.new("face_device", "device_id");
|
|
207
|
+
var device = await db_device.getObj({
|
|
208
208
|
clientid
|
|
209
209
|
});
|
|
210
210
|
if (device) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mm_os",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.4",
|
|
4
4
|
"description": "这是超级美眉服务端框架,用于快速构建应用程序。",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
"koa-websocket": "^7.0.0",
|
|
38
38
|
"mm_check": "^1.4.8",
|
|
39
39
|
"mm_excel": "^1.2.0",
|
|
40
|
-
"mm_expand": "^1.7.
|
|
40
|
+
"mm_expand": "^1.7.4",
|
|
41
41
|
"mm_html": "^1.1.6",
|
|
42
42
|
"mm_koa_proxy": "^1.0.0",
|
|
43
43
|
"mm_logs": "^1.1.4",
|
|
44
44
|
"mm_machine": "^1.7.8",
|
|
45
45
|
"mm_mongodb": "^1.4.2",
|
|
46
46
|
"mm_mqtt": "^1.0.6",
|
|
47
|
-
"mm_mysql": "^1.8.
|
|
47
|
+
"mm_mysql": "^1.8.3",
|
|
48
48
|
"mm_redis": "^1.4.2",
|
|
49
49
|
"mm_ret": "^1.3.9",
|
|
50
50
|
"mm_session": "^1.4.8",
|
|
Binary file
|
|
Binary file
|