From: JamJar00 Date: Sat, 21 Jan 2017 17:27:44 +0000 (+0000) Subject: Tidied ConnectionListener code a little X-Git-Tag: 1.0.0~107 X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=6451a7c126e1763d31815d1ff277f196309eb843;p=rhonda%2Fimpostor.hazel.git Tidied ConnectionListener code a little --- diff --git a/Hazel/Udp/UdpConnection.cs b/Hazel/Udp/UdpConnection.cs index d724be9..6f97d2d 100644 --- a/Hazel/Udp/UdpConnection.cs +++ b/Hazel/Udp/UdpConnection.cs @@ -82,7 +82,7 @@ namespace Hazel.Udp /// Handles the receiving of data. /// /// The buffer containing the bytes received. - protected void HandleReceive(byte[] buffer) + protected internal void HandleReceive(byte[] buffer) { //Inform keepalive not to send for a while ResetKeepAliveTimer(); diff --git a/Hazel/Udp/UdpConnectionListener.cs b/Hazel/Udp/UdpConnectionListener.cs index 21dfaf7..1d1a1e6 100644 --- a/Hazel/Udp/UdpConnectionListener.cs +++ b/Hazel/Udp/UdpConnectionListener.cs @@ -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); diff --git a/Hazel/Udp/UdpServerConnection.cs b/Hazel/Udp/UdpServerConnection.cs index 1eb2afe..566bf1e 100644 --- a/Hazel/Udp/UdpServerConnection.cs +++ b/Hazel/Udp/UdpServerConnection.cs @@ -65,15 +65,6 @@ namespace Hazel.Udp throw new HazelException("Cannot manually connect a UdpServerConnection, did you mean to use UdpClientConnection?"); } - /// - /// Called by the listener when we have data. - /// - /// - internal void InvokeDataReceived(byte[] buffer) - { - HandleReceive(buffer); - } - /// protected override void HandleDisconnect(HazelException e = null) {