]> git.deb.at Git - rhonda/impostor.hazel.git/commitdiff
Remove unused timeout param from ConnectAsync
authorForest <forest@innersloth.com>
Fri, 17 Jan 2020 23:04:20 +0000 (15:04 -0800)
committerForest <forest@innersloth.com>
Fri, 17 Jan 2020 23:04:20 +0000 (15:04 -0800)
Hazel/Connection.cs
Hazel/ConnectionListener.cs
Hazel/FewerThreads/UdpConnectionListener2.cs
Hazel/FewerThreads/UdpServerConnection2.cs
Hazel/Udp/UdpClientConnection.cs
Hazel/Udp/UdpConnection.KeepAlive.cs
Hazel/Udp/UdpConnectionListener.cs
Hazel/Udp/UdpServerConnection.cs
Hazel/Udp/UnityUdpClientConnection.cs

index b5bfe334c7ee1c26854cc0b383235c04a0fb8d33..d1194cd4ec93eb393d499d81a934f21c99d0b113 100644 (file)
@@ -169,8 +169,7 @@ namespace Hazel
         ///     This method does not block.
         /// </summary>
         /// <param name="bytes">The bytes of data to send in the handshake.</param>
-        /// <param name="timeout">The number of milliseconds to wait before giving up on the connect attempt.</param>
-        public abstract void ConnectAsync(byte[] bytes = null, int timeout = 5000);
+        public abstract void ConnectAsync(byte[] bytes = null);
 
         /// <summary>
         ///     Invokes the DataReceived event.
index b4b852fef2ae7ed2ac10cb848f36ca6a86ed6b9e..3facfe2050af1ac1ad588586a4173dbfe9df9e3b 100644 (file)
@@ -29,10 +29,8 @@ namespace Hazel
         ///         client.
         ///     </para>
         ///     <para>
-        ///         Hazel doesn't store connections so it is your responsibility to keep track of the connections to your 
-        ///         server. Note that as <see cref="Connection"/> implements <see cref="IDisposable"/> if you are not storing
-        ///         a connection then as a bare minimum you should call <see cref="Connection.Dispose()"/> here in order to 
-        ///         release the connection correctly.
+        ///         Hazel may or may not store connections so it is your responsibility to keep track and properly Dispose of 
+        ///         connections to your server. 
         ///     </para>
         ///     <include file="DocInclude/common.xml" path="docs/item[@name='Event_Thread_Safety_Warning']/*" />
         /// </remarks>
@@ -81,18 +79,6 @@ namespace Hazel
             }
         }
 
-        /// <summary>
-        ///     Closes the connection listener safely.
-        /// </summary>
-        /// <remarks>
-        ///     Internally this simply calls Dispose therefore trying to reuse the ConnectionListener after calling Close will
-        ///     cause ObjectDisposedExceptions.
-        /// </remarks>
-        public virtual void Close()
-        {
-            Dispose();
-        }
-
         /// <summary>
         ///     Call to dispose of the connection listener.
         /// </summary>
index 52d65da1ffb2038378428247539433c5d8f31e92..d4e88765931f3285cde7de15470fa98eb55cb69c 100644 (file)
@@ -289,7 +289,6 @@ namespace Hazel.Udp.FewerThreads
             return this.allConnections.TryRemove(endPoint, out var conn);
         }
 
