(6c8ca4a55) Tester's build, January 20th 2020

This commit is contained in:
Juan Pablo Arce
2020-01-20 11:35:15 -03:00
parent e6a08d715b
commit 4a58987eae
47 changed files with 852 additions and 248 deletions
@@ -59,10 +59,10 @@ namespace Barotrauma.Networking
{
shutDown = true;
readCancellationToken?.Cancel();
readCancellationToken?.Dispose();
readCancellationToken = null;
readThread?.Join(); readThread = null;
writeThread?.Join(); writeThread = null;
readCancellationToken?.Dispose();
readCancellationToken = null;
readStream?.Dispose(); readStream = null;
writeStream?.Dispose(); writeStream = null;
}
@@ -71,11 +71,11 @@ namespace Barotrauma.Networking
{
while (!shutDown)
{
Task<int> readTask = readStream.ReadAsync(tempBytes, 0, tempBytes.Length, readCancellationToken.Token);
Task<int> readTask = readStream?.ReadAsync(tempBytes, 0, tempBytes.Length, readCancellationToken.Token);
TimeSpan ts = TimeSpan.FromMilliseconds(15000);
if (!readTask.Wait(ts))
if (readTask == null || !readTask.Wait(ts))
{
readCancellationToken.Cancel();
readCancellationToken?.Cancel();
shutDown = true;
return;
}
@@ -142,8 +142,8 @@ namespace Barotrauma.Networking
byte[] lengthBytes = new byte[2];
lengthBytes[0] = (byte)(msg.Length & 0xFF);
lengthBytes[1] = (byte)((msg.Length >> 8) & 0xFF);
writeStream.Write(lengthBytes, 0, 2);
writeStream.Write(msg, 0, msg.Length);
writeStream?.Write(lengthBytes, 0, 2);
writeStream?.Write(msg, 0, msg.Length);
if (shutDown) { break; }