]> git.deb.at Git - rhonda/impostor.hazel.git/commitdiff
Improve debuggability, and maybe fix a case where the disconnect handler wasn't getti...
authorForest <chocozilla@gmail.com>
Thu, 13 Jun 2019 23:07:35 +0000 (16:07 -0700)
committerForest <chocozilla@gmail.com>
Thu, 13 Jun 2019 23:07:35 +0000 (16:07 -0700)
Hazel.UnitTests/UdpConnectionTests.cs
Hazel/Hazel.csproj
Hazel/NetworkConnection.cs
Hazel/ObjectPool.cs
Hazel/Udp/UdpClientConnection.cs
Hazel/Udp/UdpConnection.cs
Hazel/Udp/UdpServerConnection.cs

index 26352b5d4aa093c0e76f075954c4d9949e074561..d363a235071703b6d761ef54e7e6343ef9bd816a 100644 (file)
@@ -3,8 +3,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
 using System.Net;
 using System.Threading;
 using Hazel.Udp;
-using System.Linq;
-using System.Collections.Generic;
 
 namespace Hazel.UnitTests
 {
@@ -66,7 +64,7 @@ namespace Hazel.UnitTests
                 connection.Connect();
                 connection.Dispose();
 
-                Thread.Sleep(10);
+                Thread.Sleep(50);
 
                 Assert.IsTrue(serverConnected);
                 Assert.IsTrue(serverDisconnected);
index 6466a403b71b27967bb14d305a86e283428bd114..5114784dfffb8f62f816880e9228ae94e3fef72c 100644 (file)
@@ -25,6 +25,7 @@
     </DocumentationFile>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <Prefer32Bit>false</Prefer32Bit>
+    <LangVersion>7.3</LangVersion>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>pdbonly</DebugType>
@@ -37,6 +38,7 @@
     </DocumentationFile>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <Prefer32Bit>false</Prefer32Bit>
+    <LangVersion>7.3</LangVersion>
   </PropertyGroup>
   <PropertyGroup>
     <SignAssembly>true</SignAssembly>
@@ -54,6 +56,7 @@
     <PlatformTarget>AnyCPU</PlatformTarget>
     <ErrorReport>prompt</ErrorReport>
     <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+    <LangVersion>7.3</LangVersion>
   </PropertyGroup>
   <ItemGroup>
     <Reference Include="System" />
index 0a224a87c2a0533ec2693e28db77a5042224a999..c6426fc051df08d6e3b14d172cd29aacc203e79b 100644 (file)
@@ -40,18 +40,13 @@ namespace Hazel
         /// </summary>
         /// <param name="e">The exception if one was the cause.</param>
         public override void Disconnect(string reason)
-        {
-            this.Disconnect(reason, false);
-        }
-
-        protected void Disconnect(string reason, bool skipSendDisconnect)
         {
             bool invoke = false;
             lock (this)
             {
                 if (this._state == ConnectionState.Connected)
                 {
-                    this._state = skipSendDisconnect ? ConnectionState.NotConnected : ConnectionState.Disconnecting;
+                    this._state = ConnectionState.Disconnecting;
                     invoke = true;
                 }
             }
index 1b484159b7b8019b4aff299326eb3b469f028903..d508fbad79b4931e6ab71c0aa5ede4bd6d8b3f1c 100644 (file)
@@ -1,7 +1,5 @@
 using System;
 using System.Collections.Concurrent;
-using System.Linq;
-using System.Text;
 using System.Threading;
 
 namespace Hazel
@@ -54,7 +52,7 @@ namespace Hazel
 
             if (!inuse.TryAdd(item, true))
             {
-                throw new Exception("Duplicate pull");
+                throw new Exception("Duplicate pull " + typeof(T).Name);
             }
 
             return item;
@@ -72,7 +70,7 @@ namespace Hazel
             }
             else
             {
-                throw new Exception("Duplicate add");
+                throw new Exception("Duplicate add " + typeof(T).Name);
             }
         }
     }
index 16b7d155bcc8e836f698ceaaf1ac54ff6a259a27..a09f83040eee0750dfba0ae80221ff8b8a062e9f 100644 (file)
@@ -1,9 +1,6 @@
 using System;
-using System.Collections.Generic;
-using System.Linq;
 using System.Net;
 using System.Net.Sockets;
-using System.Text;
 using System.Threading;
 
 
@@ -100,7 +97,7 @@ namespace Hazel.Udp
             }
             catch (SocketException ex)
             {
-                Disconnect("Could not send data as a SocketException occured: " + ex.Message, true);
+                Disconnect("Could not send data as a SocketException occured: " + ex.Message);
             }
         }
 
@@ -117,7 +114,7 @@ namespace Hazel.Udp
             }
             catch (SocketException ex)
             {
-                Disconnect("Could not send data as a SocketException occured: " + ex.Message, true);
+                Disconnect("Could not send data as a SocketException occured: " + ex.Message);
             }
         }
 
index 051214e2348173aecee050f2006d51e2f2635478..c1e6cf4f7327b411d85a1606bc4d75f90cfa6a17 100644 (file)
@@ -128,7 +128,7 @@ namespace Hazel.Udp
                     break;
 
                 case (byte)UdpSendOption.Disconnect:
-                    Disconnect("The remote sent a disconnect request", true);
+                    Disconnect("The remote sent a disconnect request");
                     message.Recycle();
                     break;
                     
index fa15edbcba8c7243e009cac4b2ef36c07b8950bd..1d01c7606db39a1fc7ca2cb4185e0dd16c0645f6 100644 (file)
@@ -1,9 +1,5 @@
 using System;
-using System.Collections.Generic;
-using System.Linq;
 using System.Net;
-using System.Text;
-using System.Threading;
 
 namespace Hazel.Udp
 {