(61d00a474) v0.9.7.1

This commit is contained in:
Regalis
2020-03-04 13:04:10 +01:00
parent 3c50efa5c9
commit 3c09ebe02f
5086 changed files with 786063 additions and 295871 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;
}
}
}
}