Procházet zdrojové kódy

合并主干分支

# Conflicts:
#	Client-Server.sln
#	Config/StartConfig/Benchmark.txt
#	Server/App/Server.App.csproj
#	Server/App/Server.App.csproj.user
#	Server/Base/Server.Base.csproj
#	Server/Model/Server.Model.csproj
#	Server/ThirdParty/ENet/ENet.vcxproj
#	Unity/Assets/Scripts/Base/EQueue.cs
tanghai před 8 roky
rodič
revize
984bdd8b98

+ 3 - 1
Client-Server.sln.DotSettings.user

@@ -8,4 +8,6 @@
 	<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AUnitComponent_002Ecs_002Fl_003AUnity_003FAssets_003FScripts_003FComponent_003FUnitComponent_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
 	<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=Unity/@EntryIndexedValue">&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;Profile name="Unity"&gt;&lt;CSArrangeThisQualifier&gt;True&lt;/CSArrangeThisQualifier&gt;&lt;CSRemoveCodeRedundancies&gt;True&lt;/CSRemoveCodeRedundancies&gt;&lt;CSMakeFieldReadonly&gt;True&lt;/CSMakeFieldReadonly&gt;&lt;CSUseVar&gt;&lt;BehavourStyle&gt;DISABLED&lt;/BehavourStyle&gt;&lt;LocalVariableStyle&gt;IMPLICIT_WHEN_INITIALIZER_HAS_TYPE&lt;/LocalVariableStyle&gt;&lt;ForeachVariableStyle&gt;IMPLICIT_EXCEPT_SIMPLE_TYPES&lt;/ForeachVariableStyle&gt;&lt;/CSUseVar&gt;&lt;CSOptimizeUsings&gt;&lt;OptimizeUsings&gt;True&lt;/OptimizeUsings&gt;&lt;EmbraceInRegion&gt;False&lt;/EmbraceInRegion&gt;&lt;RegionName&gt;&lt;/RegionName&gt;&lt;/CSOptimizeUsings&gt;&lt;CSShortenReferences&gt;True&lt;/CSShortenReferences&gt;&lt;CSReformatCode&gt;True&lt;/CSReformatCode&gt;&lt;CSMakeAutoPropertyGetOnly&gt;True&lt;/CSMakeAutoPropertyGetOnly&gt;&lt;CSUseAutoProperty&gt;True&lt;/CSUseAutoProperty&gt;&lt;RemoveCodeRedundancies&gt;True&lt;/RemoveCodeRedundancies&gt;&lt;CSCodeStyleAttributes ArrangeTypeAccessModifier="True" ArrangeTypeMemberAccessModifier="True" SortModifiers="True" RemoveRedundantParentheses="True" AddMissingParentheses="True" ArrangeBraces="True" ArrangeAttributes="True" ArrangeArgumentsStyle="True" ArrangeCodeBodyStyle="True" /&gt;&lt;/Profile&gt;</s:String>
 	<s:String x:Key="/Default/Housekeeping/Layout/DialogWindows/RefactoringWizardWindow/Location/@EntryValue">247,-4</s:String>
-	<s:Int64 x:Key="/Default/Environment/SearchAndNavigation/DefaultOccurrencesGroupingIndex/@EntryValue">0</s:Int64></wpf:ResourceDictionary>
+	<s:Int64 x:Key="/Default/Environment/SearchAndNavigation/DefaultOccurrencesGroupingIndex/@EntryValue">0</s:Int64>
+	<s:String x:Key="/Default/Profiling/Configurations/=1/@EntryIndexedValue">&lt;data&gt;&lt;HostParameters type="LocalHostParameters" /&gt;&lt;Argument type="StandaloneArgument"&gt;&lt;Arguments IsNull="False"&gt;&lt;/Arguments&gt;&lt;FileName IsNull="False"&gt;&lt;/FileName&gt;&lt;WorkingDirectory IsNull="False"&gt;&lt;/WorkingDirectory&gt;&lt;Scope&gt;&lt;ProcessFilters /&gt;&lt;/Scope&gt;&lt;/Argument&gt;&lt;Info type="TimelineInfo" /&gt;&lt;HostOptions type="HostOptions"&gt;&lt;HostTempPath IsNull="False"&gt;&lt;/HostTempPath&gt;&lt;/HostOptions&gt;&lt;/data&gt;</s:String>
+	</wpf:ResourceDictionary>

