Binato/server/Packets/ChannelJoin.js

17 lines
692 B
JavaScript
Raw Permalink Normal View History

const osu = require("osu-packet"),
2022-08-26 12:52:00 +01:00
consoleHelper = require("../../consoleHelper.js"),
Streams = require("../Streams.js");
2021-01-26 12:26:46 +00:00
module.exports = function(CurrentUser, channelName = "") {
// Make sure the user is not already in the channel
2022-08-26 12:52:00 +01:00
if (Streams.isUserInStream(channelName, CurrentUser.uuid))
return consoleHelper.printBancho(`Did not add user to channel ${channelName} because they are already in it`);
2021-01-26 12:26:46 +00:00
const osuPacketWriter = new osu.Bancho.Writer;
2021-01-26 12:26:46 +00:00
osuPacketWriter.ChannelJoinSuccess(channelName);
2022-08-26 12:52:00 +01:00
if (!Streams.isUserInStream(channelName, CurrentUser.uuid))
Streams.addUserToStream(channelName, CurrentUser.uuid);
2021-01-26 12:26:46 +00:00
CurrentUser.addActionToQueue(osuPacketWriter.toBuffer);
2021-01-26 12:26:46 +00:00
}