You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-17 23:56:30 +09:00
NetClient.Connect() now prevents new connection if one already exists
This commit is contained in:
@@ -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.
|
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
namespace Lidgren.Network
|
namespace Lidgren.Network
|
||||||
{
|
{
|
||||||
@@ -52,6 +53,19 @@ namespace Lidgren.Network
|
|||||||
config.AcceptIncomingConnections = false;
|
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>
|
/// <summary>
|
||||||
/// Disconnect from server
|
/// Disconnect from server
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ namespace Lidgren.Network
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a connection to a remote endpoint
|
/// Create a connection to a remote endpoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public NetConnection Connect(IPEndPoint remoteEndpoint, NetOutgoingMessage approvalMessage)
|
public virtual NetConnection Connect(IPEndPoint remoteEndpoint, NetOutgoingMessage approvalMessage)
|
||||||
{
|
{
|
||||||
lock (m_connections)
|
lock (m_connections)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user