]> git.deb.at Git - rhonda/impostor.hazel.git/commitdiff
Fixes and help project
authorJamJar00 <jamster.30@btinternet.com>
Tue, 17 May 2016 13:13:30 +0000 (14:13 +0100)
committerJamJar00 <jamster.30@btinternet.com>
Tue, 17 May 2016 13:13:30 +0000 (14:13 +0100)
Hazel/Hazel.csproj
Hazel/Hazel.shfbproj [new file with mode: 0644]
Hazel/UdpConnection.Reliable.cs

index a4cc7dcc22159927fed35ec75e04936e2b470d81..9547f6480408f08ce8007729696935f4763ef6d2 100644 (file)
@@ -20,6 +20,8 @@
     <DefineConstants>DEBUG;TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
+    <DocumentationFile>
+    </DocumentationFile>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>pdbonly</DebugType>
@@ -28,6 +30,7 @@
     <DefineConstants>TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
+    <DocumentationFile>bin\Release\Hazel.XML</DocumentationFile>
   </PropertyGroup>
   <PropertyGroup>
     <SignAssembly>true</SignAssembly>
diff --git a/Hazel/Hazel.shfbproj b/Hazel/Hazel.shfbproj
new file mode 100644 (file)
index 0000000..0086936
--- /dev/null
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <!-- The configuration and platform will be used to determine which assemblies to include from solution and
+                                project documentation sources -->
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{359995e0-bef3-42dd-800f-20368ff5fabb}</ProjectGuid>
+    <SHFBSchemaVersion>2015.6.5.0</SHFBSchemaVersion>
+    <!-- AssemblyName, Name, and RootNamespace are not used by SHFB but Visual Studio adds them anyway -->
+    <AssemblyName>Documentation</AssemblyName>
+    <RootNamespace>Documentation</RootNamespace>
+    <Name>Documentation</Name>
+    <!-- SHFB properties -->
+    <FrameworkVersion>.NET Framework 4.5</FrameworkVersion>
+    <OutputPath>.\Help\</OutputPath>
+    <HtmlHelpName>Documentation</HtmlHelpName>
+    <Language>en-US</Language>
+    <SaveComponentCacheCapacity>100</SaveComponentCacheCapacity>
+    <BuildAssemblerVerbosity>OnlyWarningsAndErrors</BuildAssemblerVerbosity>
+    <HelpFileFormat>Website</HelpFileFormat>
+    <IndentHtml>False</IndentHtml>
+    <KeepLogFile>True</KeepLogFile>
+    <DisableCodeBlockComponent>False</DisableCodeBlockComponent>
+    <CleanIntermediates>True</CleanIntermediates>
+    <DocumentationSources>
+      <DocumentationSource sourceFile="bin\Release\Hazel.dll" />
+<DocumentationSource sourceFile="bin\Release\Hazel.XML" /></DocumentationSources>
+    <HelpFileVersion>1.0.0.0</HelpFileVersion>
+    <MaximumGroupParts>2</MaximumGroupParts>
+    <NamespaceGrouping>False</NamespaceGrouping>
+    <SyntaxFilters>Standard</SyntaxFilters>
+    <SdkLinkTarget>Blank</SdkLinkTarget>
+    <RootNamespaceContainer>False</RootNamespaceContainer>
+    <PresentationStyle>VS2013</PresentationStyle>
+    <Preliminary>False</Preliminary>
+    <NamingMethod>Guid</NamingMethod>
+    <HelpTitle>Hazel Networking</HelpTitle>
+    <ContentPlacement>AboveNamespaces</ContentPlacement>
+  </PropertyGroup>
+  <!-- There are no properties for these groups.  AnyCPU needs to appear in order for Visual Studio to perform
+                        the build.  The others are optional common platform types that may appear. -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|Win32' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|Win32' ">
+  </PropertyGroup>
+  <!-- Import the SHFB build targets -->
+  <Import Project="$(SHFBROOT)\SandcastleHelpFileBuilder.targets" />
+  <!-- The pre-build and post-build event properties must appear *after* the targets file import in order to be
+                        evaluated correctly. -->
+  <PropertyGroup>
+    <PreBuildEvent>
+    </PreBuildEvent>
+    <PostBuildEvent>
+    </PostBuildEvent>
+    <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
+  </PropertyGroup>
+  <ItemGroup>
+    <ProjectReference Include="Hazel.csproj">
+      <Name>Hazel</Name>
+      <Project>{02CFBD30-D77D-400F-94B2-700F60EFDD7F}</Project>
+    </ProjectReference>
+  </ItemGroup>
+</Project>
\ No newline at end of file
index de4677130b4f3b702b021f48092cf16f769bd193..80038c6092514710ca8028612631f53150b3d36f 100644 (file)
@@ -19,7 +19,7 @@ namespace Hazel
         ///     On each resend this is doubled for that packet.
         /// </remarks>
         public int ResendTimeout { get { return resendTimeout; } set { resendTimeout = value; } }
