]> git.deb.at Git - rhonda/impostor.hazel.git/commitdiff
Tidied ConnectionListener code a little
authorJamJar00 <jamster.30@btinternet.com>
Sat, 21 Jan 2017 17:27:44 +0000 (17:27 +0000)
committerJamJar00 <jamster.30@btinternet.com>
Sat, 21 Jan 2017 17:27:44 +0000 (17:27 +0000)
Hazel/Udp/UdpConnection.cs
Hazel/Udp/UdpConnectionListener.cs
Hazel/Udp/UdpServerConnection.cs

index d724be9b60348a62241b6fdb255ce27f67fcec37..6f97d2d5e32ab03e0567d8db123c05f3df37a526 100644 (file)
@@ -82,7 +82,7 @@ namespace Hazel.Udp
         ///     Handles the receiving of data.
         /// </summary>
         /// <param name="buffer">The buffer containing the bytes received.</param>
-        protected void HandleReceive(byte[] buffer)
+        protected internal void HandleReceive(byte[] buffer)
         {
             //Inform keepalive not to send for a while
             ResetKeepAliveTimer();
index 21dfaf780fcc5bec0493acf227c965d17a798083..1d1a1e6cb079da238e86f120ccea31231f89d78f 100644 (file)
@@ -166,18 +166,14 @@ namespace Hazel.Udp
 
                     connection = new UdpServerConnection(this, remoteEndPoint, IPMode);
                     connections.Add(remoteEndPoint, connection);
-
-                    //Then ping back an ack to make sure they're happy (unless we rejected them...)
-                    connection.SendAck(buffer[1], buffer[2]);
                 }
             }
 
-            //And fire the corresponding event
-            if (aware)
-            {
-                connection.InvokeDataReceived(buffer);
-            }
-            else
+            //Inform the connection of the buffer (new connections need to send an ack back to client)
+            connection.HandleReceive(buffer);
+            
+            //If it's a new connection invoke the NewConnection event.
+            if (!aware)
             {
                 byte[] dataBuffer = new byte[buffer.Length - 1];
                 Buffer.BlockCopy(buffer, 1, dataBuffer, 0, buffer.Length - 1);
index 1eb2afea948bcf9430fe2dc40a8da3ee7cead576..566bf1ec9c744d8d7deb837ebea1e80bb7964884 100644 (file)
@@ -65,15 +65,6 @@ namespace Hazel.Udp
             throw new HazelException("Cannot manually connect a UdpServerConnection, did you mean to use UdpClientConnection?");
         }
 
-        /// <summary>
-        ///     Called by the listener when we have data.
-        /// </summary>
-        /// <param name="buffer"></param>
-        internal void InvokeDataReceived(byte[] buffer)
-        {
-           HandleReceive(buffer);
-        }
-
         /// <inheritdoc />
         protected override void HandleDisconnect(HazelException e = null)
         {