Reduce the latency of sending messages

This commit is contained in:
BruceChen 2022-08-31 22:52:05 +08:00
parent 98dd645fb5
commit a13af47b3e
2 changed files with 29 additions and 12 deletions

View file

@ -229,14 +229,22 @@ namespace MinecraftClient.Protocol.Handlers
{
try
{
while (socketWrapper.HasDataAvailable() && !cancelToken.IsCancellationRequested)
while (socketWrapper.HasDataAvailable())
{
packetQueue.Add(ReadNextPacket());
if (cancelToken.IsCancellationRequested)
break;
}
}
catch (System.IO.IOException) { break; }
catch (SocketException) { break; }
catch (NullReferenceException) { break; }
catch (Ionic.Zlib.ZlibException) { break; }
if (cancelToken.IsCancellationRequested)
break;
Thread.Sleep(10);
}
packetQueue.CompleteAdding();