time out users due to inactivity

This commit is contained in:
Holly Stubbs 2022-02-23 05:35:32 +00:00
parent f9fe6e2a27
commit 99a4cd9b67
Signed by: tgpholly
GPG key ID: B8583C4B7D18119E
2 changed files with 11 additions and 1 deletions

View file

@ -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

View file

@ -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