From b06f29da5ba86d221353ec781db959d8d006ba1f Mon Sep 17 00:00:00 2001 From: Yonle Date: Tue, 31 Oct 2023 15:52:07 +0700 Subject: [PATCH] fix bug for mode 2 and remove unused code Signed-off-by: Yonle --- bouncer/bouncer1.js | 8 -------- bouncer/bouncer2.js | 11 +---------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/bouncer/bouncer1.js b/bouncer/bouncer1.js index 0bd50fa..aba4a0e 100644 --- a/bouncer/bouncer1.js +++ b/bouncer/bouncer1.js @@ -68,14 +68,6 @@ module.exports = (ws, req) => { csess.set(ws.id, ws); } -// CL - Broadcast message to every existing client sockets -function bc_c(msg) { - for (sock of csess) { - if (sock.readyState >= 2) return csess.delete(sock.id); - sock.send(JSON.stringify(msg)); - } -} - // WS - Broadcast message to every existing sockets function bc(msg) { for (sock of socks) { diff --git a/bouncer/bouncer2.js b/bouncer/bouncer2.js index da104eb..d05c8fa 100644 --- a/bouncer/bouncer2.js +++ b/bouncer/bouncer2.js @@ -70,15 +70,6 @@ module.exports = (ws, req) => { relays.forEach(_ => newConn(_, ws.id)); } -// CL - Broadcast message to every existing client sockets -function bc_c(msg, id) { - for (sock of csess) { - if (sock.id !== id) continue; - if (sock.readyState >= 2) return csess.delete(sock.id); - sock.send(JSON.stringify(msg)); - } -} - // WS - Broadcast message to every existing sockets function bc(msg, id) { for (sock of socks) { @@ -126,7 +117,7 @@ function newConn(addr, id) { if (sess.prepare("SELECT * FROM events WHERE cID = ? AND subID = ? AND eID = ?;").get(id, data[1], data[2]?.id)) return; // No need to transmit once it has been transmitted before. sess.prepare("INSERT INTO events VALUES (?, ?, ?);").run(id, data[1], data[2]?.id); - bc_c(data, id); + csess.get(id)?.send(JSON.stringify(data)); break; } }