2022-08-30 15:00:58 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace SharpChat.Packet {
|
|
|
|
|
public enum UserDisconnectReason {
|
|
|
|
|
Leave,
|
|
|
|
|
TimeOut,
|
|
|
|
|
Kicked,
|
|
|
|
|
Flood,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class UserDisconnectPacket : ServerPacket {
|
|
|
|
|
public DateTimeOffset Disconnected { get; private set; }
|
|
|
|
|
public ChatUser User { get; private set; }
|
|
|
|
|
public UserDisconnectReason Reason { get; private set; }
|
|
|
|
|
|
|
|
|
|
public UserDisconnectPacket(DateTimeOffset disconnected, ChatUser user, UserDisconnectReason reason) {
|
|
|
|
|
Disconnected = disconnected;
|
|
|
|
|
User = user ?? throw new ArgumentNullException(nameof(user));
|
|
|
|
|
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}",
|
|
|
|
|
User.UserId,
|
|
|
|
|
User.LegacyNameWithStatus,
|
|
|
|
|
Reason switch {
|
|
|
|
|
UserDisconnectReason.Leave => "leave",
|
|
|
|
|
UserDisconnectReason.TimeOut => "timeout",
|
|
|
|
|
UserDisconnectReason.Kicked => "kick",
|
|
|
|
|
UserDisconnectReason.Flood => "flood",
|
|
|
|
|
_ => "leave",
|
|
|
|
|
},
|
|
|
|
|
Disconnected.ToUnixTimeSeconds(),
|
|
|
|
|
SequenceId
|
|
|
|
|
);
|
2022-08-30 15:00:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|