aboutsummaryrefslogtreecommitdiffstats
path: root/lib/sockets.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2020-08-07 10:56:31 -0700
committerAdam Soltys <[email protected]>2020-08-07 10:56:34 -0700
commit1cccd058ebfa9c55e6cbaf66624710075c51ef90 (patch)
tree75960df2a33f9336f1037e258e208f9d3e8d1059 /lib/sockets.js
parentd3f5450795e25c3b788f7e23ebfe6438569aad00 (diff)
downloadcoinos-server-1cccd058ebfa9c55e6cbaf66624710075c51ef90.tar.gz
coinos-server-1cccd058ebfa9c55e6cbaf66624710075c51ef90.zip
close socket if client hasn't closed it
Diffstat (limited to 'lib/sockets.js')
-rw-r--r--lib/sockets.js3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/sockets.js b/lib/sockets.js
index 69fbab07..082a2b81 100644
--- a/lib/sockets.js
+++ b/lib/sockets.js
@@ -97,6 +97,9 @@ wss.on("connection", function (ws, req) {
const p = existing.find((sid) => sid !== id);
l.warn("sending logout to", p);
sockets[username][p].send(JSON.stringify({ type: "logout" }));
+ setTimeout(() => {
+ if (sockets[username][p]) sockets[username][p].close();
+ }, 5000);
}
sockets[username][id] = ws;
names[id] = username;