podasync-ws-only 2.7.5 → 2.7.9-snapshot.0

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/README.md CHANGED
@@ -1,111 +1,111 @@
1
- ## Synopsis
2
-
3
- **Fanap's POD** Async service (DIRANA) - Websocket Only
4
-
5
- ## Code Example
6
-
7
- First you have to require PodAsync in your project.
8
-
9
- ```javascript
10
- var Async = require('podasync');
11
- ```
12
-
13
- To be able to connect to async server, you should set some parameters. `Websockets`protocol is currently supported.
14
-
15
- ### Websocket protocol parameters
16
-
17
- ```javascript
18
- var params = {
19
- socketAddress: "ws://chat-sandbox.pod.land/ws",
20
- serverName: "chat-server",
21
- reconnectOnClose: true,
22
- connectionCheckTimeout: 10000,
23
- asyncLogging: {
24
- onFunction: true,
25
- onMessageReceive: true,
26
- onMessageSend: true
27
- }
28
- };
29
- ```
30
-
31
- After setting parameters you can make a new connection to Async server.
32
-
33
- ```javascript
34
- var asyncClient = new Async(params);
35
- ```
36
-
37
- ### Async Ready Event
38
-
39
- After making a new connection, you should wait for asyncReady event to fire so you could be sure that the connection has been estabilished and you are ready to go
40
-
41
- ```javascript
42
- asyncClient.on("asyncReady", function() {
43
- /**
44
- * Write your code inside asyncReady() function
45
- */
46
- });
47
- ```
48
-
49
- ### Receive messages
50
-
51
- In order to receive messages from Async server, you could listen to `message` event.
52
-
53
- ```javascript
54
- /**
55
- * Listening to responses came from DIRANA
56
- */
57
- asyncClient.on("message", function(message, ack) {
58
- console.log(message);
59
- });
60
- ```
61
-
62
- ### Send message
63
-
64
- To send a new message to Async server you can use `send()` function.
65
-
66
- ```javascript
67
- /**
68
- * A Custom Message To be Send Through DIRANA
69
- */
70
- var customMessage = {
71
- type: 3,
72
- content: {
73
- receivers: ["receiver1", "receiver2", "..."],
74
- content: "Hello Buddy!"
75
- }
76
- };
77
-
78
- /**
79
- * Sending Message
80
- */
81
- asyncClient.send(customMessage);
82
- ```
83
-
84
- ## Motivation
85
-
86
- This module helps you to easily connect POD chat service.
87
-
88
- ## Installation
89
-
90
- ```javascript
91
- npm install podasync --save
92
- ```
93
-
94
- ## API Reference
95
-
96
- [API Docs from POD](http://www.fanapium.com)
97
-
98
- ## Tests
99
-
100
- ```javascript
101
- npm test
102
- ```
103
-
104
- ## Contributors
105
-
106
- You can send me your thoughts about making this repo great :)
107
- [Email](masoudmanson@gmail.com)
108
-
109
- ## License
110
-
111
- Under MIT License.
1
+ ## Synopsis
2
+
3
+ **Fanap's POD** Async service (DIRANA) - Websocket Only
4
+
5
+ ## Code Example
6
+
7
+ First you have to require PodAsync in your project.
8
+
9
+ ```javascript
10
+ var Async = require('podasync-ws-only');
11
+ ```
12
+
13
+ To be able to connect to async server, you should set some parameters. `Websockets`protocol is currently supported.
14
+
15
+ ### Websocket protocol parameters
16
+
17
+ ```javascript
18
+ var params = {
19
+ socketAddress: "ws://chat-sandbox.pod.land/ws",
20
+ serverName: "chat-server",
21
+ reconnectOnClose: true,
22
+ connectionCheckTimeout: 10000,
23
+ asyncLogging: {
24
+ onFunction: true,
25
+ onMessageReceive: true,
26
+ onMessageSend: true
27
+ }
28
+ };
29
+ ```
30
+
31
+ After setting parameters you can make a new connection to Async server.
32
+
33
+ ```javascript
34
+ var asyncClient = new Async(params);
35
+ ```
36
+
37
+ ### Async Ready Event
38
+
39
+ After making a new connection, you should wait for asyncReady event to fire so you could be sure that the connection has been estabilished and you are ready to go
40
+
41
+ ```javascript
42
+ asyncClient.on("asyncReady", function() {
43
+ /**
44
+ * Write your code inside asyncReady() function
45
+ */
46
+ });
47
+ ```
48
+
49
+ ### Receive messages
50
+
51
+ In order to receive messages from Async server, you could listen to `message` event.
52
+
53
+ ```javascript
54
+ /**
55
+ * Listening to responses came from DIRANA
56
+ */
57
+ asyncClient.on("message", function(message, ack) {
58
+ console.log(message);
59
+ });
60
+ ```
61
+
62
+ ### Send message
63
+
64
+ To send a new message to Async server you can use `send()` function.
65
+
66
+ ```javascript
67
+ /**
68
+ * A Custom Message To be Send Through DIRANA
69
+ */
70
+ var customMessage = {
71
+ type: 3,
72
+ content: {
73
+ receivers: ["receiver1", "receiver2", "..."],
74
+ content: "Hello Buddy!"
75
+ }
76
+ };
77
+
78
+ /**
79
+ * Sending Message
80
+ */
81
+ asyncClient.send(customMessage);
82
+ ```
83
+
84
+ ## Motivation
85
+
86
+ This module helps you to easily connect POD chat service.
87
+
88
+ ## Installation
89
+
90
+ ```javascript
91
+ npm install podasync --save
92
+ ```
93
+
94
+ ## API Reference
95
+
96
+ [API Docs from POD](http://www.fanapium.com)
97
+
98
+ ## Tests
99
+
100
+ ```javascript
101
+ npm test
102
+ ```
103
+
104
+ ## Contributors
105
+
106
+ You can send me your thoughts about making this repo great :)
107
+ [Email](masoudmanson@gmail.com)
108
+
109
+ ## License
110
+
111
+ Under MIT License.
package/package.json CHANGED
@@ -1,42 +1,46 @@
1
- {
2
- "name": "podasync-ws-only",
3
- "version": "2.7.5",
4
- "description": "Fanap's POD Async service (DIRANA) - Websocket only",
5
- "main": "./src/network/async.js",
6
- "scripts": {
7
- "test": "mocha --reporter spec --exit"
8
- },
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/masoudmanson/pod-async-ws-only.git"
12
- },
13
- "keywords": [
14
- "Fanap",
15
- "POD",
16
- "Async",
17
- "Socket",
18
- "DIRANA",
19
- "WS",
20
- "Websocket"
21
- ],
22
- "engines": {
23
- "node": ">=4.2.4"
24
- },
25
- "author": "Masoud Amjadi <masoudmanson@gmail.com>",
26
- "license": "MIT",
27
- "bugs": {
28
- "url": "https://github.com/masoudmanson/pod-async-ws-only/issues"
29
- },
30
- "homepage": "https://github.com/masoudmanson/pod-async-ws-only#readme",
31
- "dependencies": {
32
- "isomorphic-ws": "^4.0.1",
33
- "ws": "^4.1.0"
34
- },
35
- "devDependencies": {
36
- "mocha": "^5.2.0"
37
- },
38
- "directories": {
39
- "example": "examples",
40
- "test": "test"
41
- }
42
- }
1
+ {
2
+ "name": "podasync-ws-only",
3
+ "version": "2.7.9-snapshot.0",
4
+ "description": "Fanap's POD Async service (DIRANA) - Websocket only",
5
+ "main": "./src/network/async.js",
6
+ "scripts": {
7
+ "test": "mocha --reporter spec --exit",
8
+ "publish:snapshot": "npm run version:snapshot && npm publish --tag snapshot",
9
+ "version:snapshot": "npm version prerelease --preid snapshot",
10
+ "publish:release": "npm run version:release && npm publish",
11
+ "version:release": "npm version 2.7.8"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/FanapSoft/pod-async-ws-only-js-sdk.git"
16
+ },
17
+ "keywords": [
18
+ "Fanap",
19
+ "POD",
20
+ "Async",
21
+ "Socket",
22
+ "DIRANA",
23
+ "WS",
24
+ "Websocket"
25
+ ],
26
+ "engines": {
27
+ "node": ">=4.2.4"
28
+ },
29
+ "author": "Masoud Amjadi <masoudmanson@gmail.com>",
30
+ "license": "MIT",
31
+ "bugs": {
32
+ "url": "https://github.com/FanapSoft/pod-async-ws-only-js-sdk/issues"
33
+ },
34
+ "homepage": "https://github.com/FanapSoft/pod-async-ws-only-js-sdk#readme",
35
+ "dependencies": {
36
+ "isomorphic-ws": "^4.0.1",
37
+ "ws": "^4.1.0"
38
+ },
39
+ "devDependencies": {
40
+ "mocha": "^5.2.0"
41
+ },
42
+ "directories": {
43
+ "example": "examples",
44
+ "test": "test"
45
+ }
46
+ }
package/podasync.js CHANGED
@@ -1,28 +1,28 @@
1
- (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
1
+ (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
2
2
  window.PodAsync = require('./src/network/async.js')
3
-
4
- },{"./src/network/async.js":3}],2:[function(require,module,exports){
5
- (function (global){
6
- // https://github.com/maxogden/websocket-stream/blob/48dc3ddf943e5ada668c31ccd94e9186f02fafbd/ws-fallback.js
7
-
8
- var ws = null
9
-
10
- if (typeof WebSocket !== 'undefined') {
11
- ws = WebSocket
12
- } else if (typeof MozWebSocket !== 'undefined') {
13
- ws = MozWebSocket
14
- } else if (typeof global !== 'undefined') {
15
- ws = global.WebSocket || global.MozWebSocket
16
- } else if (typeof window !== 'undefined') {
17
- ws = window.WebSocket || window.MozWebSocket
18
- } else if (typeof self !== 'undefined') {
19
- ws = self.WebSocket || self.MozWebSocket
20
- }
21
-
22
- module.exports = ws
23
-
24
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
25
- },{}],3:[function(require,module,exports){
3
+
4
+ },{"./src/network/async.js":3}],2:[function(require,module,exports){
5
+ (function (global){
6
+ // https://github.com/maxogden/websocket-stream/blob/48dc3ddf943e5ada668c31ccd94e9186f02fafbd/ws-fallback.js
7
+
8
+ var ws = null
9
+
10
+ if (typeof WebSocket !== 'undefined') {
11
+ ws = WebSocket
12
+ } else if (typeof MozWebSocket !== 'undefined') {
13
+ ws = MozWebSocket
14
+ } else if (typeof global !== 'undefined') {
15
+ ws = global.WebSocket || global.MozWebSocket
16
+ } else if (typeof window !== 'undefined') {
17
+ ws = window.WebSocket || window.MozWebSocket
18
+ } else if (typeof self !== 'undefined') {
19
+ ws = self.WebSocket || self.MozWebSocket
20
+ }
21
+
22
+ module.exports = ws
23
+
24
+ }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
25
+ },{}],3:[function(require,module,exports){
26
26
  (function () {
27
27
  /*
28
28
  * Async module to handle async messaging
@@ -734,8 +734,8 @@ module.exports = ws
734
734
  window.POD.Async = Async;
735
735
  }
736
736
  })();
737
-
738
- },{"../utility/utility.js":5,"./socket.js":4}],4:[function(require,module,exports){
737
+
738
+ },{"../utility/utility.js":5,"./socket.js":4}],4:[function(require,module,exports){
739
739
  (function() {
740
740
  /*
741
741
  * Socket Module to connect and handle Socket functionalities
@@ -955,9 +955,9 @@ module.exports = ws
955
955
  }
956
956
 
957
957
  })();
958
-
959
- },{"isomorphic-ws":2}],5:[function(require,module,exports){
960
- (function (global){
958
+
959
+ },{"isomorphic-ws":2}],5:[function(require,module,exports){
960
+ (function (global){
961
961
  (function() {
962
962
  /**
963
963
  * General Utilities
@@ -1273,6 +1273,6 @@ module.exports = ws
1273
1273
  window.POD.AsyncUtility = Utility;
1274
1274
  }
1275
1275
  })();
1276
-
1277
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
1278
- },{}]},{},[1]);
1276
+
1277
+ }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
1278
+ },{}]},{},[1]);
@@ -13,15 +13,17 @@
13
13
  *******************************************************/
14
14
 
15
15
  var PodSocketClass,
16
- PodUtility;
17
-
16
+ PodUtility,
17
+ LogLevel
18
18
  if (typeof(require) !== 'undefined' && typeof(exports) !== 'undefined') {
19
19
  PodSocketClass = require('./socket.js');
20
20
  PodUtility = require('../utility/utility.js');
21
+ LogLevel = require('../utility/logger.js');
21
22
  }
22
23
  else {
23
24
  PodSocketClass = POD.Socket;
24
25
  PodUtility = POD.AsyncUtility;
26
+ LogLevel = POD.LogLevel;
25
27
  }
26
28
 
27
29
  var Utility = new PodUtility();
@@ -60,6 +62,7 @@
60
62
  CLOSING: 2, // The connection is in the process of closing.
61
63
  CLOSED: 3 // The connection is closed or couldn't be opened.
62
64
  },
65
+ logLevel = LogLevel(params.logLevel),
63
66
  isNode = Utility.isNode(),
64
67
  isSocketOpen = false,
65
68
  isDeviceRegister = false,
@@ -122,7 +125,8 @@
122
125
  socketAddress: params.socketAddress,
123
126
  wsConnectionWaitTime: params.wsConnectionWaitTime,
124
127
  connectionCheckTimeout: params.connectionCheckTimeout,
125
- connectionCheckTimeoutThreshold: params.connectionCheckTimeoutThreshold
128
+ connectionCheckTimeoutThreshold: params.connectionCheckTimeoutThreshold,
129
+ logLevel: logLevel
126
130
  });
127
131
 
128
132
  checkIfSocketHasOpennedTimeoutId = setTimeout(function () {
@@ -356,9 +360,12 @@
356
360
 
357
361
  if (peerId !== undefined) {
358
362
  content.refresh = true;
363
+ content.renew = false;
364
+
359
365
  }
360
366
  else {
361
367
  content.renew = true;
368
+ content.refresh = false;
362
369
  }
363
370
 
364
371
  pushSendData({
@@ -527,7 +534,7 @@
527
534
  },
528
535
 
529
536
  fireEvent = function (eventName, param, ack) {
530
- try {
537
+ // try {
531
538
  if (ack) {
532
539
  for (var id in eventCallbacks[eventName]) {
533
540
  eventCallbacks[eventName][id](param, ack);
@@ -538,14 +545,14 @@
538
545
  eventCallbacks[eventName][id](param);
539
546
  }
540
547
  }
541
- }
542
- catch (e) {
543
- fireEvent('error', {
544
- errorCode: 999,
545
- errorMessage: 'Unknown ERROR!',
546
- errorEvent: e
547
- });
548
- }
548
+ // }
549
+ // catch (e) {
550
+ // fireEvent('error', {
551
+ // errorCode: 999,
552
+ // errorMessage: 'Unknown ERROR!',
553
+ // errorEvent: e
554
+ // });
555
+ // }
549
556
  };
550
557
 
551
558
  /*******************************************************
@@ -22,12 +22,45 @@
22
22
  eventCallback = {},
23
23
  socket,
24
24
  waitForSocketToConnectTimeoutId,
25
- forceCloseSocket = false,
26
- forceCloseSocketTimeout,
27
25
  socketRealTimeStatusInterval,
28
- sendPingTimeout,
26
+ //sendPingTimeout,
29
27
  socketCloseTimeout,
30
- forceCloseTimeout;
28
+ forceCloseTimeout,
29
+ logLevel = params.logLevel,
30
+ pingController = new PingManager({waitTime: connectionCheckTimeout});
31
+
32
+
33
+ function PingManager(params) {
34
+ const config = {
35
+ normalWaitTime: params.waitTime,
36
+
37
+ lastRequestTimeoutId: null,
38
+ lastReceivedMessageTime: 0,
39
+ }
40
+
41
+ return {
42
+ setPingTimeout() {
43
+ config.lastRequestTimeoutId = setInterval(()=>{
44
+ ping();
45
+ //this.watchForPingResponse();
46
+ }, config.normalWaitTime)
47
+ },
48
+ resetPingLoop() {
49
+ this.updateLastReceivedMessageTime();
50
+ this.stopPingLoop();
51
+ this.setPingTimeout();
52
+ // this.retries = 0;
53
+ },
54
+ stopPingLoop(){
55
+ // config.retries = 0;
56
+ clearInterval(config.lastRequestTimeoutId);
57
+ // clearTimeout(config.responseTimeoutId)
58
+ },
59
+ updateLastReceivedMessageTime() {
60
+ config.lastReceivedMessageTime = new Date().getTime();
61
+ },
62
+ }
63
+ }
31
64
 
32
65
  /*******************************************************
33
66
  * P R I V A T E M E T H O D S *
@@ -59,59 +92,26 @@
59
92
 
60
93
  socket.onopen = function(event) {
61
94
  waitForSocketToConnect(function() {
95
+ pingController.resetPingLoop();
62
96
  eventCallback["open"]();
63
97
  });
64
98
  }
65
99
 
66
100
  socket.onmessage = function(event) {
101
+ pingController.resetPingLoop();
102
+
67
103
  var messageData = JSON.parse(event.data);
68
104
  eventCallback["message"](messageData);
69
-
70
- /**
71
- * To avoid manually closing socket's connection
72
- */
73
- forceCloseSocket = false;
74
-
75
- socketCloseTimeout && clearTimeout(socketCloseTimeout);
76
- forceCloseTimeout && clearTimeout(forceCloseTimeout);
77
-
78
- socketCloseTimeout = setTimeout(function() {
79
- /**
80
- * If message's type is not 5, socket won't get any acknowledge packet,therefore
81
- * you may think that connection has been closed and you would force socket
82
- * to close, but before that you should make sure that connection is actually closed!
83
- * for that, you must send a ping message and if that message don't get any
84
- * responses too, you are allowed to manually kill socket connection.
85
- */
86
- ping();
87
-
88
- /**
89
- * We set forceCloseSocket as true so that if your ping's response don't make it
90
- * you close your socket
91
- */
92
- forceCloseSocket = true;
93
-
94
- /**
95
- * If type of messages are not 5, you won't get ant ACK packets
96
- * for that being said, we send a ping message to be sure of
97
- * socket connection's state. The ping message should have an
98
- * ACK, if not, you're allowed to close your socket after
99
- * 4 * [connectionCheckTimeout] seconds
100
- */
101
- forceCloseTimeout = setTimeout(function() {
102
- if (forceCloseSocket) {
103
- socket.close();
104
- }
105
- }, connectionCheckTimeout);
106
-
107
- }, connectionCheckTimeout * 1.5);
108
105
  }
109
106
 
110
107
  socket.onclose = function(event) {
108
+ pingController.stopPingLoop();
109
+ logLevel.debug && console.debug("[Async][Socket.js] socket.onclose happened. EventData:", event);
111
110
  onCloseHandler(event);
112
111
  }
113
112
 
114
113
  socket.onerror = function(event) {
114
+ logLevel.debug && console.debug("[Async][Socket.js] socket.onerror happened. EventData:", event);
115
115
  eventCallback["error"](event);
116
116
  }
117
117
  } catch (error) {
@@ -124,9 +124,7 @@
124
124
  },
125
125
 
126
126
  onCloseHandler = function(event) {
127
- sendPingTimeout && clearTimeout(sendPingTimeout);
128
- socketCloseTimeout && clearTimeout(socketCloseTimeout);
129
- forceCloseTimeout && clearTimeout(forceCloseTimeout);
127
+ pingController.stopPingLoop();
130
128
  eventCallback["close"](event);
131
129
  },
132
130
 
@@ -161,11 +159,6 @@
161
159
  data.trackerId = params.trackerId;
162
160
  }
163
161
 
164
- sendPingTimeout && clearTimeout(sendPingTimeout);
165
- sendPingTimeout = setTimeout(function() {
166
- ping();
167
- }, connectionCheckTimeout);
168
-
169
162
  try {
170
163
  if (params.content) {
171
164
  data.content = JSON.stringify(params.content);
@@ -198,9 +191,7 @@
198
191
  }
199
192
 
200
193
  this.close = function() {
201
- sendPingTimeout && clearTimeout(sendPingTimeout);
202
- socketCloseTimeout && clearTimeout(socketCloseTimeout);
203
- forceCloseTimeout && clearTimeout(forceCloseTimeout);
194
+ logLevel.debug && console.debug("[Async][Socket.js] Closing socket by call to this.close");
204
195
  socket.close();
205
196
  }
206
197
 
@@ -0,0 +1,34 @@
1
+ function LogLevel(logLevel){
2
+ let ll = logLevel || 2;
3
+ switch (ll) {
4
+ case 1:
5
+ return {
6
+ error: true,
7
+ debug: false,
8
+ info: false,
9
+ }
10
+ case 2:
11
+ return {
12
+ error: true,
13
+ debug: true,
14
+ info: false,
15
+ }
16
+ case 3:
17
+ return {
18
+ error: true,
19
+ debug: true,
20
+ info: true,
21
+ }
22
+ }
23
+ }
24
+
25
+
26
+ if (typeof module !== 'undefined' && typeof module.exports != 'undefined') {
27
+ module.exports = LogLevel;
28
+ }
29
+ else {
30
+ if (!window.POD) {
31
+ window.POD = {};
32
+ }
33
+ window.POD.LogLevel = LogLevel;
34
+ }
@@ -196,97 +196,6 @@
196
196
  console.log("\n");
197
197
  }
198
198
  break;
199
-
200
- case "queue":
201
- if (typeof global !== "undefined" && ({}).toString.call(global) === '[object global]') {
202
- console.log("\n");
203
- console.log("\x1b[" + BgColor + "m\x1b[8m%s\x1b[0m", "################################################################");
204
- console.log("\x1b[" + BgColor + "m\x1b[8m##################\x1b[0m\x1b[37m\x1b[" + BgColor + "m Q U E U E S T A T U S \x1b[0m\x1b[" + BgColor + "m\x1b[8m##################\x1b[0m");
205
- console.log("\x1b[" + BgColor + "m\x1b[8m%s\x1b[0m", "################################################################");
206
- console.log("\x1b[" + BgColor + "m\x1b[8m##\x1b[0m \t\t\t\t\t\t\t \x1b[" + BgColor + "m\x1b[8m##\x1b[0m");
207
-
208
- console.log("\x1b[" + BgColor + "m\x1b[8m##\x1b[0m \x1b[2m%s\x1b[0m \x1b[1m%s\x1b[0m", " QUEUE STATE\t\t", socketState);
209
- console.log("\x1b[" + BgColor + "m\x1b[8m##\x1b[0m \x1b[2m%s\x1b[0m \x1b[" + FgColor + "m%s\x1b[0m ", " CURRENT MESSAGE\t", type);
210
- console.log("\x1b[" + BgColor + "m\x1b[8m##\x1b[0m");
211
-
212
- Object.keys(msg).forEach(function(key) {
213
- if (typeof msg[key] === 'object') {
214
- console.log("\x1b[" + BgColor + "m\x1b[8m##\x1b[0m \t \x1b[1m-\x1b[0m \x1b[35m%s\x1b[0m", key);
215
- Object.keys(msg[key]).forEach(function(k) {
216
- console.log("\x1b[" + BgColor + "m\x1b[8m##\x1b[0m \t \x1b[1m•\x1b[0m \x1b[35m%s\x1b[0m : \x1b[33m%s\x1b[0m", k, msg[key][k]);
217
- });
218
- } else {
219
- console.log("\x1b[" + BgColor + "m\x1b[8m##\x1b[0m \t \x1b[1m•\x1b[0m \x1b[35m%s\x1b[0m : \x1b[33m%s\x1b[0m", key, msg[key]);
220
- }
221
- });
222
-
223
- console.log("\x1b[" + BgColor + "m\x1b[8m##\x1b[0m");
224
-
225
- if (pushSendDataQueue.length > 0) {
226
- console.log("\x1b[" + BgColor + "m\x1b[8m##\x1b[0m \x1b[2m%s\x1b[0m", " SEND QUEUE");
227
- console.log("\x1b[" + BgColor + "m\x1b[8m##\x1b[0m");
228
- Object.keys(pushSendDataQueue).forEach(function(key) {
229
- if (typeof pushSendDataQueue[key] === 'object') {
230
- console.log("\x1b[" + BgColor + "m\x1b[8m##\x1b[0m \t \x1b[1m-\x1b[0m \x1b[35m%s\x1b[0m", key);
231
- Object.keys(pushSendDataQueue[key]).forEach(function(k) {
232
- console.log("\x1b[" + BgColor + "m\x1b[8m##\x1b[0m \t \x1b[1m•\x1b[0m \x1b[35m%s\x1b[0m : \x1b[36m%s\x1b[0m", k, JSON.stringify(pushSendDataQueue[key][k]));
233
- });
234
- } else {
235
- console.log("\x1b[" + BgColor + "m\x1b[8m##\x1b[0m \t \x1b[1m•\x1b[0m \x1b[35m%s\x1b[0m : \x1b[33m%s\x1b[0m", key, pushSendDataQueue[key]);
236
- }
237
- });
238
-
239
- } else {
240
- console.log("\x1b[" + BgColor + "m\x1b[8m##\x1b[0m \x1b[2m%s\x1b[0m \x1b[1m%s\x1b[0m ", " SEND QUEUE\t\t", "Empty");
241
- }
242
-
243
- console.log("\x1b[" + BgColor + "m\x1b[8m##\x1b[0m \t\t\t\t\t\t\t \x1b[" + BgColor + "m\x1b[8m##\x1b[0m");
244
- console.log("\x1b[" + BgColor + "m\x1b[8m%s\x1b[0m", "################################################################");
245
- console.log("\n");
246
- } else {
247
- console.log("\n");
248
- console.log("%cQ U E U E S T A T U S", 'background: ' + ColorCSS + '; padding: 10px 142px; font-weight: bold; font-size: 18px; color: #fff;');
249
- console.log("\n");
250
- console.log("%c QUEUE STATE\t\t %c" + socketState, 'color: #444', 'color: #ffac28; font-weight: bold');
251
- console.log("%c CURRENT MESSAGE\t %c" + type, 'color: #444', 'color: #aa386d; font-weight: bold');
252
- console.log("\n");
253
-
254
- Object.keys(msg).forEach(function(key) {
255
- if (typeof msg[key] === 'object') {
256
- console.log("%c \t-" + key, 'color: #777');
257
- Object.keys(msg[key]).forEach(function(k) {
258
- console.log("%c \t •" + k + " : %c" + msg[key][k], 'color: #777', 'color: #f23; font-weight: bold');
259
- });
260
- } else {
261
- console.log("%c \t•" + key + " : %c" + msg[key], 'color: #777', 'color: #f23; font-weight: bold');
262
- }
263
- });
264
-
265
- console.log("\n");
266
-
267
- if (pushSendDataQueue.length > 0) {
268
- console.log("%c SEND QUEUE", 'color: #444');
269
- console.log("\n");
270
- Object.keys(pushSendDataQueue).forEach(function(key) {
271
- if (typeof pushSendDataQueue[key] === 'object') {
272
- console.log("%c \t-" + key, 'color: #777');
273
- Object.keys(pushSendDataQueue[key]).forEach(function(k) {
274
- console.log("%c \t •" + k + " : %c" + JSON.stringify(pushSendDataQueue[key][k]), 'color: #777', 'color: #999; font-weight: bold');
275
- });
276
- } else {
277
- console.log("%c \t•" + key + " : %c" + pushSendDataQueue[key], 'color: #777', 'color: #999; font-weight: bold');
278
- }
279
- });
280
-
281
- } else {
282
- console.log("%c SEND QUEUE\t\t %cEmpty", 'color: #444', 'color: #000; font-weight: bold');
283
- }
284
-
285
- console.log("\n");
286
- console.log("%c ", 'font-weight: bold; font-size: 3px; border-left: solid 540px ' + ColorCSS + ';');
287
- console.log("\n");
288
- }
289
- break;
290
199
  }
291
200
  }
292
201