+ 2 - 0
Config/StartConfig/BenchmarkClient.txt

@@ -0,0 +1,2 @@
+{ "_t" : "StartConfig", "_id" : NumberLong("98813417750535"), "components" : [{ "_t" : "OuterConfig", "Host" : "127.0.0.1", "Port" : 10000, "Host2" : null }, { "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20003 }], "AppId" : 1, "AppType" : "Manager", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("98813420503048"), "components" : [{ "_t" : "ClientConfig", "Host" : "127.0.0.1", "Port" : 10002 }], "AppId" : 2, "AppType" : "Benchmark", "ServerIP" : "*" }

+ 1 - 1
Server/App/NLog.config

@@ -14,7 +14,7 @@
 		<target name="debug" xsi:type="File"
 			fileName="${basedir}/../Logs/Log-${var:appType}-${var:appId}-Debug.txt"
 			deleteOldFileOnStartup="false"
-			layout="${longdate} ${var:appTypeFormat} ${var:appIdFormat} ${callsite:className=false:methodName=false:fileName=true:includeSourcePath=false:skipFrames=2} ${message} ${stacktrace:format=Flat:topFrames=100:skipFrames=0}" />
+			layout="${longdate} ${var:appTypeFormat} ${var:appIdFormat} ${callsite:className=false:methodName=false:fileName=true:includeSourcePath=false:skipFrames=2} ${message}" />
 	</targets>
 
 	<targets>

+ 10 - 0
Server/App/Server.App.csproj.user

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
+    <StartArguments>--appId=1 --appType=AllServer --config=../Config/StartConfig/LocalAllServer.txt</StartArguments>
+    <StartAction>URL</StartAction>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
+    <StartArguments>--appId=1 --appType=AllServer --config=../Config/StartConfig/LocalAllServer.txt</StartArguments>
+  </PropertyGroup>
+</Project>

+ 26 - 14
Server/Model/Component/BenchmarkComponent.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Threading.Tasks;
 
 namespace Model
 {
@@ -42,22 +43,10 @@ namespace Model
 				using (Session session = networkComponent.Create(address))
 				{
 					int i = 0;
-					while (i < 10000000)
+					while (i < 100000000)
 					{
 						++i;
-						await session.Call<R2C_Ping>(new C2R_Ping());
-
-						++this.k;
-
-						if (this.k % 100000 != 0)
-						{
-							continue;
-						}
-
-						long time2 = TimeHelper.ClientNow();
-						long time = time2 - this.time1;
-						this.time1 = time2;
-						Log.Info($"{j} Benchmark k: {this.k} 每10W次耗时: {time} ms");
+						await this.Send(session, j);
 					}
 				}
 			}
@@ -71,6 +60,29 @@ namespace Model
 			}
 		}
 
+		public async Task Send(Session session, int j)
+		{
+			try
+			{
+				await session.Call<R2C_Ping>(new C2R_Ping());
+				++this.k;
+
+				if (this.k % 100000 != 0)
+				{
+					return;
+				}
+
+				long time2 = TimeHelper.ClientNow();
+				long time = time2 - this.time1;
+				this.time1 = time2;
+				Log.Info($"Benchmark k: {this.k} 每10W次耗时: {time} ms");
+			}
+			catch (Exception e)
+			{
+				Log.Error(e.ToString());
+			}
+		}
+
 		public override void Dispose()
 		{
 			if (this.Id == 0)

+ 4 - 3
Server/Model/Other/OneThreadSynchronizationContext.cs

@@ -16,13 +16,14 @@ namespace Model
 
 		public void Update()
 		{
-			while (!this.queue.IsEmpty)
+			while (true)
 			{
 				Action a;
-				if (this.queue.TryDequeue(out a))
+				if (!this.queue.TryDequeue(out a))
 				{
-					a();
+					return;
 				}
+				a();
 			}
 		}
 

+ 144 - 0
Server/Server.sln

@@ -0,0 +1,144 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.26730.15
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Server.App", "App\Server.App.csproj", "{11464C2C-E0B6-476E-ABB1-87445E736B76}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Server.Base", "Base\Server.Base.csproj", "{9FB55F6F-9A5B-4B8C-A1DD-374A431BAB57}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Server.Hotfix", "Hotfix\Server.Hotfix.csproj", "{E383A68D-1928-46F4-8896-4E99DF331476}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Server.Model", "Model\Server.Model.csproj", "{85CB09B5-6392-4A13-BAF8-025218BFF496}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ENet", "ThirdParty\ENet\ENet.vcxproj", "{C9992B7C-313E-4C9F-A954-640D01EDFB58}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ThirdParty", "ThirdParty", "{5D11E730-0CAA-4A47-BA1A-379004F0F6D9}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MongodbDriver", "MongodbDriver", "{6946DBCF-B81C-4B2A-A7C5-94A337D915C2}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MongoDB.Bson", "ThirdParty\MongodbDriver\DotNetCoreDriver\MongoDB.Bson\MongoDB.Bson.csproj", "{817B2682-29D6-4BAC-9AA7-618DCCD8CBE5}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MongoDB.Driver", "ThirdParty\MongodbDriver\DotNetCoreDriver\MongoDB.Driver\MongoDB.Driver.csproj", "{3FD1D683-59E8-47C4-9436-B3D856EFB094}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MongoDB.Driver.Core", "ThirdParty\MongodbDriver\DotNetCoreDriver\MongoDB.Driver.Core\MongoDB.Driver.Core.csproj", "{46A590DE-EBA3-4928-AB78-5C514D08C9E7}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Debug|x64 = Debug|x64
+		Debug|x86 = Debug|x86
+		Release|Any CPU = Release|Any CPU
+		Release|x64 = Release|x64
+		Release|x86 = Release|x86
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{11464C2C-E0B6-476E-ABB1-87445E736B76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{11464C2C-E0B6-476E-ABB1-87445E736B76}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{11464C2C-E0B6-476E-ABB1-87445E736B76}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{11464C2C-E0B6-476E-ABB1-87445E736B76}.Debug|x64.Build.0 = Debug|Any CPU
+		{11464C2C-E0B6-476E-ABB1-87445E736B76}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{11464C2C-E0B6-476E-ABB1-87445E736B76}.Debug|x86.Build.0 = Debug|Any CPU
+		{11464C2C-E0B6-476E-ABB1-87445E736B76}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{11464C2C-E0B6-476E-ABB1-87445E736B76}.Release|Any CPU.Build.0 = Release|Any CPU
+		{11464C2C-E0B6-476E-ABB1-87445E736B76}.Release|x64.ActiveCfg = Release|Any CPU
+		{11464C2C-E0B6-476E-ABB1-87445E736B76}.Release|x64.Build.0 = Release|Any CPU
+		{11464C2C-E0B6-476E-ABB1-87445E736B76}.Release|x86.ActiveCfg = Release|Any CPU
+		{11464C2C-E0B6-476E-ABB1-87445E736B76}.Release|x86.Build.0 = Release|Any CPU
+		{9FB55F6F-9A5B-4B8C-A1DD-374A431BAB57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{9FB55F6F-9A5B-4B8C-A1DD-374A431BAB57}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{9FB55F6F-9A5B-4B8C-A1DD-374A431BAB57}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{9FB55F6F-9A5B-4B8C-A1DD-374A431BAB57}.Debug|x64.Build.0 = Debug|Any CPU
+		{9FB55F6F-9A5B-4B8C-A1DD-374A431BAB57}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{9FB55F6F-9A5B-4B8C-A1DD-374A431BAB57}.Debug|x86.Build.0 = Debug|Any CPU
+		{9FB55F6F-9A5B-4B8C-A1DD-374A431BAB57}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{9FB55F6F-9A5B-4B8C-A1DD-374A431BAB57}.Release|Any CPU.Build.0 = Release|Any CPU
+		{9FB55F6F-9A5B-4B8C-A1DD-374A431BAB57}.Release|x64.ActiveCfg = Release|Any CPU
+		{9FB55F6F-9A5B-4B8C-A1DD-374A431BAB57}.Release|x64.Build.0 = Release|Any CPU
+		{9FB55F6F-9A5B-4B8C-A1DD-374A431BAB57}.Release|x86.ActiveCfg = Release|Any CPU
+		{9FB55F6F-9A5B-4B8C-A1DD-374A431BAB57}.Release|x86.Build.0 = Release|Any CPU
+		{E383A68D-1928-46F4-8896-4E99DF331476}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{E383A68D-1928-46F4-8896-4E99DF331476}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{E383A68D-1928-46F4-8896-4E99DF331476}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{E383A68D-1928-46F4-8896-4E99DF331476}.Debug|x64.Build.0 = Debug|Any CPU
+		{E383A68D-1928-46F4-8896-4E99DF331476}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{E383A68D-1928-46F4-8896-4E99DF331476}.Debug|x86.Build.0 = Debug|Any CPU
+		{E383A68D-1928-46F4-8896-4E99DF331476}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{E383A68D-1928-46F4-8896-4E99DF331476}.Release|Any CPU.Build.0 = Release|Any CPU
+		{E383A68D-1928-46F4-8896-4E99DF331476}.Release|x64.ActiveCfg = Release|Any CPU
+		{E383A68D-1928-46F4-8896-4E99DF331476}.Release|x64.Build.0 = Release|Any CPU
+		{E383A68D-1928-46F4-8896-4E99DF331476}.Release|x86.ActiveCfg = Release|Any CPU
+		{E383A68D-1928-46F4-8896-4E99DF331476}.Release|x86.Build.0 = Release|Any CPU
+		{85CB09B5-6392-4A13-BAF8-025218BFF496}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{85CB09B5-6392-4A13-BAF8-025218BFF496}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{85CB09B5-6392-4A13-BAF8-025218BFF496}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{85CB09B5-6392-4A13-BAF8-025218BFF496}.Debug|x64.Build.0 = Debug|Any CPU
+		{85CB09B5-6392-4A13-BAF8-025218BFF496}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{85CB09B5-6392-4A13-BAF8-025218BFF496}.Debug|x86.Build.0 = Debug|Any CPU
+		{85CB09B5-6392-4A13-BAF8-025218BFF496}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{85CB09B5-6392-4A13-BAF8-025218BFF496}.Release|Any CPU.Build.0 = Release|Any CPU
+		{85CB09B5-6392-4A13-BAF8-025218BFF496}.Release|x64.ActiveCfg = Release|Any CPU
+		{85CB09B5-6392-4A13-BAF8-025218BFF496}.Release|x64.Build.0 = Release|Any CPU
+		{85CB09B5-6392-4A13-BAF8-025218BFF496}.Release|x86.ActiveCfg = Release|Any CPU
+		{85CB09B5-6392-4A13-BAF8-025218BFF496}.Release|x86.Build.0 = Release|Any CPU
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Debug|Any CPU.ActiveCfg = Debug|Win32
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Debug|x64.ActiveCfg = Debug|x64
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Debug|x64.Build.0 = Debug|x64
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Debug|x86.ActiveCfg = Debug|Win32
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Debug|x86.Build.0 = Debug|Win32
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Release|Any CPU.ActiveCfg = Release|Win32
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Release|x64.ActiveCfg = Release|x64
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Release|x64.Build.0 = Release|x64
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Release|x86.ActiveCfg = Release|Win32
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Release|x86.Build.0 = Release|Win32
+		{817B2682-29D6-4BAC-9AA7-618DCCD8CBE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{817B2682-29D6-4BAC-9AA7-618DCCD8CBE5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{817B2682-29D6-4BAC-9AA7-618DCCD8CBE5}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{817B2682-29D6-4BAC-9AA7-618DCCD8CBE5}.Debug|x64.Build.0 = Debug|Any CPU
+		{817B2682-29D6-4BAC-9AA7-618DCCD8CBE5}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{817B2682-29D6-4BAC-9AA7-618DCCD8CBE5}.Debug|x86.Build.0 = Debug|Any CPU
+		{817B2682-29D6-4BAC-9AA7-618DCCD8CBE5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{817B2682-29D6-4BAC-9AA7-618DCCD8CBE5}.Release|Any CPU.Build.0 = Release|Any CPU
+		{817B2682-29D6-4BAC-9AA7-618DCCD8CBE5}.Release|x64.ActiveCfg = Release|Any CPU
+		{817B2682-29D6-4BAC-9AA7-618DCCD8CBE5}.Release|x64.Build.0 = Release|Any CPU
+		{817B2682-29D6-4BAC-9AA7-618DCCD8CBE5}.Release|x86.ActiveCfg = Release|Any CPU
+		{817B2682-29D6-4BAC-9AA7-618DCCD8CBE5}.Release|x86.Build.0 = Release|Any CPU
+		{3FD1D683-59E8-47C4-9436-B3D856EFB094}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{3FD1D683-59E8-47C4-9436-B3D856EFB094}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{3FD1D683-59E8-47C4-9436-B3D856EFB094}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{3FD1D683-59E8-47C4-9436-B3D856EFB094}.Debug|x64.Build.0 = Debug|Any CPU
+		{3FD1D683-59E8-47C4-9436-B3D856EFB094}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{3FD1D683-59E8-47C4-9436-B3D856EFB094}.Debug|x86.Build.0 = Debug|Any CPU
+		{3FD1D683-59E8-47C4-9436-B3D856EFB094}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{3FD1D683-59E8-47C4-9436-B3D856EFB094}.Release|Any CPU.Build.0 = Release|Any CPU
+		{3FD1D683-59E8-47C4-9436-B3D856EFB094}.Release|x64.ActiveCfg = Release|Any CPU
+		{3FD1D683-59E8-47C4-9436-B3D856EFB094}.Release|x64.Build.0 = Release|Any CPU
+		{3FD1D683-59E8-47C4-9436-B3D856EFB094}.Release|x86.ActiveCfg = Release|Any CPU
+		{3FD1D683-59E8-47C4-9436-B3D856EFB094}.Release|x86.Build.0 = Release|Any CPU
+		{46A590DE-EBA3-4928-AB78-5C514D08C9E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{46A590DE-EBA3-4928-AB78-5C514D08C9E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{46A590DE-EBA3-4928-AB78-5C514D08C9E7}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{46A590DE-EBA3-4928-AB78-5C514D08C9E7}.Debug|x64.Build.0 = Debug|Any CPU
+		{46A590DE-EBA3-4928-AB78-5C514D08C9E7}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{46A590DE-EBA3-4928-AB78-5C514D08C9E7}.Debug|x86.Build.0 = Debug|Any CPU
+		{46A590DE-EBA3-4928-AB78-5C514D08C9E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{46A590DE-EBA3-4928-AB78-5C514D08C9E7}.Release|Any CPU.Build.0 = Release|Any CPU
+		{46A590DE-EBA3-4928-AB78-5C514D08C9E7}.Release|x64.ActiveCfg = Release|Any CPU
+		{46A590DE-EBA3-4928-AB78-5C514D08C9E7}.Release|x64.Build.0 = Release|Any CPU
+		{46A590DE-EBA3-4928-AB78-5C514D08C9E7}.Release|x86.ActiveCfg = Release|Any CPU
+		{46A590DE-EBA3-4928-AB78-5C514D08C9E7}.Release|x86.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(NestedProjects) = preSolution
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58} = {5D11E730-0CAA-4A47-BA1A-379004F0F6D9}
+		{6946DBCF-B81C-4B2A-A7C5-94A337D915C2} = {5D11E730-0CAA-4A47-BA1A-379004F0F6D9}
+		{817B2682-29D6-4BAC-9AA7-618DCCD8CBE5} = {6946DBCF-B81C-4B2A-A7C5-94A337D915C2}
+		{3FD1D683-59E8-47C4-9436-B3D856EFB094} = {6946DBCF-B81C-4B2A-A7C5-94A337D915C2}
+		{46A590DE-EBA3-4928-AB78-5C514D08C9E7} = {6946DBCF-B81C-4B2A-A7C5-94A337D915C2}
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {EE120158-643A-409C-B8F2-5E654E4D6D70}
+	EndGlobalSection
+EndGlobal

+ 1 - 1
Unity/Assets/Bundles/UI/UILobby.prefab.meta

@@ -5,5 +5,5 @@ licenseType: Free
 NativeFormatImporter:
   mainObjectFileID: 100100000
   userData: 
-  assetBundleName: uilogin.unity3d
+  assetBundleName: 
   assetBundleVariant: 

+ 1 - 1
Unity/Assets/Bundles/UI/UILogin.prefab.meta

@@ -5,5 +5,5 @@ licenseType: Free
 NativeFormatImporter:
   mainObjectFileID: 100100000
   userData: 
-  assetBundleName: uilogin.unity3d
+  assetBundleName: 
   assetBundleVariant: 

+ 179 - 0
Unity/Assets/Editor/BuildEditor/BuildABEditor.cs

@@ -0,0 +1,179 @@
+using System.Collections.Generic;
+using System.IO;
+using Model;
+using UnityEditor;
+using UnityEngine;
+
+namespace MyEditor
+{
+	public class BundleInfo
+	{
+		public List<string> ParentPaths = new List<string>();
+	}
+	
+	public class BuildABEditor: EditorWindow
+	{
+		private readonly Dictionary<string, BundleInfo> dictionary = new Dictionary<string, BundleInfo>();
+		
+		[MenuItem("Tools/打包/设置标记")]
+		private static void ShowWindow()
+		{
+			GetWindow<BuildABEditor>();
+		}
+
+		private void OnGUI()
+		{
+			if (GUILayout.Button("设置标记"))
+			{
+				SetPackingTagAndAssetBundle();
+			}
+
+			if (GUILayout.Button("清除标记"))
+			{
+				ClearPackingTagAndAssetBundle();
+			}
+
+			if (GUILayout.Button("清除并且设置"))
+			{
+				ClearPackingTagAndAssetBundle();
+				SetPackingTagAndAssetBundle();
+			}
+		}
+
+		private void SetPackingTagAndAssetBundle()
+		{
+			string[] subDirectories = Directory.GetDirectories("Assets/Bundles/");
+
+			foreach (string subDirectory in subDirectories)
+			{
+				Log.Info($"开始设置目录:{subDirectory}");
+				DirectoryInfo info = new DirectoryInfo(subDirectory);
+				SetOneDirPackingTagAndAssetBundle(info.Name);
+				Log.Info($"结束设置目录:{subDirectory}");
+
+				Log.Info($"--------------------------------------");
+			}
+		}
+
+		private void SetOneDirPackingTagAndAssetBundle(string dirName)
+		{
+			this.dictionary.Clear();
+			List<string> paths = EditorResHelper.GetAllPath($"Assets/Bundles/{dirName}", true);
+
+			foreach (string path in paths)
+			{
+				string path1 = path.Replace('\\', '/');
+				GameObject go = AssetDatabase.LoadAssetAtPath<GameObject>(path1);
+				AssetImporter importer = AssetImporter.GetAtPath(path1);
+				importer.assetBundleName = $"{go.name}.unity3d";
+					
+				UnityEngine.Object[] objects = EditorUtility.CollectDependencies(new UnityEngine.Object[] { go });
+				foreach (UnityEngine.Object o in objects)
+				{
+					string pt = AssetDatabase.GetAssetPath(o);
+					string extension = Path.GetExtension(pt);
+					if (extension == ".cs" || extension == ".dll")
+					{
+						continue;
+					}
+					if (pt.Contains("Resources"))
+					{
+						continue;
+					}
+					if (pt == path1)
+					{
+						continue;
+					}
+
+					// 不存在则记录下来
+					if (!this.dictionary.ContainsKey(pt))
+					{					
+						Log.Info($"{path1}----{pt}");
+						BundleInfo bundleInfo = new BundleInfo();
+						bundleInfo.ParentPaths.Add(path1);
+						this.dictionary.Add(pt, bundleInfo);
+							
+						AssetImporter importer3 = AssetImporter.GetAtPath(pt);
+						TextureImporter textureImporter3 = importer3 as TextureImporter;
+						if (textureImporter3 != null)
+						{
+							textureImporter3.spritePackingTag = go.name;
+						}
+							
+						continue;
+					}
+
+					// 依赖的父亲不一样
+					BundleInfo info = this.dictionary[pt];
+					if (info.ParentPaths.Contains(path1))
+					{
+						continue;
+					}
+					info.ParentPaths.Add(path1);
+						
+					AssetImporter importer2 = AssetImporter.GetAtPath(pt);
+					if (importer2 == null)
+					{
+						continue;
+					}
+
+					if (importer2.assetBundleName != "")
+					{
+						continue;
+					}
+						
+					
+					importer2.assetBundleName = $"{dirName}share.unity3d";
+					Log.Warning($"{importer2.assetBundleName}: {pt} {info.ParentPaths.ListToString()}");
+
+					TextureImporter textureImporter = importer2 as TextureImporter;
+					if (textureImporter != null)
+					{
+						textureImporter.spritePackingTag = $"{dirName}share";
+					}
+				}
+			}
+		}
+
+		private static void ClearPackingTagAndAssetBundle()
+		{
+			List<string> bundlePaths = EditorResHelper.GetAllResourcePath("Assets/Bundles", true);
+			foreach (string bundlePath in bundlePaths)
+			{
+				AssetImporter importer = AssetImporter.GetAtPath(bundlePath);
+				if (importer == null)
+				{
+					continue;
+				}
+				//Log.Info(bundlePath);
+				importer.assetBundleName = "";
+			}
+			
+			List<string> paths = EditorResHelper.GetAllResourcePath("Assets/Res", true);
+			foreach (string path in paths)
+			{
+				string extendName = Path.GetExtension(path);
+				if (extendName == ".cs")
+				{
+					continue;
+				}
+				
+				AssetImporter importer = AssetImporter.GetAtPath(path);
+				if (importer == null)
+				{
+					continue;
+				}
+
+				//Log.Info(path);
+
+				importer.assetBundleName = "";
+
+				TextureImporter textureImporter = importer as TextureImporter;
+				if (textureImporter != null)
+				{
+					textureImporter.spritePackingTag = "";
+				}
+			}
+		}
+	}
+}

+ 3 - 0
Unity/Assets/Editor/BuildEditor/BuildABEditor.cs.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 52155b8c452647ec8b84033519269054
+timeCreated: 1507865387

+ 3 - 0
Unity/Assets/Editor/Helper.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 5999bd61b5ca4e5ba50b20b2e3a7f9b2
+timeCreated: 1507865451

+ 65 - 0
Unity/Assets/Editor/Helper/EditorResHelper.cs

@@ -0,0 +1,65 @@
+using System.Collections.Generic;
+using System.IO;
+
+namespace Model
+{
+    public class EditorResHelper
+    {
+        /// <summary>
+        /// 获取文件夹内所有的预制路径
+        /// </summary>
+        /// <param name="srcPath">源文件夹</param>
+        /// <param name="subDire">是否获取子文件夹</param>
+        /// <returns></returns>
+        public static List<string> GetAllPath(string srcPath, bool subDire)
+        {
+            List<string> paths = new List<string>();
+            string[] files = Directory.GetFiles(srcPath);
+            foreach (string str in files)
+            {
+                if (str.EndsWith(".prefab"))
+                {
+                    paths.Add(str);
+                }
+            }
+            if (subDire)
+            {
+                foreach (string subPath in Directory.GetDirectories(srcPath))
+                {
+                    List<string> subFiles = GetAllPath(subPath, true);
+                    paths.AddRange(subFiles);
+                }
+            }
+            return paths;
+        }
+        
+        /// <summary>
+        /// 获取文件夹内所有资源路径
+        /// </summary>
+        /// <param name="srcPath">源文件夹</param>
+        /// <param name="subDire">是否获取子文件夹</param>
+        /// <returns></returns>
+        public static List<string> GetAllResourcePath(string srcPath, bool subDire)
+        {
+            List<string> paths = new List<string>();
+            string[] files = Directory.GetFiles(srcPath);
+            foreach (string str in files)
+            {
+                if (str.EndsWith(".meta"))
+                {
+                    continue;
+                }
+                paths.Add(str);
+            }
+            if (subDire)
+            {
+                foreach (string subPath in Directory.GetDirectories(srcPath))
+                {
+                    List<string> subFiles = GetAllResourcePath(subPath, true);
+                    paths.AddRange(subFiles);
+                }
+            }
+            return paths;
+        }
+    }
+}

+ 3 - 0
Unity/Assets/Editor/Helper/EditorResHelper.cs.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 534eee73ca004cb58dcde9e3536b8b74
+timeCreated: 1507865453

+ 13 - 7
Unity/Assets/Scripts/Base/Network/TNet/TChannel.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.IO;
 using System.Linq;
 using System.Net;
 using System.Net.Sockets;
@@ -59,7 +60,7 @@ namespace Model
 			}
 			catch (Exception e)
 			{
-				Log.Error(e.ToString());
+				Log.Error($"connect error: {host} {port} {e}");
 			}
 		}
 
@@ -69,13 +70,10 @@ namespace Model
 			{
 				return;
 			}
-
-			long id = this.Id;
-
+			
 			base.Dispose();
 
 			this.tcpClient.Close();
-			this.service.Remove(id);
 		}
 
 		private void OnAccepted()
@@ -96,7 +94,7 @@ namespace Model
 			this.sendBuffer.SendTo(buffer);
 			if (this.isConnected)
 			{
-				this.StartSend();
+				((TService)this.service).Add(this.StartSend);
 			}
 		}
 
@@ -115,7 +113,7 @@ namespace Model
 			}
 			if (this.isConnected)
 			{
-				this.StartSend();
+				((TService)this.service).Add(this.StartSend);
 			}
 		}
 
@@ -123,6 +121,11 @@ namespace Model
 		{
 			try
 			{
+				if (this.Id == 0)
+				{
+					return;
+				}
+
 				// 如果正在发送中,不需要再次发送
 				if (this.isSending)
 				{
@@ -209,6 +212,9 @@ namespace Model
 			catch (ObjectDisposedException)
 			{
 			}
+			catch (IOException)
+			{
+			}
 			catch (Exception e)
 			{
 				Log.Error(e.ToString());

+ 12 - 0
Unity/Assets/Scripts/Base/Network/TNet/TService.cs

@@ -13,6 +13,8 @@ namespace Model
 
 		private readonly Dictionary<long, TChannel> idChannels = new Dictionary<long, TChannel>();
 
+		private readonly EQueue<Action> actions = new EQueue<Action>();
+		
 		/// <summary>
 		/// 即可做client也可做server
 		/// </summary>
@@ -44,6 +46,11 @@ namespace Model
 			this.acceptor = null;
 		}
 
+		public void Add(Action action)
+		{
+			this.actions.Enqueue(action);
+		}
+
 		public override AChannel GetChannel(long id)
 		{
 			TChannel channel = null;
@@ -90,6 +97,11 @@ namespace Model
 		
 		public override void Update()
 		{
+			while (this.actions.Count > 0)
+			{
+				Action action = this.actions.Dequeue();
+				action();
+			}
 		}
 	}
 }

+ 2 - 0
Unity/Unity.Editor.csproj

@@ -184,9 +184,11 @@
     <Compile Include="Assets\Editor\BehaviorTreeEditor\NodeMeta.cs" />
     <Compile Include="Assets\Editor\BehaviorTreeEditor\NodeMetaHelper.cs" />
     <Compile Include="Assets\Editor\BehaviorTreeEditor\PropertyDesigner.cs" />
+    <Compile Include="Assets\Editor\BuildEditor\BuildABEditor.cs" />
     <Compile Include="Assets\Editor\BuildEditor\BuildEditor.cs" />
     <Compile Include="Assets\Editor\ExcelExporterEditor\ExcelExporterEditor.cs" />
     <Compile Include="Assets\Editor\ExportNavmesh.cs" />
+    <Compile Include="Assets\Editor\Helper\EditorResHelper.cs" />
     <Compile Include="Assets\Editor\ReferenceCollectorEditor\ReferenceCollectorEditor.cs" />
     <Compile Include="Assets\Editor\RsyncEditor\RsyncConfig.cs" />
     <Compile Include="Assets\Editor\RsyncEditor\RsyncEditor.cs" />

+ 5 - 8
Unity/Unity.csproj

@@ -12,15 +12,12 @@
     <ProjectTypeGuids>{E097FAD1-6243-4DAD-9C02-E9B9EFC3FFC1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
     <TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
     <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
-    <TargetFrameworkProfile>
-    </TargetFrameworkProfile>
-    <CompilerResponseFile>
-    </CompilerResponseFile>
+    <TargetFrameworkProfile></TargetFrameworkProfile>
+    <CompilerResponseFile></CompilerResponseFile>
     <UnityProjectType>Game:1</UnityProjectType>
     <UnityBuildTarget>StandaloneWindows:5</UnityBuildTarget>
     <UnityVersion>2017.1.0p5</UnityVersion>
-    <RootNamespace>
-    </RootNamespace>
+    <RootNamespace></RootNamespace>
     <LangVersion>6</LangVersion>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -557,8 +554,8 @@
     <Compile Include="Assets\Scripts\Factory\PlayerFactory.cs" />
     <Compile Include="Assets\Scripts\Factory\UnitFactory.cs" />
     <Compile Include="Assets\Scripts\Handler\Actor_CreateUnitsHandler.cs" />
-    <Compile Include="Assets\Scripts\Handler\Frame_ClickMapHandler.cs" />
     <Compile Include="Assets\Scripts\Handler\Actor_TestHandler.cs" />
+    <Compile Include="Assets\Scripts\Handler\Frame_ClickMapHandler.cs" />
     <Compile Include="Assets\Scripts\Helper\ActionHelper.cs" />
     <Compile Include="Assets\Scripts\Helper\DllHelper.cs" />
     <Compile Include="Assets\Scripts\Helper\GameObjectHelper.cs" />
@@ -588,4 +585,4 @@
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Target Name="GenerateTargetFrameworkMonikerAttribute" />
-</Project>
+</Project>