File size: 253 Bytes
fe83268
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
function send(ws, msg) {
  if (ws.readyState === ws.OPEN) ws.send(JSON.stringify(msg));
}

function broadcast(room, msg, exclude) {
  for (const p of room.participants) {
    if (p !== exclude) send(p, msg);
  }
}

module.exports = { send, broadcast };