2025-04-25 20:05:55 +00:00
|
|
|
|
using System.Text;
|
2022-08-30 17:00:58 +02:00
|
|
|
|
|
2025-04-25 20:12:42 +00:00
|
|
|
|
namespace SharpChat.S2CPackets {
|
2025-04-25 22:14:48 +00:00
|
|
|
|
public class ForceDisconnectS2CPacket(DateTimeOffset? expires = null) : S2CPacket {
|
2025-04-25 20:33:42 +00:00
|
|
|
|
public string Pack() {
|
2023-02-07 16:01:56 +01:00
|
|
|
|
StringBuilder sb = new();
|
2022-08-30 17:00:58 +02:00
|
|
|
|
|
2025-04-25 22:14:48 +00:00
|
|
|
|
sb.Append("9\t");
|
2022-08-30 17:00:58 +02:00
|
|
|
|
|
2025-04-25 22:14:48 +00:00
|
|
|
|
if(expires.HasValue && expires.Value > DateTimeOffset.UtcNow) {
|
|
|
|
|
sb.Append("1\t");
|
|
|
|
|
if(expires.Value < DateTimeOffset.MaxValue)
|
|
|
|
|
sb.Append(expires.Value.ToUnixTimeSeconds());
|
2023-02-07 23:28:06 +01:00
|
|
|
|
else
|
2025-04-25 22:14:48 +00:00
|
|
|
|
sb.Append("-1");
|
|
|
|
|
} else
|
|
|
|
|
sb.Append('0');
|
|
|
|
|
|
2025-04-25 20:33:42 +00:00
|
|
|
|
return sb.ToString();
|
2022-08-30 17:00:58 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|