Alter pong packet to conform to the spec.
This commit is contained in:
parent
3c8bb88d53
commit
b026bad176
2 changed files with 2 additions and 14 deletions
SharpChat
|
@ -4,20 +4,8 @@ using System.Text;
|
||||||
|
|
||||||
namespace SharpChat.Packet {
|
namespace SharpChat.Packet {
|
||||||
public class PongPacket : ServerPacket {
|
public class PongPacket : ServerPacket {
|
||||||
public DateTimeOffset PongTime { get; private set; }
|
|
||||||
|
|
||||||
public PongPacket(DateTimeOffset dto) {
|
|
||||||
PongTime = dto;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<string> Pack() {
|
public override IEnumerable<string> Pack() {
|
||||||
StringBuilder sb = new();
|
yield return "0\tpong";
|
||||||
|
|
||||||
sb.Append('0');
|
|
||||||
sb.Append('\t');
|
|
||||||
sb.Append(PongTime.ToUnixTimeSeconds());
|
|
||||||
|
|
||||||
yield return sb.ToString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace SharpChat.PacketHandlers {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ctx.Connection.BumpPing();
|
ctx.Connection.BumpPing();
|
||||||
ctx.Connection.Send(new PongPacket(ctx.Connection.LastPing));
|
ctx.Connection.Send(new PongPacket());
|
||||||
|
|
||||||
ctx.Chat.ContextAccess.Wait();
|
ctx.Chat.ContextAccess.Wait();
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue