sharp-chat/SharpChat/PacketsS2C/AuthSuccessS2CPacket.cs

47 lines
1.7 KiB
C#

namespace SharpChat.PacketsS2C {
public class AuthSuccessS2CPacket : SockChatS2CPacket {
private readonly long UserId;
private readonly string UserName;
private readonly Colour UserColour;
private readonly int UserRank;
private readonly UserPermissions UserPerms;
private readonly string ChannelName;
private readonly int MaxMessageLength;
public AuthSuccessS2CPacket(
long userId,
string userName,
Colour userColour,
int userRank,
UserPermissions userPerms,
string channelName,
int maxMsgLength
) {
UserId = userId;
UserName = userName;
UserColour = userColour;
UserRank = userRank;
UserPerms = userPerms;
ChannelName = channelName;
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}",
UserId,
UserName,
UserColour,
UserRank,
UserPerms.HasFlag(UserPermissions.KickUser) ? 1 : 0,
UserPerms.HasFlag(UserPermissions.ViewLogs) ? 1 : 0,
UserPerms.HasFlag(UserPermissions.SetOwnNickname) ? 1 : 0,
UserPerms.HasFlag(UserPermissions.CreateChannel) ? (
UserPerms.HasFlag(UserPermissions.SetChannelPermanent) ? 2 : 1
) : 0,
SockChatUtility.SanitiseChannelName(ChannelName),
MaxMessageLength
);
}
}
}