Make things not receive messages from themselves

This commit is contained in:
osmarks 2018-09-16 16:15:33 +01:00
parent 8b64a05d1c
commit d986327767
1 changed files with 2 additions and 2 deletions

View File

@ -53,13 +53,13 @@ const commands = {
// Send message to all clients listening on this channel or the wildcard channel.
const sentTo = [];
wss.clients.forEach(client => {
if ((client.channels.includes(message.channel) || client.channels.includes(wildcardChannel)) && client.readyState === websocket.OPEN) {
if ((client.channels.includes(message.channel) || client.channels.includes(wildcardChannel)) && client.readyState === websocket.OPEN && client.ID !== ws.ID) {
client.send(JSON.stringify(toSend));
sentTo.push(client.ID);
}
});
return { sentTo };
return { sentTo, ID: toSend.ID };
},
getID(ws) {
return { ID: ws.ID };