diff options
Diffstat (limited to 'lib/sockets.js')
| -rw-r--r-- | lib/sockets.js | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/sockets.js b/lib/sockets.js index d4ca336d..d0f00771 100644 --- a/lib/sockets.js +++ b/lib/sockets.js @@ -54,6 +54,11 @@ wss.on("connection", function(ws, req) { try { const username = jwt.decode(token).username; if (!sockets[username]) sockets[username] = {}; + const existing = Object.keys(sockets[username]); + if (existing.length > 5) { + l.warn("too many sockets, logging out", existing[0]); + sockets[username][existing[0]].send(JSON.stringify({ type: "login", data: false })); + } sockets[username][id] = ws; names[id] = username; |
