diff --git a/server/index.js b/server/index.js index 334a1aa..9b864f1 100644 --- a/server/index.js +++ b/server/index.js @@ -185,6 +185,7 @@ wss.on("connection", function connection(ws, req) { if ( client !== ws && client.readyState === WebSocket.OPEN && + (ws.playerId === "host" || client.playerId === "host") && dataToPlayer[client.playerId] ) { client.send(JSON.stringify(dataToPlayer[client.playerId])); @@ -205,7 +206,11 @@ wss.on("connection", function connection(ws, req) { data ); channels[ws.channel].forEach(function each(client) { - if (client !== ws && client.readyState === WebSocket.OPEN) { + if ( + client !== ws && + client.readyState === WebSocket.OPEN && + (ws.playerId === "host" || client.playerId === "host") + ) { client.send(data); metrics.messages_outgoing.inc(); }