1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-06 02:11:06 +09:00

Fixed AcceptIncomingConnections = false actualling having an effect

This commit is contained in:
lidgren
2013-05-07 07:37:27 +00:00
parent c5ca1879a0
commit f32e40d048

View File

@@ -614,8 +614,31 @@ namespace Lidgren.Network
LogWarning("Received unhandled library message " + tp + " from " + senderEndPoint);
return;
case NetMessageType.Connect:
// proceed
break;
if (m_configuration.AcceptIncomingConnections == false)
{
LogWarning("Received Connect, but we're not accepting incoming connections!");
return;
}
// handle connect
// It's someone wanting to shake hands with us!
int reservedSlots = m_handshakes.Count + m_connections.Count;
if (reservedSlots >= m_configuration.m_maximumConnections)
{
// server full
NetOutgoingMessage full = CreateMessage("Server full");
full.m_messageType = NetMessageType.Disconnect;
SendLibrary(full, senderEndPoint);
return;
}
// Ok, start handshake!
NetConnection conn = new NetConnection(this, senderEndPoint);
conn.m_status = NetConnectionStatus.ReceivedInitiation;
m_handshakes.Add(senderEndPoint, conn);
conn.ReceivedHandshake(now, tp, ptr, payloadByteLength);
return;
case NetMessageType.Disconnect:
// this is probably ok
LogVerbose("Received Disconnect from unconnected source: " + senderEndPoint);
@@ -624,26 +647,6 @@ namespace Lidgren.Network
LogWarning("Received unhandled library message " + tp + " from " + senderEndPoint);
return;
}
// It's someone wanting to shake hands with us!
int reservedSlots = m_handshakes.Count + m_connections.Count;
if (reservedSlots >= m_configuration.m_maximumConnections)
{
// server full
NetOutgoingMessage full = CreateMessage("Server full");
full.m_messageType = NetMessageType.Disconnect;
SendLibrary(full, senderEndPoint);
return;
}
// Ok, start handshake!
NetConnection conn = new NetConnection(this, senderEndPoint);
conn.m_status = NetConnectionStatus.ReceivedInitiation;
m_handshakes.Add(senderEndPoint, conn);
conn.ReceivedHandshake(now, tp, ptr, payloadByteLength);
return;
}
internal void AcceptConnection(NetConnection conn)