@alizadefaig/pos-server 1.2.14 → 1.2.16
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/app/config.js +2 -1
- package/app/logger/Server.js +5 -0
- package/app/tcp.js +26 -6
- package/package.json +1 -1
package/app/config.js
CHANGED
package/app/logger/Server.js
CHANGED
package/app/tcp.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
const net = require('net');
|
|
2
|
+
const {socketSendByFilter} = require("../utils");
|
|
3
|
+
const serverSocket = require("./socket/server")();
|
|
2
4
|
|
|
3
5
|
module.exports = function (io = null) {
|
|
4
6
|
const server = net.createServer((socket) => {
|
|
@@ -34,17 +36,35 @@ module.exports = function (io = null) {
|
|
|
34
36
|
const rawData = messageBuffer.toString('utf8');
|
|
35
37
|
const payload = JSON.parse(rawData);
|
|
36
38
|
|
|
37
|
-
console.log(`Received ${expectedLength} data length: ${expectedLength}`, payload);
|
|
39
|
+
// console.log(`Received ${expectedLength} data length: ${expectedLength}`, payload);
|
|
38
40
|
|
|
39
41
|
// payload содержит: event, company_id, to_id, data и т.д.
|
|
40
42
|
|
|
41
43
|
// Логика отправки в Socket.IO
|
|
42
44
|
// Пример: отправляем в конкретную комнату или всем
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
|
|
46
|
+
const companyId = payload.company_id;
|
|
47
|
+
const eventName = payload.event;
|
|
48
|
+
const data = payload.data;
|
|
49
|
+
|
|
50
|
+
if (!companyId || !data || !eventName) {
|
|
51
|
+
return res.json({
|
|
52
|
+
success: false,
|
|
53
|
+
message: 'Required fields is not set',
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const to = payload.to;
|
|
58
|
+
const excepts = payload.excepts;
|
|
59
|
+
const toId = payload.toId;
|
|
60
|
+
socketSendByFilter({
|
|
61
|
+
companyId,
|
|
62
|
+
eventName,
|
|
63
|
+
data,
|
|
64
|
+
to,
|
|
65
|
+
toId,
|
|
66
|
+
excepts
|
|
67
|
+
}, serverSocket);
|
|
48
68
|
|
|
49
69
|
} catch (e) {
|
|
50
70
|
console.error('JSON Error:', e);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alizadefaig/pos-server",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.16",
|
|
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": {
|