sharp-chat/SharpChat/Packet/AuthSuccessPacket.cs

40 lines
1.5 KiB
C#

using System;
namespace SharpChat.Packet {
public class AuthSuccessPacket : ServerPacket {
public ChatUser User { get; private set; }
public ChatChannel Channel { get; private set; }
public ChatConnection Connection { get; private set; }
public int MaxMessageLength { get; private set; }
public AuthSuccessPacket(
ChatUser user,
ChatChannel channel,
ChatConnection connection,
int maxMsgLength
) {
User = user ?? throw new ArgumentNullException(nameof(user));
Channel = channel ?? throw new ArgumentNullException(nameof(channel));
Connection = connection ?? throw new ArgumentNullException(nameof(connection));
MaxMessageLength = maxMsgLength;
}
public override string Pack() {
return string.Format(
"1\ty\t{0}\t{1}\t{2}\t{3} {4} {5} {6} {7}\t{8}\t{9}",
User.UserId,
User.LegacyNameWithStatus,
User.Colour,
User.Rank,
User.Can(ChatUserPermissions.KickUser) ? 1 : 0,
User.Can(ChatUserPermissions.ViewLogs) ? 1 : 0,
User.Can(ChatUserPermissions.SetOwnNickname) ? 1 : 0,
User.Can(ChatUserPermissions.CreateChannel | ChatUserPermissions.SetChannelPermanent, true) ? 2 : (
User.Can(ChatUserPermissions.CreateChannel) ? 1 : 0
),
Channel.Name,
MaxMessageLength
);
}
}
}