mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
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:
parent
774043fddb
commit
f99efb5177
2 changed files with 24 additions and 2 deletions
|
|
@ -41,9 +41,20 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
|
|
||||||
private void Updater()
|
private void Updater()
|
||||||
{
|
{
|
||||||
|
int keep_alive_interval = 100;
|
||||||
|
int keep_alive_timer = 100;
|
||||||
try
|
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());
|
while (Update());
|
||||||
}
|
}
|
||||||
catch (System.IO.IOException) { }
|
catch (System.IO.IOException) { }
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,20 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
|
|
||||||
private void Updater()
|
private void Updater()
|
||||||
{
|
{
|
||||||
|
int keep_alive_interval = 100;
|
||||||
|
int keep_alive_timer = 100;
|
||||||
try
|
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());
|
while (Update());
|
||||||
}
|
}
|
||||||
catch (System.IO.IOException) { }
|
catch (System.IO.IOException) { }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue