From f984f56459182375421c4af0a31393a8f411a296 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 18 Apr 2021 22:35:47 +0900 Subject: [PATCH] =?UTF-8?q?=E7=B2=BE=E5=BA=A6=E3=82=92=E9=AB=98=E3=82=81?= =?UTF-8?q?=E3=82=8B=E3=81=9F=E3=82=81=E3=82=B9=E3=83=88=E3=83=AA=E3=83=BC?= =?UTF-8?q?=E3=83=9F=E3=83=B3=E3=82=B0=E6=8E=A5=E7=B6=9A=E4=B8=AD=E3=81=AB?= =?UTF-8?q?=E5=AE=9A=E6=9C=9F=E7=9A=84=E3=81=ABlastActiveDate=E3=82=92?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/api/streaming.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/server/api/streaming.ts b/src/server/api/streaming.ts index 7224c2357..57e8c9086 100644 --- a/src/server/api/streaming.ts +++ b/src/server/api/streaming.ts @@ -35,10 +35,22 @@ module.exports = (server: http.Server) => { const main = new MainStreamConnection(connection, ev, user, app); + const intervalId = user ? setInterval(() => { + Users.update(user.id, { + lastActiveDate: new Date(), + }); + }, 1000 * 60 * 5) : null; + if (user) { + Users.update(user.id, { + lastActiveDate: new Date(), + }); + } + connection.once('close', () => { ev.removeAllListeners(); main.dispose(); redisClient.off('message', onRedisMessage); + if (intervalId) clearInterval(intervalId); }); connection.on('message', async (data) => { @@ -46,11 +58,5 @@ module.exports = (server: http.Server) => { connection.send('pong'); } }); - - if (user) { - Users.update(user.id, { - lastActiveDate: new Date(), - }); - } }); };