@alizadefaig/pos-server 1.2.22 → 1.2.23

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.
@@ -39,6 +39,7 @@ module.exports = (server = null) => {
39
39
  const PROXY_TARGET = getConfig().apiUrl;
40
40
 
41
41
  socket.join(companyId);
42
+ if (terminalId) socket.join(`terminal:${terminalId}`);
42
43
  socket.terminalId = terminalId;
43
44
  socket.companyId = companyId;
44
45
  socket.userId = userId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alizadefaig/pos-server",
3
- "version": "1.2.22",
3
+ "version": "1.2.23",
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": {
package/utils.js CHANGED
@@ -100,15 +100,7 @@ const socketSendByFilter = ({companyId, eventName, data, to, toId, excepts}, ser
100
100
  if (!to) {
101
101
  serverSocket.to(companyId).emit(eventName, data);
102
102
  } else if (to === 'terminal' && toId) {
103
- const room = serverSocket.sockets.adapter.rooms.get(companyId);
104
- if (room) {
105
- for (const socketId of room) {
106
- const sock = serverSocket.sockets.sockets.get(socketId);
107
- if (sock && sock.terminalId === toId) {
108
- sock.emit(eventName, data);
109
- }
110
- }
111
- }
103
+ serverSocket.to(`terminal:${toId}`).emit(eventName, data);
112
104
  }
113
105
  }
114
106