sharp-chat/SharpChat.SockChat/PacketsS2C/UserDisconnectS2CPacket.cs

35 lines
1.1 KiB
C#
Raw Normal View History

namespace SharpChat.SockChat.PacketsS2C {
public class UserDisconnectS2CPacket : SockChatTimedS2CPacket {
private readonly long UserId;
private readonly string UserName;
private readonly UserDisconnectReason Reason;
2022-08-30 15:00:58 +00:00
public UserDisconnectS2CPacket(
long userId,
string userName,
UserDisconnectReason reason
) {
UserId = userId;
UserName = userName;
2022-08-30 15:00:58 +00:00
Reason = reason;
}
2024-05-10 15:24:43 +00:00
public override string Pack() {
2024-05-10 17:28:52 +00:00
return string.Format(
"3\t{0}\t{1}\t{2}\t{3}\t{4}",
UserId,
UserName,
2024-05-10 17:28:52 +00:00
Reason switch {
UserDisconnectReason.Leave => "leave",
UserDisconnectReason.TimeOut => "timeout",
UserDisconnectReason.Kicked => "kick",
UserDisconnectReason.Flood => "flood",
2024-05-10 17:28:52 +00:00
_ => "leave",
},
TimeStamp.ToUnixTimeSeconds(),
MessageId
2024-05-10 17:28:52 +00:00
);
2022-08-30 15:00:58 +00:00
}
}
}