39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
using System;
|
|
|
|
namespace SharpChat.Packet {
|
|
public class UserDisconnectPacket : ServerPacket {
|
|
private readonly long Timestamp;
|
|
private readonly long UserId;
|
|
private readonly string UserName;
|
|
private readonly UserDisconnectReason Reason;
|
|
|
|
public UserDisconnectPacket(
|
|
DateTimeOffset timestamp,
|
|
long userId,
|
|
string userName,
|
|
UserDisconnectReason reason
|
|
) {
|
|
Timestamp = timestamp.ToUnixTimeSeconds();
|
|
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,
|
|
SequenceId
|
|
);
|
|
}
|
|
}
|
|
}
|