34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
namespace SharpChat.PacketsS2C {
|
|
public class UserDisconnectS2CPacket : SockChatTimedS2CPacket {
|
|
private readonly long UserId;
|
|
private readonly string UserName;
|
|
private readonly UserDisconnectReason Reason;
|
|
|
|
public UserDisconnectS2CPacket(
|
|
long userId,
|
|
string userName,
|
|
UserDisconnectReason reason
|
|
) {
|
|
UserId = userId;
|
|
UserName = userName;
|
|
Reason = reason;
|
|
}
|
|
|
|
public override string Pack() {
|
|
return string.Format(
|
|
"3\t{0}\t{1}\t{2}\t{3}\t{4}",
|
|
UserId,
|
|
UserName,
|
|
Reason switch {
|
|
UserDisconnectReason.Leave => "leave",
|
|
UserDisconnectReason.TimeOut => "timeout",
|
|
UserDisconnectReason.Kicked => "kick",
|
|
UserDisconnectReason.Flood => "flood",
|
|
_ => "leave",
|
|
},
|
|
TimeStamp.ToUnixTimeSeconds(),
|
|
MessageId
|
|
);
|
|
}
|
|
}
|
|
}
|