Better connection lost detection

To detect that the TCP connection has been lost, try sending a small
packet every ~10 seconds. If the connection is lost, it will then throw
an exception which will allow MCC to detect that connection is lost, and
eventually properly trigger the AutoRelog bot.
- See issue #41 -
This commit is contained in:
ORelio 2014-08-11 12:38:39 +02:00
parent 774043fddb
commit f99efb5177
2 changed files with 24 additions and 2 deletions

View file

@ -44,9 +44,20 @@ namespace MinecraftClient.Protocol.Handlers
private void Updater()
{
int keep_alive_interval = 100;
int keep_alive_timer = 100;
try
{
do { Thread.Sleep(100); }
do
{
Thread.Sleep(100);
keep_alive_timer--;
if (keep_alive_timer <= 0)
{
Send(getPaddingPacket());
keep_alive_timer = keep_alive_interval;
}
}
while (Update());
}
catch (System.IO.IOException) { }