]> git.deb.at Git - rhonda/impostor.hazel.git/commitdiff
More testing, some fixes
authorForest <forest@innersloth.com>
Mon, 6 Jul 2020 22:04:15 +0000 (15:04 -0700)
committerForest <forest@innersloth.com>
Mon, 6 Jul 2020 22:04:15 +0000 (15:04 -0700)
Hazel.UnitTests/Hazel.UnitTests.csproj
Hazel/Udp/UdpConnection.Reliable.cs
Hazel/Udp/UnityUdpClientConnection.cs

index b2e55e30f06c855818923f3b583fe06333256907..45305afbf55367ccc7fda4c025e4af63c26c2bf5 100644 (file)
     <Compile Include="StatisticsTests.cs" />
     <Compile Include="TestHelper.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="UdpConnectionTestHarness.cs" />
     <Compile Include="UdpConnectionTests.cs" />
     <Compile Include="MessageWriterTests.cs" />
     <Compile Include="StressTests.cs" />
+    <Compile Include="UdpReliabilityTests.cs" />
     <Compile Include="UPnPTests.cs" />
   </ItemGroup>
   <ItemGroup>
index f09c432e988d872502a55cc163bdfb0afb929a9a..649f166e1dbac6a07b1572e9f6578750df4a0c8f 100644 (file)
@@ -221,7 +221,7 @@ namespace Hazel.Udp
         /// <param name="buffer">The buffer to attach to.</param>
         /// <param name="offset">The offset to attach at.</param>
         /// <param name="ackCallback">The callback to make once the packet has been acknowledged.</param>
-        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
         /// <param name="data">The byte array to write to.</param>
         /// <param name="ackCallback">The callback to make once the packet has been acknowledged.</param>
         private void ReliableSend(byte sendOption, byte[] data, Action ackCallback = null)
-        {
-            this.ReliableSend(sendOption, data, 0, data.Length, ackCallback);
-        }
-
-        /// <summary>
-        ///     Sends the bytes reliably and stores the send.
-        /// </summary>
-        /// <param name="sendOption"></param>
-        /// <param name="data">The byte array to write to.</param>
-        /// <param name="offset"></param>
-        /// <param name="length"></param>
-        /// <param name="ackCallback">The callback to make once the packet has been acknowledged.</param>
-        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);
         }
 
         /// <summary>
index 2e217d870e5951a850464205c46ad8c8e2d933db..fb5a57aaa78a2d460ccdf0de3de68bce487e8f3f 100644 (file)
@@ -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()
         {