You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-17 15:46:33 +09:00
Fixed maximum handshake attempts one-off error
Fixed better disconnect messages when not yet fully connected (aborting connection attempt)
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
<ProductVersion>9.0.21022</ProductVersion>
|
<ProductVersion>9.0.30729</ProductVersion>
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
<ProjectGuid>{AE483C29-042E-4226-BA52-D247CE7676DA}</ProjectGuid>
|
<ProjectGuid>{AE483C29-042E-4226-BA52-D247CE7676DA}</ProjectGuid>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
@@ -55,7 +55,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Encryption\INetEncryption.cs" />
|
<Compile Include="Encryption\INetEncryption.cs" />
|
||||||
<Compile Include="Encryption\NetBCrypt.cs" />
|
|
||||||
<Compile Include="Encryption\NetBlockEncryptionBase.cs" />
|
<Compile Include="Encryption\NetBlockEncryptionBase.cs" />
|
||||||
<Compile Include="Encryption\NetXorEncryption.cs" />
|
<Compile Include="Encryption\NetXorEncryption.cs" />
|
||||||
<Compile Include="Encryption\NetXteaEncryption.cs" />
|
<Compile Include="Encryption\NetXteaEncryption.cs" />
|
||||||
|
|||||||
@@ -102,6 +102,17 @@ namespace Lidgren.Network
|
|||||||
NetConnection serverConnection = ServerConnection;
|
NetConnection serverConnection = ServerConnection;
|
||||||
if (serverConnection == null)
|
if (serverConnection == null)
|
||||||
{
|
{
|
||||||
|
lock (m_handshakes)
|
||||||
|
{
|
||||||
|
if (m_handshakes.Count > 0)
|
||||||
|
{
|
||||||
|
LogVerbose("Aborting connection attempt");
|
||||||
|
foreach(var hs in m_handshakes)
|
||||||
|
hs.Value.Disconnect(byeMessage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LogWarning("Disconnect requested when not connected!");
|
LogWarning("Disconnect requested when not connected!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ namespace Lidgren.Network
|
|||||||
|
|
||||||
if (now - m_lastHandshakeSendTime > m_peerConfiguration.m_resendHandshakeInterval)
|
if (now - m_lastHandshakeSendTime > m_peerConfiguration.m_resendHandshakeInterval)
|
||||||
{
|
{
|
||||||
if (m_handshakeAttempts > m_peerConfiguration.m_maximumHandshakeAttempts)
|
if (m_handshakeAttempts >= m_peerConfiguration.m_maximumHandshakeAttempts)
|
||||||
{
|
{
|
||||||
// failed to connect
|
// failed to connect
|
||||||
ExecuteDisconnect("Failed to establish connection - no response from remote host", true);
|
ExecuteDisconnect("Failed to establish connection - no response from remote host", true);
|
||||||
@@ -431,6 +431,7 @@ namespace Lidgren.Network
|
|||||||
if (m_status != NetConnectionStatus.Disconnected && m_status != NetConnectionStatus.None)
|
if (m_status != NetConnectionStatus.Disconnected && m_status != NetConnectionStatus.None)
|
||||||
SetStatus(NetConnectionStatus.Disconnecting, byeMessage);
|
SetStatus(NetConnectionStatus.Disconnecting, byeMessage);
|
||||||
|
|
||||||
|
m_handshakeAttempts = 0;
|
||||||
m_disconnectRequested = true;
|
m_disconnectRequested = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,9 +109,6 @@ namespace Lidgren.Network
|
|||||||
if (reason == null)
|
if (reason == null)
|
||||||
reason = string.Empty;
|
reason = string.Empty;
|
||||||
|
|
||||||
// new status equals potentially new handshake attempts
|
|
||||||
m_handshakeAttempts = 0;
|
|
||||||
|
|
||||||
if (m_status == NetConnectionStatus.Connected)
|
if (m_status == NetConnectionStatus.Connected)
|
||||||
{
|
{
|
||||||
m_timeoutDeadline = (float)NetTime.Now + m_peerConfiguration.m_connectionTimeout;
|
m_timeoutDeadline = (float)NetTime.Now + m_peerConfiguration.m_connectionTimeout;
|
||||||
|
|||||||
@@ -338,7 +338,12 @@ namespace Lidgren.Network
|
|||||||
public int MaximumHandshakeAttempts
|
public int MaximumHandshakeAttempts
|
||||||
{
|
{
|
||||||
get { return m_maximumHandshakeAttempts; }
|
get { return m_maximumHandshakeAttempts; }
|
||||||
set { m_maximumHandshakeAttempts = value; }
|
set
|
||||||
|
{
|
||||||
|
if (value < 1)
|
||||||
|
throw new NetException("MaximumHandshakeAttempts must be at least 1");
|
||||||
|
m_maximumHandshakeAttempts = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user