sharp-chat/SharpChat/Packet/UserConnectPacket.cs

46 lines
1.5 KiB
C#

using System;
namespace SharpChat.Packet {
public class UserConnectPacket : ServerPacket {
private readonly DateTimeOffset Joined;
private readonly long UserId;
private readonly string UserName;
private readonly ChatColour UserColour;
private readonly int UserRank;
private readonly ChatUserPermissions UserPerms;
public UserConnectPacket(
DateTimeOffset joined,
long userId,
string userName,
ChatColour userColour,
int userRank,
ChatUserPermissions userPerms
) {
Joined = joined;
UserId = userId;
UserName = userName;
UserColour = userColour;
UserRank = userRank;
UserPerms = userPerms;
}
public override string Pack() {
return string.Format(
"1\t{0}\t{1}\t{2}\t{3}\t{4} {5} {6} {7} {8}\t{9}",
Joined.ToUnixTimeSeconds(),
UserId,
UserName,
UserColour,
UserRank,
UserPerms.HasFlag(ChatUserPermissions.KickUser) ? 1 : 0,
UserPerms.HasFlag(ChatUserPermissions.ViewLogs) ? 1 : 0,
UserPerms.HasFlag(ChatUserPermissions.SetOwnNickname) ? 1 : 0,
UserPerms.HasFlag(ChatUserPermissions.CreateChannel) ? (
UserPerms.HasFlag(ChatUserPermissions.SetChannelPermanent) ? 2 : 1
) : 0,
SequenceId
);
}
}
}