From 99a4cd9b670f495c59a267cc2a4b27f55c69fc46 Mon Sep 17 00:00:00 2001 From: Holly Date: Wed, 23 Feb 2022 05:35:32 +0000 Subject: [PATCH] time out users due to inactivity --- server/User.js | 1 + server/serverHandler.js | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/server/User.js b/server/User.js index 8dcc8a9..1cb018e 100644 --- a/server/User.js +++ b/server/User.js @@ -12,6 +12,7 @@ module.exports = class { this.username = username; this.uuid = uuid; this.connectTime = Date.now(); + this.timeoutTime = Date.now() + 30000; this.queue = Buffer.alloc(0); // Binato specific diff --git a/server/serverHandler.js b/server/serverHandler.js index 0af49e0..b30410e 100644 --- a/server/serverHandler.js +++ b/server/serverHandler.js @@ -31,7 +31,13 @@ setInterval(() => { if (User.id == 3) continue; // Ignore the bot // Bot: :( - User.getNewUserInformationFromDatabase(); + // Logout this user, they're clearly gone. + if (Date.now() >= User.timeoutTime) + Logout(User); + + // The user is still here + else + User.getNewUserInformationFromDatabase(); } }, 10000); @@ -118,6 +124,9 @@ module.exports = async function(req, res) { // Make sure the client's token isn't invalid if (PacketUser != null) { + // Update the session timeout time + PacketUser.timeoutTime = Date.now() + 60000; + // Create a new osu! packet reader const osuPacketReader = new osu.Client.Reader(requestData); // Parse current bancho packet