Ver Fonte

ActorProxy重发三次失败,删掉ActorProxy

tanghai há 8 anos atrás
pai
commit
cc4ee67594

+ 10 - 0
Server/Model/Component/ActorProxyComponent.cs

@@ -17,5 +17,15 @@ namespace Model
 			this.dictionary[id] = actorProxy;
 			this.dictionary[id] = actorProxy;
 			return actorProxy;
 			return actorProxy;
 		}
 		}
+
+		public void Remove(long id)
+		{
+			ActorProxy actorProxy;
+			if (!this.dictionary.TryGetValue(id, out actorProxy))
+			{
+				return;
+			}
+			actorProxy.Dispose();
+		}
 	}
 	}
 }
 }

+ 23 - 2
Server/Model/Entity/ActorProxy.cs

@@ -132,7 +132,7 @@ namespace Model
 
 
 		private void Remove()
 		private void Remove()
 		{
 		{
-			ActorTask task = this.RunningTasks.Dequeue();
+			this.RunningTasks.Dequeue();
 			this.AllowGet();
 			this.AllowGet();
 		}
 		}
 
 
@@ -174,8 +174,24 @@ namespace Model
 			}
 			}
 			while (true)
 			while (true)
 			{
 			{
+				if (this.Id == 0)
+				{
+					return;
+				}
 				ActorTask actorTask = await this.GetAsync();
 				ActorTask actorTask = await this.GetAsync();
-				this.RunTask(actorTask);
+				if (actorTask == null)
+				{
+					return;
+				}
+				try
+				{
+					this.RunTask(actorTask);
+				}
+				catch (Exception e)
+				{
+					Log.Error(e.ToString());
+					return;
+				}
 			}
 			}
 		}
 		}
 
 
@@ -207,6 +223,9 @@ namespace Model
 							ActorTask actorTask = this.WaitingTasks.Dequeue();
 							ActorTask actorTask = this.WaitingTasks.Dequeue();
 							actorTask.RunFail(response.Error);
 							actorTask.RunFail(response.Error);
 						}
 						}
+
+						// 失败直接删除actorproxy
+						Game.Scene.GetComponent<ActorProxyComponent>().Remove(this.Id);
 						return;
 						return;
 					}
 					}
 					
 					
@@ -281,6 +300,8 @@ namespace Model
 			}
 			}
 
 
 			base.Dispose();
 			base.Dispose();
+
+			this.tcs?.SetResult(null);
 		}
 		}
 	}
 	}
 }
 }

+ 1 - 0
Unity/Unity.Editor.Plugins.csproj

@@ -166,6 +166,7 @@
     <None Include="Assets\Res\Config\UnitConfig.txt" />
     <None Include="Assets\Res\Config\UnitConfig.txt" />
     <None Include="Assets\StreamingAssets\Logs\Log-Client-Error.txt" />
     <None Include="Assets\StreamingAssets\Logs\Log-Client-Error.txt" />
     <None Include="Assets\StreamingAssets\Logs\Log-Client-Info.txt" />
     <None Include="Assets\StreamingAssets\Logs\Log-Client-Info.txt" />
+    <None Include="Assets\link.xml" />
   </ItemGroup>
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Target Name="GenerateTargetFrameworkMonikerAttribute" />
   <Target Name="GenerateTargetFrameworkMonikerAttribute" />

+ 1 - 0
Unity/Unity.Editor.csproj

@@ -216,6 +216,7 @@
     <None Include="Assets\Res\Config\UnitConfig.txt" />
     <None Include="Assets\Res\Config\UnitConfig.txt" />
     <None Include="Assets\StreamingAssets\Logs\Log-Client-Error.txt" />
     <None Include="Assets\StreamingAssets\Logs\Log-Client-Error.txt" />
     <None Include="Assets\StreamingAssets\Logs\Log-Client-Info.txt" />
     <None Include="Assets\StreamingAssets\Logs\Log-Client-Info.txt" />
+    <None Include="Assets\link.xml" />
   </ItemGroup>
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Target Name="GenerateTargetFrameworkMonikerAttribute" />
   <Target Name="GenerateTargetFrameworkMonikerAttribute" />

+ 1 - 0
Unity/Unity.Plugins.csproj

@@ -518,6 +518,7 @@
     <None Include="Assets\Res\Config\UnitConfig.txt" />
     <None Include="Assets\Res\Config\UnitConfig.txt" />
     <None Include="Assets\StreamingAssets\Logs\Log-Client-Error.txt" />
     <None Include="Assets\StreamingAssets\Logs\Log-Client-Error.txt" />
     <None Include="Assets\StreamingAssets\Logs\Log-Client-Info.txt" />
     <None Include="Assets\StreamingAssets\Logs\Log-Client-Info.txt" />
+    <None Include="Assets\link.xml" />
   </ItemGroup>
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Target Name="GenerateTargetFrameworkMonikerAttribute" />
   <Target Name="GenerateTargetFrameworkMonikerAttribute" />

+ 5 - 7
Unity/Unity.csproj

@@ -12,15 +12,12 @@
     <ProjectTypeGuids>{E097FAD1-6243-4DAD-9C02-E9B9EFC3FFC1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
     <ProjectTypeGuids>{E097FAD1-6243-4DAD-9C02-E9B9EFC3FFC1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
     <TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
     <TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
     <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
     <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
-    <TargetFrameworkProfile>
-    </TargetFrameworkProfile>
-    <CompilerResponseFile>
-    </CompilerResponseFile>
+    <TargetFrameworkProfile></TargetFrameworkProfile>
+    <CompilerResponseFile></CompilerResponseFile>
     <UnityProjectType>Game:1</UnityProjectType>
     <UnityProjectType>Game:1</UnityProjectType>
     <UnityBuildTarget>StandaloneWindows64:19</UnityBuildTarget>
     <UnityBuildTarget>StandaloneWindows64:19</UnityBuildTarget>
     <UnityVersion>2017.1.1p4</UnityVersion>
     <UnityVersion>2017.1.1p4</UnityVersion>
-    <RootNamespace>
-    </RootNamespace>
+    <RootNamespace></RootNamespace>
     <LangVersion>6</LangVersion>
     <LangVersion>6</LangVersion>
   </PropertyGroup>
   </PropertyGroup>
   <PropertyGroup>
   <PropertyGroup>
@@ -557,7 +554,8 @@
     <None Include="Assets\Res\Config\UnitConfig.txt" />
     <None Include="Assets\Res\Config\UnitConfig.txt" />
     <None Include="Assets\StreamingAssets\Logs\Log-Client-Error.txt" />
     <None Include="Assets\StreamingAssets\Logs\Log-Client-Error.txt" />
     <None Include="Assets\StreamingAssets\Logs\Log-Client-Info.txt" />
     <None Include="Assets\StreamingAssets\Logs\Log-Client-Info.txt" />
+    <None Include="Assets\link.xml" />
   </ItemGroup>
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Target Name="GenerateTargetFrameworkMonikerAttribute" />
   <Target Name="GenerateTargetFrameworkMonikerAttribute" />
-</Project>
+</Project>