fix(assist): apply message's top layer structure before broadcast call
This commit is contained in:
parent
b51cc1ecf4
commit
4d839b241b
3 changed files with 12 additions and 12 deletions
|
|
@ -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}`);
|
||||
|
|
|
|||
|
|
@ -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}`);
|
||||
|
|
|
|||
|
|
@ -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}`);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue