From: Forest Date: Mon, 6 Jul 2020 22:04:15 +0000 (-0700) Subject: More testing, some fixes X-Git-Tag: 1.0.0~27^2~6 X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=2792ba2b18663055e8687bef671179f2d7579e41;p=rhonda%2Fimpostor.hazel.git More testing, some fixes --- diff --git a/Hazel.UnitTests/Hazel.UnitTests.csproj b/Hazel.UnitTests/Hazel.UnitTests.csproj index b2e55e3..45305af 100644 --- a/Hazel.UnitTests/Hazel.UnitTests.csproj +++ b/Hazel.UnitTests/Hazel.UnitTests.csproj @@ -61,9 +61,11 @@ + + diff --git a/Hazel/Udp/UdpConnection.Reliable.cs b/Hazel/Udp/UdpConnection.Reliable.cs index f09c432..649f166 100644 --- a/Hazel/Udp/UdpConnection.Reliable.cs +++ b/Hazel/Udp/UdpConnection.Reliable.cs @@ -221,7 +221,7 @@ namespace Hazel.Udp /// The buffer to attach to. /// The offset to attach at. /// The callback to make once the packet has been acknowledged. - private void AttachReliableID(byte[] buffer, int offset, int sendLength, Action ackCallback = null) + protected void AttachReliableID(byte[] buffer, int offset, int sendLength, Action ackCallback = null) { ushort id = (ushort)Interlocked.Increment(ref lastIDAllocated); @@ -257,24 +257,11 @@ namespace Hazel.Udp /// The byte array to write to. /// The callback to make once the packet has been acknowledged. private void ReliableSend(byte sendOption, byte[] data, Action ackCallback = null) - { - this.ReliableSend(sendOption, data, 0, data.Length, ackCallback); - } - - /// - /// Sends the bytes reliably and stores the send. - /// - /// - /// The byte array to write to. - /// - /// - /// The callback to make once the packet has been acknowledged. - private void ReliableSend(byte sendOption, byte[] data, int offset, int length, Action ackCallback = null) { //Inform keepalive not to send for a while ResetKeepAliveTimer(); - byte[] bytes = new byte[length + 3]; + byte[] bytes = new byte[data.Length + 3]; //Add message type bytes[0] = sendOption; @@ -283,12 +270,12 @@ namespace Hazel.Udp AttachReliableID(bytes, 1, bytes.Length, ackCallback); //Copy data into new array - Buffer.BlockCopy(data, offset, bytes, bytes.Length - length, length); + Buffer.BlockCopy(data, 0, bytes, bytes.Length - data.Length, data.Length); //Write to connection WriteBytesToConnection(bytes, bytes.Length); - Statistics.LogReliableSend(length, bytes.Length); + Statistics.LogReliableSend(data.Length, bytes.Length); } /// diff --git a/Hazel/Udp/UnityUdpClientConnection.cs b/Hazel/Udp/UnityUdpClientConnection.cs index 2e217d8..fb5a57a 100644 --- a/Hazel/Udp/UnityUdpClientConnection.cs +++ b/Hazel/Udp/UnityUdpClientConnection.cs @@ -15,8 +15,6 @@ namespace Hazel.Udp { private Socket socket; - public EndPoint LocalEndpoint { get { return this.socket.LocalEndPoint; } } - public UnityUdpClientConnection(IPEndPoint remoteEndPoint, IPMode ipMode = IPMode.IPv4) : base() {