From d11dcbe2571f1ade2047dad9a083c3715bc97b8b Mon Sep 17 00:00:00 2001 From: lidgren Date: Fri, 6 Jul 2012 18:29:57 +0000 Subject: [PATCH] Invalid warning message about status fixed --- Lidgren.Network/NetConnection.Handshake.cs | 2 +- Lidgren.Network/NetConnectionStatus.cs | 5 +++++ Lidgren.Network/NetPeer.Internal.cs | 1 + Lidgren.Network/NetPeer.cs | 4 ++-- Samples/Chat/ChatClient/Form1.Designer.cs | 2 +- Samples/Chat/ChatClient/Program.cs | 4 ++++ 6 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Lidgren.Network/NetConnection.Handshake.cs b/Lidgren.Network/NetConnection.Handshake.cs index e8b9114..eb1f903 100644 --- a/Lidgren.Network/NetConnection.Handshake.cs +++ b/Lidgren.Network/NetConnection.Handshake.cs @@ -270,7 +270,7 @@ namespace Lidgren.Network switch (tp) { case NetMessageType.Connect: - if (m_status == NetConnectionStatus.None) + if (m_status == NetConnectionStatus.ReceivedInitiation) { // Whee! Server full has already been checked bool ok = ValidateHandshakeData(ptr, payloadLength, out hail); diff --git a/Lidgren.Network/NetConnectionStatus.cs b/Lidgren.Network/NetConnectionStatus.cs index 0821638..ff2d61d 100644 --- a/Lidgren.Network/NetConnectionStatus.cs +++ b/Lidgren.Network/NetConnectionStatus.cs @@ -35,6 +35,11 @@ namespace Lidgren.Network /// InitiatedConnect, + /// + /// Connect was received, but ConnectResponse hasn't been sent yet + /// + ReceivedInitiation, + /// /// Connect was received and ApprovalMessage released to the application; awaiting Approve() or Deny() /// diff --git a/Lidgren.Network/NetPeer.Internal.cs b/Lidgren.Network/NetPeer.Internal.cs index c796039..2a7a876 100644 --- a/Lidgren.Network/NetPeer.Internal.cs +++ b/Lidgren.Network/NetPeer.Internal.cs @@ -623,6 +623,7 @@ namespace Lidgren.Network // 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); diff --git a/Lidgren.Network/NetPeer.cs b/Lidgren.Network/NetPeer.cs index 14441b5..4cc57d4 100644 --- a/Lidgren.Network/NetPeer.cs +++ b/Lidgren.Network/NetPeer.cs @@ -265,7 +265,7 @@ namespace Lidgren.Network if (m_handshakes.TryGetValue(remoteEndpoint, out hs)) { // already trying to connect to that endpoint; make another try - switch (hs.Status) + switch (hs.m_status) { case NetConnectionStatus.InitiatedConnect: // send another connect @@ -277,7 +277,7 @@ namespace Lidgren.Network break; default: // weird - LogWarning("Weird situation; Connect() already in progress to remote endpoint; but hs status is " + hs.Status); + LogWarning("Weird situation; Connect() already in progress to remote endpoint; but hs status is " + hs.m_status); break; } return hs; diff --git a/Samples/Chat/ChatClient/Form1.Designer.cs b/Samples/Chat/ChatClient/Form1.Designer.cs index 4e594c1..ff6e1b3 100644 --- a/Samples/Chat/ChatClient/Form1.Designer.cs +++ b/Samples/Chat/ChatClient/Form1.Designer.cs @@ -136,7 +136,7 @@ private System.Windows.Forms.Button button1; private System.Windows.Forms.TextBox textBox1; - private System.Windows.Forms.Button button2; + public System.Windows.Forms.Button button2; public System.Windows.Forms.RichTextBox richTextBox1; public System.Windows.Forms.TextBox textBox2; public System.Windows.Forms.TextBox textBox3; diff --git a/Samples/Chat/ChatClient/Program.cs b/Samples/Chat/ChatClient/Program.cs index 4b1c230..2076a9a 100644 --- a/Samples/Chat/ChatClient/Program.cs +++ b/Samples/Chat/ChatClient/Program.cs @@ -59,6 +59,10 @@ namespace ChatClient s_form.EnableInput(); else s_form.DisableInput(); + + if (status == NetConnectionStatus.Disconnected) + s_form.button2.Text = "Connect"; + string reason = im.ReadString(); Output(status.ToString() + ": " + reason);