You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-16 15:16:33 +09:00
Added fix for delayed Approval
This commit is contained in:
@@ -76,11 +76,12 @@ namespace Lidgren.Network
|
||||
SendConnectResponse(now, true);
|
||||
break;
|
||||
case NetConnectionStatus.None:
|
||||
if (m_peerConfiguration.IsMessageTypeEnabled(NetIncomingMessageType.ConnectionApproval))
|
||||
break; // we're probably waiting for connection approval here
|
||||
m_peer.LogWarning("Time to resend handshake, but status is " + m_status);
|
||||
break;
|
||||
|
||||
case NetConnectionStatus.RespondedAwaitingApproval:
|
||||
// awaiting approval
|
||||
m_lastHandshakeSendTime = now; // postpone handshake resend
|
||||
break;
|
||||
default:
|
||||
m_peer.LogWarning("Time to resend handshake, but status is " + m_status);
|
||||
break;
|
||||
@@ -212,6 +213,12 @@ namespace Lidgren.Network
|
||||
/// </summary>
|
||||
public void Approve()
|
||||
{
|
||||
if (m_status != NetConnectionStatus.RespondedAwaitingApproval)
|
||||
{
|
||||
m_peer.LogWarning("Approve() called in wrong status; expected RespondedAwaitingApproval; got " + m_status);
|
||||
return;
|
||||
}
|
||||
|
||||
m_localHailMessage = null;
|
||||
m_handshakeAttempts = 0;
|
||||
SendConnectResponse((float)NetTime.Now, false);
|
||||
@@ -223,6 +230,12 @@ namespace Lidgren.Network
|
||||
/// <param name="localHail">The local hail message that will be set as RemoteHailMessage on the remote host</param>
|
||||
public void Approve(NetOutgoingMessage localHail)
|
||||
{
|
||||
if (m_status != NetConnectionStatus.RespondedAwaitingApproval)
|
||||
{
|
||||
m_peer.LogWarning("Approve() called in wrong status; expected RespondedAwaitingApproval; got " + m_status);
|
||||
return;
|
||||
}
|
||||
|
||||
m_localHailMessage = localHail;
|
||||
m_handshakeAttempts = 0;
|
||||
SendConnectResponse((float)NetTime.Now, false);
|
||||
@@ -283,6 +296,7 @@ namespace Lidgren.Network
|
||||
if (m_remoteHailMessage != null)
|
||||
appMsg.Write(m_remoteHailMessage.m_data, 0, m_remoteHailMessage.LengthBytes);
|
||||
m_peer.ReleaseMessage(appMsg);
|
||||
SetStatus(NetConnectionStatus.RespondedAwaitingApproval, "Awaiting approval");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -290,6 +304,11 @@ namespace Lidgren.Network
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (m_status == NetConnectionStatus.RespondedAwaitingApproval)
|
||||
{
|
||||
m_peer.LogWarning("Ignoring multiple Connect() most likely due to a delayed Approval");
|
||||
return;
|
||||
}
|
||||
if (m_status == NetConnectionStatus.RespondedConnect)
|
||||
{
|
||||
// our ConnectResponse must have been lost
|
||||
|
||||
@@ -35,6 +35,11 @@ namespace Lidgren.Network
|
||||
/// </summary>
|
||||
InitiatedConnect,
|
||||
|
||||
/// <summary>
|
||||
/// Connect was received and ApprovalMessage released to the application; awaiting Approve() or Deny()
|
||||
/// </summary>
|
||||
RespondedAwaitingApproval, // We got Connect, released ApprovalMessage
|
||||
|
||||
/// <summary>
|
||||
/// Connect was received and ConnectResponse has been sent; waiting for ConnectionEstablished
|
||||
/// </summary>
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Lidgren.Network
|
||||
//
|
||||
// excellent, right on time
|
||||
//
|
||||
m_peer.LogVerbose("Received RIGHT-ON-TIME " + message);
|
||||
//m_peer.LogVerbose("Received RIGHT-ON-TIME " + message);
|
||||
|
||||
AdvanceWindow();
|
||||
m_peer.ReleaseMessage(message);
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Lidgren.Network
|
||||
//
|
||||
// excellent, right on time
|
||||
//
|
||||
m_peer.LogVerbose("Received RIGHT-ON-TIME " + message);
|
||||
//m_peer.LogVerbose("Received RIGHT-ON-TIME " + message);
|
||||
|
||||
AdvanceWindow();
|
||||
m_peer.ReleaseMessage(message);
|
||||
|
||||
Reference in New Issue
Block a user