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

@ -83,6 +83,7 @@ namespace MinecraftClient.Protocol.Handlers
{
case 0x00: byte[] keepalive = new byte[5] { 0, 0, 0, 0, 0 };
Receive(keepalive, 1, 4, SocketFlags.None);
handler.OnServerKeepAlive();
Send(keepalive); break;
case 0x01: readData(4); readNextString(); readData(5); break;
case 0x02: readData(1); readNextString(); readNextString(); readData(4); break;