diff options
| author | Adam Soltys <[email protected]> | 2024-10-11 22:36:35 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-10-11 22:36:35 -0700 |
| commit | 047db29c3489e6aba60dd334fdcc5d4cee43b21c (patch) | |
| tree | e496be7b46d8617f8085d6815ce6ed76be3225b3 /lib | |
| parent | 8b2aae9b29649df4ee2aff21b0864da0982d5cd4 (diff) | |
| download | coinos-server-047db29c3489e6aba60dd334fdcc5d4cee43b21c.tar.gz coinos-server-047db29c3489e6aba60dd334fdcc5d4cee43b21c.zip | |
clean up invoice subscriptions
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sockets.ts | 6 |
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); |
