2022-11-17 00:29:07 +00:00
|
|
|
import { ConsoleHelper } from "../../ConsoleHelper";
|
|
|
|
import { Database } from "../objects/Database";
|
2022-11-19 01:06:03 +00:00
|
|
|
import { DataStreamArray } from "../objects/DataStreamArray";
|
2022-11-17 00:29:07 +00:00
|
|
|
import { User } from "../objects/User";
|
|
|
|
|
2022-11-19 01:06:03 +00:00
|
|
|
export async function Logout(user:User) {
|
|
|
|
if (user.uuid === "bot") throw "Tried to log bot out, WTF???";
|
|
|
|
|
|
|
|
const logoutStartTime = Date.now();
|
|
|
|
|
2022-11-19 22:28:46 +00:00
|
|
|
user.sharedContent.streams.RemoveUserFromAllStreams(user);
|
2022-11-19 01:06:03 +00:00
|
|
|
|
|
|
|
// Remove user from user list
|
2022-11-19 22:28:46 +00:00
|
|
|
user.sharedContent.users.remove(user.uuid);
|
2022-11-19 01:06:03 +00:00
|
|
|
|
2022-11-19 22:28:46 +00:00
|
|
|
await user.sharedContent.database.query("UPDATE osu_info SET value = ? WHERE name = 'online_now'", [user.sharedContent.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
|
|
|
}
|