(e42047dc1) Tester's build, January 30th 2020

This commit is contained in:
Juan Pablo Arce
2020-01-30 15:56:31 -03:00
parent eaa18a20a3
commit 15499cb704
203 changed files with 8274 additions and 4950 deletions
+30
View File
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
namespace Lidgren.Network
{
@@ -66,5 +68,33 @@ namespace Lidgren.Network
{
return "[NetServer " + ConnectionsCount + " connections]";
}
/// <summary>
/// Changes the number of maximum allowed connections, closing existing ones if the limit is lowered below the current amount.
/// </summary>
public void ChangeMaximumConnections(int num)
{
m_configuration.ChangeMaximumConnectionsInternal(num);
int reservedSlots = m_handshakes.Count + m_connections.Count;
while (reservedSlots >= m_configuration.m_maximumConnections)
{
if (m_handshakes.Count > 0)
{
IPEndPoint endpoint = m_handshakes.Keys.Last();
// server full
NetOutgoingMessage full = CreateMessage("Server full");
full.m_messageType = NetMessageType.Disconnect;
SendLibrary(full, endpoint);
}
else
{
m_connections.Last().Disconnect("Server full");
}
reservedSlots = m_handshakes.Count + m_connections.Count;
}
}
}
}