Allow users to join chat channels

This commit is contained in:
Holly Stubbs 2023-09-10 18:32:45 +01:00
parent 469cbb9bc9
commit a00aba5825
Signed by: tgpholly
GPG key ID: B8583C4B7D18119E
2 changed files with 17 additions and 2 deletions

View file

@ -234,11 +234,11 @@ export default async function HandleRequest(req:IncomingMessage, res:ServerRespo
break;
case Packets.Client_ChannelJoin:
//ChannelJoin(PacketUser, CurrentPacket.data);
PacketUser.joinChannel(CurrentPacket.data);
break;
case Packets.Client_ChannelPart:
//ChannelPart(PacketUser, CurrentPacket.data);
PacketUser.leaveChannel(CurrentPacket.data);
break;
case Packets.Client_SetAwayMessage:

View file

@ -5,6 +5,7 @@ import DataStream from "./DataStream";
import StatusUpdate from "../packets/StatusUpdate";
import Shared from "../objects/Shared";
import Slot from "./Slot";
import Channel from "./Channel";
const rankingModes = [
"pp_raw",
@ -144,4 +145,18 @@ export default class User {
StatusUpdate(this, this.id);
}
}
joinChannel(channelName:string) {
const channel = this.shared.chatManager.GetChannelByName(channelName);
if (channel instanceof Channel) {
channel.Join(this);
}
}
leaveChannel(channelName:string) {
const channel = this.shared.chatManager.GetChannelByName(channelName);
if (channel instanceof Channel) {
channel.Leave(this);
}
}
}