Binato/server/Packets/Logout.js

27 lines
1,002 B
JavaScript
Raw Normal View History

2020-08-27 13:09:35 +01:00
const osu = require("osu-packet");
module.exports = function(CurrentUser) {
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.uuid)) {
global.StreamsHandler.removeUserFromStream(streamList[i], CurrentUser.uuid);
2020-08-27 13:09:35 +01:00
}
}
2021-05-15 00:24:39 +01:00
// Remove user from user list
global.removeUser(CurrentUser);
2020-08-27 13:09:35 +01:00
2021-09-24 01:39:46 +01:00
const osuPacketWriter = new osu.Bancho.Writer();
2020-08-27 13:09:35 +01:00
osuPacketWriter.SendMessage({
2021-05-15 00:24:39 +01:00
sendingClient: global.users["bot"].username,
2020-08-27 13:09:35 +01:00
message: `User ${CurrentUser.username} has logged out.`,
target: "#userlog",
2021-05-15 00:24:39 +01:00
senderId: global.users["bot"].id
2020-08-27 13:09:35 +01:00
});
global.StreamsHandler.sendToStream("#userlog", osuPacketWriter.toBuffer);
global.consoleHelper.printBancho(`User logged out, took ${new Date().getTime() - logoutStartTime}ms. [User: ${CurrentUser.username}]`);
2020-08-27 13:09:35 +01:00
}