@azteam/express 1.2.501 → 1.2.503

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/lib/Server.js CHANGED
@@ -453,22 +453,33 @@ var Server = /*#__PURE__*/function () {
453
453
  httpServer.on('listening', function () {
454
454
  console.log('listening', "ServerIO start at http://localhost:".concat(httpServer.address().port));
455
455
  });
456
- var listenEventList = [];
457
- var staticEventList = [];
456
+ var listEventListen = [];
458
457
  var msg = [];
459
458
  _lodash["default"].map(socketEvents, function (data) {
460
459
  var event = data.event;
461
460
  var eventName = data.name;
462
461
  var eventVersion = data.version;
463
- var listPublicEvent = event.__getPublicEvents();
464
- _lodash["default"].map(listPublicEvent, function (method) {
462
+ var _event$__getPublicEve = event.__getPublicEvents(),
463
+ lstEvListen = _event$__getPublicEve.listen,
464
+ listEventStatic = _event$__getPublicEve["static"];
465
+ _lodash["default"].map(lstEvListen, function (method) {
465
466
  var name = method.name,
466
467
  type = method.type;
467
- if (type === 'listen') {
468
- listenEventList.push(event[name]);
469
- } else if (type === 'static') {
470
- staticEventList.push(event[name]);
471
- }
468
+ listEventListen.push({
469
+ event: event,
470
+ name: name
471
+ });
472
+ msg.push({
473
+ name: eventName,
474
+ version: eventVersion,
475
+ type: type,
476
+ method: name
477
+ });
478
+ });
479
+ _lodash["default"].map(listEventStatic, function (_ref4) {
480
+ var type = _ref4.type,
481
+ name = _ref4.name;
482
+ event[name](io);
472
483
  msg.push({
473
484
  name: eventName,
474
485
  version: eventVersion,
@@ -478,9 +489,6 @@ var Server = /*#__PURE__*/function () {
478
489
  });
479
490
  });
480
491
  console.table(msg);
481
- _lodash["default"].map(staticEventList, function (event) {
482
- event(io);
483
- });
484
492
  io.on('connection', function (socket) {
485
493
  console.log('connected', socket.id);
486
494
  var interval = (0, _util.setIntervalImmediately)(function () {
@@ -492,8 +500,10 @@ var Server = /*#__PURE__*/function () {
492
500
  console.log('disconnected', socket.id);
493
501
  clearInterval(interval);
494
502
  });
495
- _lodash["default"].map(listenEventList, function (event) {
496
- event(io, socket);
503
+ _lodash["default"].map(listEventListen, function (_ref5) {
504
+ var event = _ref5.event,
505
+ name = _ref5.name;
506
+ event[name](io, socket);
497
507
  });
498
508
  });
499
509
  return io;
@@ -20,7 +20,10 @@ var SocketEvent = /*#__PURE__*/function () {
20
20
  key: "__getPublicEvents",
21
21
  value: function __getPublicEvents() {
22
22
  var child = this;
23
- var result = [];
23
+ var result = {
24
+ listen: [],
25
+ "static": []
26
+ };
24
27
 
25
28
  // eslint-disable-next-line no-proto
26
29
  while (Object.getPrototypeOf(child.__proto__)) {
@@ -28,10 +31,17 @@ var SocketEvent = /*#__PURE__*/function () {
28
31
  data.map(function (methodName) {
29
32
  var matches = methodName.match(/^(listen|static)/);
30
33
  if (matches) {
31
- result.push({
32
- type: matches[0],
33
- name: methodName
34
- });
34
+ if (matches[0] === 'listen') {
35
+ result.listen.push({
36
+ type: matches[0],
37
+ name: methodName
38
+ });
39
+ } else if (matches[0] === 'static') {
40
+ result["static"].push({
41
+ type: matches[0],
42
+ name: methodName
43
+ });
44
+ }
35
45
  }
36
46
  return true;
37
47
  });
@@ -69,9 +79,11 @@ var SocketEvent = /*#__PURE__*/function () {
69
79
  message: err.toString()
70
80
  }));
71
81
  }
72
- callback(SocketEvent.compressJson({
73
- status: 'ok'
74
- }));
82
+ if (typeof callback === 'function') {
83
+ callback(SocketEvent.compressJson({
84
+ status: 'ok'
85
+ }));
86
+ }
75
87
  }
76
88
  }]);
77
89
  return SocketEvent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azteam/express",
3
- "version": "1.2.501",
3
+ "version": "1.2.503",
4
4
  "license": "MIT",
5
5
  "author": "toda <sp.azsolution.net@gmail.com>",
6
6
  "main": "./lib/index.js",
package/src/Server.js CHANGED
@@ -436,23 +436,19 @@ class Server {
436
436
  console.log('listening', `ServerIO start at http://localhost:${httpServer.address().port}`);
437
437
  });
438
438
 
439
- const listenEventList = [];
440
- const staticEventList = [];
439
+ const listEventListen = [];
441
440
  const msg = [];
442
441
 
443
- _.map(socketEvents, (data) => {
442
+ _.map(socketEvents, function (data) {
444
443
  const {event} = data;
445
444
  const eventName = data.name;
446
445
  const eventVersion = data.version;
447
- const listPublicEvent = event.__getPublicEvents();
446
+ const {listen: lstEvListen, static: listEventStatic} = event.__getPublicEvents();
448
447
 
449
- _.map(listPublicEvent, (method) => {
448
+ _.map(lstEvListen, (method) => {
450
449
  const {name, type} = method;
451
- if (type === 'listen') {
452
- listenEventList.push(event[name]);
453
- } else if (type === 'static') {
454
- staticEventList.push(event[name]);
455
- }
450
+ listEventListen.push({event, name});
451
+
456
452
  msg.push({
457
453
  name: eventName,
458
454
  version: eventVersion,
@@ -460,15 +456,21 @@ class Server {
460
456
  method: name,
461
457
  });
462
458
  });
463
- });
464
459
 
465
- console.table(msg);
460
+ _.map(listEventStatic, function ({type, name}) {
461
+ event[name](io);
466
462
 
467
- _.map(staticEventList, (event) => {
468
- event(io);
463
+ msg.push({
464
+ name: eventName,
465
+ version: eventVersion,
466
+ type,
467
+ method: name,
468
+ });
469
+ });
469
470
  });
471
+ console.table(msg);
470
472
 
471
- io.on('connection', (socket) => {
473
+ io.on('connection', function (socket) {
472
474
  console.log('connected', socket.id);
473
475
  const interval = setIntervalImmediately(function () {
474
476
  socket.emit(
@@ -483,8 +485,8 @@ class Server {
483
485
  clearInterval(interval);
484
486
  });
485
487
 
486
- _.map(listenEventList, (event) => {
487
- event(io, socket);
488
+ _.map(listEventListen, ({event, name}) => {
489
+ event[name](io, socket);
488
490
  });
489
491
  });
490
492
 
@@ -3,7 +3,10 @@ import pako from 'pako';
3
3
  class SocketEvent {
4
4
  __getPublicEvents() {
5
5
  let child = this;
6
- const result = [];
6
+ const result = {
7
+ listen: [],
8
+ static: [],
9
+ };
7
10
 
8
11
  // eslint-disable-next-line no-proto
9
12
  while (Object.getPrototypeOf(child.__proto__)) {
@@ -12,10 +15,17 @@ class SocketEvent {
12
15
  data.map(function (methodName) {
13
16
  const matches = methodName.match(/^(listen|static)/);
14
17
  if (matches) {
15
- result.push({
16
- type: matches[0],
17
- name: methodName,
18
- });
18
+ if (matches[0] === 'listen') {
19
+ result.listen.push({
20
+ type: matches[0],
21
+ name: methodName,
22
+ });
23
+ } else if (matches[0] === 'static') {
24
+ result.static.push({
25
+ type: matches[0],
26
+ name: methodName,
27
+ });
28
+ }
19
29
  }
20
30
  return true;
21
31
  });
@@ -56,11 +66,13 @@ class SocketEvent {
56
66
  );
57
67
  }
58
68
 
59
- callback(
60
- SocketEvent.compressJson({
61
- status: 'ok',
62
- })
63
- );
69
+ if (typeof callback === 'function') {
70
+ callback(
71
+ SocketEvent.compressJson({
72
+ status: 'ok',
73
+ })
74
+ );
75
+ }
64
76
  }
65
77
  }
66
78