Add connection timeout using server keepalives

Vanilla client will consider that connection has been lost
when no server keepalive was received during the last 30 seconds.
This commit implements a similar mechanism in MCC. See #802
This commit is contained in:
ORelio 2019-09-15 17:01:53 +02:00
parent 1406c00abd
commit 877e50579d
4 changed files with 61 additions and 6 deletions

View file

@ -185,6 +185,7 @@ namespace MinecraftClient.Protocol.Handlers
{
case PacketIncomingType.KeepAlive:
SendPacket(PacketOutgoingType.KeepAlive, packetData);
handler.OnServerKeepAlive();
break;
case PacketIncomingType.JoinGame:
handler.OnGameJoined();
@ -481,7 +482,7 @@ namespace MinecraftClient.Protocol.Handlers
byte slots = dataTypes.ReadNextByte(packetData);
Inventory inventory = new Inventory(windowID, inventoryType, title, slots);
handler.onInventoryOpen(inventory);
handler.OnInventoryOpen(inventory);
}
break;
case PacketIncomingType.CloseWindow:
@ -489,7 +490,7 @@ namespace MinecraftClient.Protocol.Handlers
{
byte windowID = dataTypes.ReadNextByte(packetData);
handler.onInventoryClose(windowID);
handler.OnInventoryClose(windowID);
}
break;
case PacketIncomingType.WindowItems: