Small fix
This commit is contained in:
@ -135,7 +135,7 @@ namespace CoopServer
|
|||||||
/// We try to remove the client when all files have been sent
|
/// We try to remove the client when all files have been sent
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="nethandle"></param>
|
/// <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)
|
public static void TryToRemoveClient(long nethandle, int id)
|
||||||
{
|
{
|
||||||
lock (_clients)
|
lock (_clients)
|
||||||
@ -146,12 +146,14 @@ namespace CoopServer
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (client.IsCurrentFile(id))
|
||||||
|
{
|
||||||
client.FilePosition++;
|
client.FilePosition++;
|
||||||
|
}
|
||||||
|
|
||||||
if (client.DownloadComplete())
|
if (client.DownloadComplete())
|
||||||
{
|
{
|
||||||
client.Finish();
|
AddClientToRemove(client.NetHandle);
|
||||||
_clients.Remove(client);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -159,11 +161,14 @@ namespace CoopServer
|
|||||||
public static void AddClientToRemove(long nethandle)
|
public static void AddClientToRemove(long nethandle)
|
||||||
{
|
{
|
||||||
lock (_clientsToDelete)
|
lock (_clientsToDelete)
|
||||||
|
{
|
||||||
|
if (!_clientsToDelete.Contains(nethandle))
|
||||||
{
|
{
|
||||||
_clientsToDelete.Add(nethandle);
|
_clientsToDelete.Add(nethandle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal class DownloadClient
|
internal class DownloadClient
|
||||||
{
|
{
|
||||||
@ -253,6 +258,11 @@ namespace CoopServer
|
|||||||
Server.MainNetServer.SendMessage(outgoingMessage, conn, NetDeliveryMethod.ReliableUnordered, (byte)ConnectionChannel.File);
|
Server.MainNetServer.SendMessage(outgoingMessage, conn, NetDeliveryMethod.ReliableUnordered, (byte)ConnectionChannel.File);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsCurrentFile(int id)
|
||||||
|
{
|
||||||
|
return _files[FilePosition].FileID == id;
|
||||||
|
}
|
||||||
|
|
||||||
public bool DownloadComplete()
|
public bool DownloadComplete()
|
||||||
{
|
{
|
||||||
return FilePosition >= _files.Count;
|
return FilePosition >= _files.Count;
|
||||||
|
Reference in New Issue
Block a user