This commit is contained in:
UnknownShadow200 2017-08-05 13:24:07 +10:00
parent ea5269ed59
commit db1fe40f90

View File

@ -111,8 +111,11 @@ namespace MCGalaxy.Network {
}
lock (sendLock) {
if (sendInProgress) { sendQueue.Enqueue(buffer); }
else { DoSendAsync(buffer); }
if (sendInProgress) {
sendQueue.Enqueue(buffer);
} else {
if (!DoSendAsync(buffer)) sendInProgress = false;
}
}
} catch (SocketException) {
player.Disconnect();
@ -152,6 +155,8 @@ namespace MCGalaxy.Network {
// DoSendAsync returns false if SendAsync completed sync
// If that happens, SendCallback isn't called so we need to send data here instead
if (s.DoSendAsync(s.sendQueue.Dequeue())) return;
if (s.player.disconnected) s.sendQueue.Clear();
}
}
} catch (SocketException) {