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

NetClient.Connect() now prevents new connection if one already exists

This commit is contained in:
lidgren
2010-07-18 12:13:26 +00:00
parent 1a66c6b76c
commit ced71204ac
2 changed files with 15 additions and 1 deletions

View File

@@ -17,6 +17,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
using System;
using System.Net;
namespace Lidgren.Network
{
@@ -52,6 +53,19 @@ namespace Lidgren.Network
config.AcceptIncomingConnections = false;
}
public override NetConnection Connect(IPEndPoint remoteEndpoint, NetOutgoingMessage approvalMessage)
{
lock(m_connections)
{
if (m_connections.Count > 0)
{
LogWarning("Connect attempt failed; Already connected");
return null;
}
}
return base.Connect(remoteEndpoint, approvalMessage);
}
/// <summary>
/// Disconnect from server
/// </summary>