mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +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
|
|
@ -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) { }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue