Add timeout for SpigotMC, Fix bot update

- We need to send a MC 1.6 ping first but SpigotMC ignore them
- So a timeout is necessary. Too slow old servers might suffer
- Fix bots not beign updated by Protocol16 (MC 1.4 to 1.6)
This commit is contained in:
ORelio 2014-05-31 13:47:34 +02:00
parent c8332eb845
commit 850ff7ad0b

View file

@ -55,6 +55,7 @@ namespace MinecraftClient.Protocol.Handlers
private bool Update() private bool Update()
{ {
handler.OnUpdate();
bool connection_ok = true; bool connection_ok = true;
while (c.Client.Available > 0 && connection_ok) while (c.Client.Available > 0 && connection_ok)
{ {
@ -651,6 +652,7 @@ namespace MinecraftClient.Protocol.Handlers
try try
{ {
TcpClient tcp = ProxyHandler.newTcpClient(host, port); TcpClient tcp = ProxyHandler.newTcpClient(host, port);
tcp.ReceiveTimeout = 5000; //MC 1.7.2+ SpigotMC servers won't answer, so we need a reasonable timeout.
byte[] ping = new byte[2] { 0xfe, 0x01 }; byte[] ping = new byte[2] { 0xfe, 0x01 };
tcp.Client.Send(ping, SocketFlags.None); tcp.Client.Send(ping, SocketFlags.None);