You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-19 00:26:30 +09:00
Added code to prevent multiple connection approval messages from being spawned and more sending serverfull when connections + pending connections exceed maxconnections
This commit is contained in:
@@ -519,12 +519,32 @@ namespace Lidgren.Network
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ok, someone wants to connect to us, and we're accepting connections!
|
// ok, someone wants to connect to us, and we're accepting connections!
|
||||||
if (m_connections.Count >= m_configuration.MaximumConnections)
|
int reservedSlots = m_connections.Count;
|
||||||
|
if (m_pendingConnections != null)
|
||||||
|
reservedSlots += m_pendingConnections.Count;
|
||||||
|
if (reservedSlots >= m_configuration.MaximumConnections)
|
||||||
{
|
{
|
||||||
HandleServerFull(senderEndpoint);
|
HandleServerFull(senderEndpoint);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isAlreadyPending = false;
|
||||||
|
if (m_pendingConnections != null)
|
||||||
|
{
|
||||||
|
// check so we don't already have a pending connection to this endpoint
|
||||||
|
foreach (NetConnection conn in m_pendingConnections)
|
||||||
|
{
|
||||||
|
if (conn.RemoteEndpoint.Equals(senderEndpoint))
|
||||||
|
{
|
||||||
|
// Yes, we do.
|
||||||
|
isAlreadyPending = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isAlreadyPending)
|
||||||
|
{
|
||||||
NetConnection conn = new NetConnection(this, senderEndpoint);
|
NetConnection conn = new NetConnection(this, senderEndpoint);
|
||||||
conn.m_connectionInitiator = false;
|
conn.m_connectionInitiator = false;
|
||||||
conn.m_connectInitationTime = NetTime.Now;
|
conn.m_connectInitationTime = NetTime.Now;
|
||||||
@@ -538,6 +558,7 @@ namespace Lidgren.Network
|
|||||||
}
|
}
|
||||||
|
|
||||||
AcceptConnection(conn);
|
AcceptConnection(conn);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LogWarning("Received unconnected library message of type " + libType);
|
LogWarning("Received unconnected library message of type " + libType);
|
||||||
|
|||||||
Reference in New Issue
Block a user