Binato/server/packets/Logout.ts

19 lines
717 B
TypeScript
Raw Normal View History

2022-11-17 00:29:07 +00:00
import { ConsoleHelper } from "../../ConsoleHelper";
2023-09-10 12:59:22 +01:00
import Database from "../objects/Database";
import DataStreamArray from "../objects/DataStreamArray";
import User from "../objects/User";
2022-11-17 00:29:07 +00:00
2023-09-10 12:59:22 +01:00
export default async function Logout(user:User) {
2022-11-19 01:06:03 +00:00
if (user.uuid === "bot") throw "Tried to log bot out, WTF???";
const logoutStartTime = Date.now();
2023-08-20 13:03:01 +01:00
user.shared.streams.RemoveUserFromAllStreams(user);
2022-11-19 01:06:03 +00:00
// Remove user from user list
2023-08-20 13:03:01 +01:00
user.shared.users.remove(user.uuid);
2022-11-19 01:06:03 +00:00
2023-10-04 15:10:38 +01:00
await user.shared.database.execute("UPDATE osu_info SET value = ? WHERE name = 'online_now'", [user.shared.users.getLength() - 1]);
2022-11-19 01:06:03 +00:00
ConsoleHelper.printBancho(`User logged out, took ${Date.now() - logoutStartTime}ms. [User: ${user.username}]`);
2022-11-17 00:29:07 +00:00
}