2020-08-27 13:09:35 +01:00
|
|
|
const osu = require("osu-packet");
|
|
|
|
|
|
|
|
module.exports = function(CurrentUser) {
|
2020-11-03 02:08:57 +00:00
|
|
|
const logoutStartTime = new Date().getTime();
|
2020-08-27 13:09:35 +01:00
|
|
|
|
|
|
|
const streamList = global.StreamsHandler.getStreams();
|
|
|
|
|
|
|
|
for (let i = 0; i < streamList.length; i++) {
|
|
|
|
if (global.StreamsHandler.isUserInStream(streamList[i], CurrentUser.id)) {
|
|
|
|
global.StreamsHandler.removeUserFromStream(streamList[i], CurrentUser.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 02:08:57 +00:00
|
|
|
// Find the index that the user's class is at and remove the object
|
|
|
|
for (let i = 0; i < global.users.length; i++) {
|
|
|
|
if (CurrentUser.uuid == global.users[i].uuid) {
|
|
|
|
// Remove that user from the list of users
|
|
|
|
global.users.splice(i, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-08-27 13:09:35 +01:00
|
|
|
|
|
|
|
const osuPacketWriter = new osu.Bancho.Writer;
|
|
|
|
osuPacketWriter.SendMessage({
|
2020-11-03 02:08:57 +00:00
|
|
|
sendingClient: global.users[0].username,
|
2020-08-27 13:09:35 +01:00
|
|
|
message: `User ${CurrentUser.username} has logged out.`,
|
|
|
|
target: "#userlog",
|
|
|
|
senderId: 3
|
|
|
|
});
|
|
|
|
global.StreamsHandler.sendToStream("#userlog", osuPacketWriter.toBuffer);
|
|
|
|
|
2020-11-03 02:08:57 +00:00
|
|
|
global.consoleHelper.printBancho(`User logged out, took ${new Date().getTime() - logoutStartTime}ms. [User: ${CurrentUser.username}]`);
|
2020-08-27 13:09:35 +01:00
|
|
|
}
|