diff --git a/assist/servers/websocket.js b/assist/servers/websocket.js index 8dce5d459..918af4034 100644 --- a/assist/servers/websocket.js +++ b/assist/servers/websocket.js @@ -370,16 +370,16 @@ module.exports = { debug && console.log(`received event:${eventName}, should be handled by another listener, stopping onAny.`); return } + // Back compatibility (add top layer with meta information) + if (args[0].meta === undefined) { + args[0] = {meta: {tabId: socket.tabId}, data: args[0]}; + } if (socket.identity === IDENTITIES.session) { debug && console.log(`received event:${eventName}, from:${socket.identity}, sending message to room:${socket.roomId}`); // TODO: emit message to all agents in the room (except tabs) socket.to(socket.roomId).emit(eventName, args[0]); } else { debug && console.log(`received event:${eventName}, from:${socket.identity}, sending message to session of room:${socket.roomId}`); - // Back compatibility (add top layer with meta information) - if (args[0].meta === undefined) { - args[0] = {meta: {tabId: socket.tabId}, data: args[0]}; - } let socketId = await findSessionSocketId(io, socket.roomId, args[0].meta.tabId); if (socketId === null) { debug && console.log(`session not found for:${socket.roomId}`); diff --git a/ee/assist/servers/websocket-cluster.js b/ee/assist/servers/websocket-cluster.js index b68654a8a..98135d349 100644 --- a/ee/assist/servers/websocket-cluster.js +++ b/ee/assist/servers/websocket-cluster.js @@ -422,16 +422,16 @@ module.exports = { debug && console.log(`received event:${eventName}, should be handled by another listener, stopping onAny.`); return } + // Back compatibility (add top layer with meta information) + if (args[0].meta === undefined) { + args[0] = {meta: {tabId: socket.tabId}, data: args[0]}; + } if (socket.identity === IDENTITIES.session) { debug && console.log(`received event:${eventName}, from:${socket.identity}, sending message to room:${socket.roomId}`); // TODO: send to all agents in the room socket.to(socket.roomId).emit(eventName, args[0]); } else { debug && console.log(`received event:${eventName}, from:${socket.identity}, sending message to session of room:${socket.roomId}`); - // Back compatibility (add top layer with meta information) - if (args[0].meta === undefined) { - args[0] = {meta: {tabId: socket.tabId}, data: args[0]}; - } let socketId = await findSessionSocketId(io, socket.roomId, args[0].meta.tabId); if (socketId === null) { debug && console.log(`session not found for:${socket.roomId}`); diff --git a/ee/assist/servers/websocket.js b/ee/assist/servers/websocket.js index ae328ed1d..b7e96cefc 100644 --- a/ee/assist/servers/websocket.js +++ b/ee/assist/servers/websocket.js @@ -391,15 +391,15 @@ module.exports = { debug && console.log(`received event:${eventName}, should be handled by another listener, stopping onAny.`); return } + // Back compatibility (add top layer with meta information) + if (args[0].meta === undefined) { + args[0] = {meta: {tabId: socket.tabId}, data: args[0]}; + } if (socket.identity === IDENTITIES.session) { debug && console.log(`received event:${eventName}, from:${socket.identity}, sending message to room:${socket.peerId}`); socket.to(socket.roomId).emit(eventName, args[0]); } else { debug && console.log(`received event:${eventName}, from:${socket.identity}, sending message to session of room:${socket.peerId}`); - // Back compatibility (add top layer with meta information) - if (args[0].meta === undefined) { - args[0] = {meta: {tabId: socket.tabId}, data: args[0]}; - } let socketId = await findSessionSocketId(io, socket.roomId, args[0].meta.tabId); if (socketId === null) { debug && console.log(`session not found for:${socket.roomId}`);