-        private int resendTimeout = 200;        //TODO this based of average ping?
+        private volatile int resendTimeout = 200;        //TODO this based of average ping?
 
         /// <summary>
         ///     Holds the last ID allocated.
@@ -46,10 +46,16 @@ namespace Hazel
         /// </summary>
         volatile bool hasReceivedSomething = false;
 
+        /// <summary>
+        ///     The maximum times a message should be retransmitted before marking the endpoint as disconnected.
+        /// </summary>
+        public int RetransmissionsBeforeDisconnect { get { return retransmissionsBeforeDisconnect; } set { retransmissionsBeforeDisconnect = value; } }
+        private volatile int retransmissionsBeforeDisconnect = 3;
+
         /// <summary>
         ///     Class to hold packet data
         /// </summary>
-        class Packet : IRecyclable
+        class Packet : IRecyclable, IDisposable
         {
             /// <summary>
             ///     Object pool for this event.
@@ -70,6 +76,7 @@ namespace Hazel
             public volatile int LastTimeout;
             public Action AckCallback;
             public volatile bool Acknowledged;
+            public volatile int Retransmissions;
 
             Packet()
             {
@@ -90,6 +97,7 @@ namespace Hazel
                 LastTimeout = timeout;
                 AckCallback = ackCallback;
                 Acknowledged = false;
+                Retransmissions = 0;
             }
 
             /// <summary>
@@ -97,8 +105,29 @@ namespace Hazel
             /// </summary>
             public void Recycle()
             {
+                lock (Timer)
+                    Timer.Dispose();
+
                 objectPool.PutObject(this);
             }
+
+            /// <summary>
+            ///     Disposes of this object.
+            /// </summary>
+            public void Dispose()
+            {
+                Dispose(true);
+                GC.SuppressFinalize(this);
+            }
+
+            protected void Dispose(bool disposing)
+            {
+                if (disposing)
+                {
+                    lock (Timer)
+                        Timer.Dispose();
+                }
+            }
         }
 
         /// <summary>
@@ -132,7 +161,14 @@ namespace Hazel
                         lock (p.Timer)
                         {
                             if (!p.Acknowledged)
+                            {
                                 p.Timer.Change(p.LastTimeout *= 2, Timeout.Infinite);       //TODO disconnect after x tries
+                                if (++p.Retransmissions >= RetransmissionsBeforeDisconnect)
+                                {
+                                    HandleDisconnect();
+                                    p.Recycle();
+                                }
+                            }
                         }
 
                         Trace.WriteLine("Resend.");
@@ -211,9 +247,6 @@ namespace Hazel
                     
                     packet.Acknowledged = true;
 
-                    lock (packet.Timer)
-                        packet.Timer.Dispose();
-                    
                     if (packet.AckCallback != null)
                         packet.AckCallback.Invoke();