2024-05-20 02:16:38 +00:00
|
|
|
|
namespace SharpChat.Packet {
|
|
|
|
|
public class UserDisconnectPacket : SockChatTimedS2CPacket {
|
2024-05-10 18:29:48 +00:00
|
|
|
|
private readonly long UserId;
|
|
|
|
|
private readonly string UserName;
|
2024-05-19 02:17:51 +00:00
|
|
|
|
private readonly UserDisconnectReason Reason;
|
2022-08-30 15:00:58 +00:00
|
|
|
|
|
2024-05-10 18:29:48 +00:00
|
|
|
|
public UserDisconnectPacket(
|
|
|
|
|
long userId,
|
|
|
|
|
string userName,
|
2024-05-19 02:17:51 +00:00
|
|
|
|
UserDisconnectReason reason
|
2024-05-10 18:29:48 +00:00
|
|
|
|
) {
|
|
|
|
|
UserId = userId;
|
2024-05-14 22:56:56 +00:00
|
|
|
|
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}",
|
2024-05-10 18:29:48 +00:00
|
|
|
|
UserId,
|
|
|
|
|
UserName,
|
2024-05-10 17:28:52 +00:00
|
|
|
|
Reason switch {
|
2024-05-19 02:17:51 +00:00
|
|
|
|
UserDisconnectReason.Leave => "leave",
|
|
|
|
|
UserDisconnectReason.TimeOut => "timeout",
|
|
|
|
|
UserDisconnectReason.Kicked => "kick",
|
|
|
|
|
UserDisconnectReason.Flood => "flood",
|
2024-05-10 17:28:52 +00:00
|
|
|
|
_ => "leave",
|
|
|
|
|
},
|
2024-05-20 02:16:38 +00:00
|
|
|
|
TimeStamp.ToUnixTimeSeconds(),
|
|
|
|
|
MessageId
|
2024-05-10 17:28:52 +00:00
|
|
|
|
);
|
2022-08-30 15:00:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|