Small fix

This commit is contained in:
EntenKoeniq
2022-04-11 14:22:51 +02:00
parent 0bcca6b3af
commit 625ae2aa7b

View File

@ -135,7 +135,7 @@ namespace CoopServer
/// We try to remove the client when all files have been sent
/// </summary>
/// <param name="nethandle"></param>
/// <param name="id">Not currently used but maybe we can need this sometime</param>
/// <param name="id"></param>
public static void TryToRemoveClient(long nethandle, int id)
{
lock (_clients)
@ -146,12 +146,14 @@ namespace CoopServer
return;
}
client.FilePosition++;
if (client.IsCurrentFile(id))
{
client.FilePosition++;
}
if (client.DownloadComplete())
{
client.Finish();
_clients.Remove(client);
AddClientToRemove(client.NetHandle);
}
}
}
@ -160,7 +162,10 @@ namespace CoopServer
{
lock (_clientsToDelete)
{
_clientsToDelete.Add(nethandle);
if (!_clientsToDelete.Contains(nethandle))
{
_clientsToDelete.Add(nethandle);
}
}
}
}
@ -253,6 +258,11 @@ namespace CoopServer
Server.MainNetServer.SendMessage(outgoingMessage, conn, NetDeliveryMethod.ReliableUnordered, (byte)ConnectionChannel.File);
}
public bool IsCurrentFile(int id)
{
return _files[FilePosition].FileID == id;
}
public bool DownloadComplete()
{
return FilePosition >= _files.Count;