@alizadefaig/pos-server 1.2.16 → 1.2.18

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.
Files changed (2) hide show
  1. package/app/tcp.js +22 -3
  2. package/package.json +1 -1
package/app/tcp.js CHANGED
@@ -1,9 +1,12 @@
1
1
  const net = require('net');
2
2
  const {socketSendByFilter} = require("../utils");
3
+ const {getLogger} = require("./logger/Log");
4
+ // const moment = require("moment");
3
5
  const serverSocket = require("./socket/server")();
4
6
 
5
7
  module.exports = function (io = null) {
6
8
  const server = net.createServer((socket) => {
9
+ const connectedAt = Date.now();
7
10
  console.log('Laravel connected via TCP');
8
11
 
9
12
  let buffer = Buffer.alloc(0); // Буфер накопления
@@ -34,9 +37,14 @@ module.exports = function (io = null) {
34
37
  // Обработка полного сообщения
35
38
  try {
36
39
  const rawData = messageBuffer.toString('utf8');
37
- const payload = JSON.parse(rawData);
40
+ let payload = JSON.parse(rawData);
41
+ let profiling = {};
42
+ if (payload.hasOwnProperty('profiling')) {
43
+ profiling = payload.profiling;
44
+ profiling['12_connection_received'] = connectedAt;
45
+ payload = payload.data;
46
+ }
38
47
 
39
- // console.log(`Received ${expectedLength} data length: ${expectedLength}`, payload);
40
48
 
41
49
  // payload содержит: event, company_id, to_id, data и т.д.
42
50
 
@@ -57,10 +65,21 @@ module.exports = function (io = null) {
57
65
  const to = payload.to;
58
66
  const excepts = payload.excepts;
59
67
  const toId = payload.toId;
68
+ const now = Date.now();
69
+ // const nowUtc = moment.utc();
70
+
71
+ const logger = getLogger();
72
+ // logger.info(`Start: ${now} ${companyId} - ${JSON.stringify(payload)}`)
73
+ console.log(`Start: ${now} ${companyId} - ${JSON.stringify(payload)}`);
74
+ profiling['13_sent_to_websocket'] = Date.now();
60
75
  socketSendByFilter({
61
76
  companyId,
62
77
  eventName,
63
- data,
78
+ data: {
79
+ ...data,
80
+ profiling: profiling,
81
+ // _server_time: nowUtc?.valueOf()
82
+ },
64
83
  to,
65
84
  toId,
66
85
  excepts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alizadefaig/pos-server",
3
- "version": "1.2.16",
3
+ "version": "1.2.18",
4
4
  "description": "Server in express js with Proxy to Main server if need and will work with Electron JS",
5
5
  "homepage": "https://gitlab.com/faigalizade/pos-server#readme",
6
6
  "bugs": {