mirror of
https://github.com/Yonle/bostr.git
synced 2025-09-27 21:36:21 +02:00
fix bug for mode 2 and remove unused code
Signed-off-by: Yonle <yonle@lecturify.net>
This commit is contained in:
@@ -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) {
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user