aboutsummaryrefslogtreecommitdiffstats
path: root/lib/sockets.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sockets.ts')
-rw-r--r--lib/sockets.ts6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/sockets.ts b/lib/sockets.ts
index 4ee8e00e..17c3cb4e 100644
--- a/lib/sockets.ts
+++ b/lib/sockets.ts
@@ -11,6 +11,7 @@ const users = {};
export const emit = (uid, type, data) => {
if (type === "payment" && data.amount > 0) {
+ console.log("SUBS", subscriptions.length);
for (let i = subscriptions.length - 1; i >= 0; i--) {
let s = subscriptions[i];
@@ -117,6 +118,7 @@ Bun.serve({
store.sessions[data] = ws;
break;
case "subscribe":
+ console.log("SUBBING", data.id);
subscriptions.push({ invoice: data, ws });
break;
default:
@@ -138,6 +140,10 @@ Bun.serve({
delete store.sockets[uid][id];
}
+ let i;
+ ~(i = subscriptions.findIndex((s) => s.ws.id === id)) &&
+ subscriptions.splice(i, 1);
+
if (all[id]) delete all[id];
} catch (e) {
err("problem closing socket", e.message);