From e036042a3dec38ebf8890db06b1acf012b732dfb Mon Sep 17 00:00:00 2001 From: HF Date: Mon, 4 Jul 2022 02:11:52 +0200 Subject: [PATCH] add logging if someone subscribes to many chunks --- src/socket/SocketServer.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/socket/SocketServer.js b/src/socket/SocketServer.js index 0639866..e2a883d 100644 --- a/src/socket/SocketServer.js +++ b/src/socket/SocketServer.js @@ -91,6 +91,7 @@ class SocketServer { return; } ws.user = user; + ws.chunkCnt = 0; ws.name = user.getName(); const { ip } = user; @@ -569,6 +570,12 @@ class SocketServer { } pushChunk(chunkid, ws) { + ws.chunkCnt += 1; + if (ws.chunkCnt === 25000) { + logger.info( + `Client ${ws.user.ip} subscribed to 25k chunks`, + ); + } if (!this.CHUNK_CLIENTS.has(chunkid)) { this.CHUNK_CLIENTS.set(chunkid, []); } @@ -579,6 +586,7 @@ class SocketServer { } deleteChunk(chunkid, ws) { + ws.chunkCnt -= 1; if (!this.CHUNK_CLIENTS.has(chunkid)) return; const clients = this.CHUNK_CLIENTS.get(chunkid); const pos = clients.indexOf(ws);