-        /// <inheritdoc />
         protected virtual void Dispose(bool disposing)
         {
             foreach (var kvp in this.allConnections)
index fd5ca4f175e7121b448143534ebde5b9e47307d8..c5e679520163d4948481bf6e2277386d6f11aca5 100644 (file)
@@ -57,7 +57,7 @@ namespace Hazel.Udp.FewerThreads
         /// <remarks>
         ///     This will always throw a HazelException.
         /// </remarks>
-        public override void ConnectAsync(byte[] bytes = null, int timeout = 5000)
+        public override void ConnectAsync(byte[] bytes = null)
         {
             throw new InvalidOperationException("Cannot manually connect a UdpServerConnection, did you mean to use UdpClientConnection?");
         }
index de40a39d6c034e536e9475509269f1291107d05c..4500fe56bbb01baa2d9a3b08444c7f4884d4754a 100644 (file)
@@ -123,7 +123,7 @@ namespace Hazel.Udp
         /// <inheritdoc />
         public override void Connect(byte[] bytes = null, int timeout = 5000)
         {
-            this.ConnectAsync(bytes, timeout);
+            this.ConnectAsync(bytes);
 
             //Wait till hello packet is acknowledged and the state is set to Connected
             bool timedOut = !WaitOnConnect(timeout);
@@ -137,7 +137,7 @@ namespace Hazel.Udp
         }
 
         /// <inheritdoc />
-        public override void ConnectAsync(byte[] bytes = null, int timeout = 5000)
+        public override void ConnectAsync(byte[] bytes = null)
         {
             this.State = ConnectionState.Connecting;
 
index 69ceac21abd77a55a89f318af560c40378c40e2f..8d55f05329a48bc4f9418a044eaa15c494c8d05e 100644 (file)
@@ -76,6 +76,8 @@ namespace Hazel.Udp
             keepAliveTimer = new Timer(
                 (o) =>
                 {
+                    if (this.State != ConnectionState.Connected) return;
+
                     if (this.pingsSinceAck >= this.MissingPingsUntilDisconnect)
                     {
                         this.DisposeKeepAliveTimer();
index 03bc5df04b42ccb0c7757c477ee16ddd46189b2d..5570ae69c0d892e26e718bf4f269a066251e8836 100644 (file)
@@ -213,10 +213,9 @@ namespace Hazel.Udp
                 }
             }
 
-            //Inform the connection of the buffer (new connections need to send an ack back to client)
-            connection.HandleReceive(message, bytesReceived);
-            
-            //If it's a new connection invoke the NewConnection event.
+            // If it's a new connection invoke the NewConnection event.
+            // This needs to happen before handling the message because in localhost scenarios, the ACK and
+            // subsequent messages can happen before the NewConnection event sets up OnDataRecieved handlers
             if (!aware)
             {
                 // Skip header and hello byte;
@@ -225,7 +224,11 @@ namespace Hazel.Udp
                 message.Position = 0;
                 InvokeNewConnection(message, connection);
             }
-            else if (isHello)
+
+            //Inform the connection of the buffer (new connections need to send an ack back to client)
+            connection.HandleReceive(message, bytesReceived);
+
+            if (aware && isHello)
             {
                 message.Recycle();
             }
index 5641ca3d95c08913d1aa8a438f9a6b6261f4ff40..32093c17924b1c7bae7ebb5472783ed4eeab50c1 100644 (file)
@@ -55,7 +55,7 @@ namespace Hazel.Udp
         /// <remarks>
         ///     This will always throw a HazelException.
         /// </remarks>
-        public override void ConnectAsync(byte[] bytes = null, int timeout = 5000)
+        public override void ConnectAsync(byte[] bytes = null)
         {
             throw new InvalidOperationException("Cannot manually connect a UdpServerConnection, did you mean to use UdpClientConnection?");
         }
index ff92ea58ae68e49ab5c9e0545292197ace97c2b4..4f4640f9a781cae815954e29a0327bd715faceb4 100644 (file)
@@ -83,7 +83,7 @@ namespace Hazel.Udp
         }
 
         /// <inheritdoc />
-        public override void ConnectAsync(byte[] bytes = null, int timeout = 5000)
+        public override void ConnectAsync(byte[] bytes = null)
         {
             this.State = ConnectionState.Connecting;
 
@@ -122,8 +122,9 @@ namespace Hazel.Udp
             SendHello(bytes, () =>
             {
                 this.State = ConnectionState.Connected;
-                this.InitializeKeepAliveTimer();
             });
+
+            this.InitializeKeepAliveTimer();
         }
 
         /// <summary>