Przeglądaj źródła

1.网络改成独立一个线程,序列化反序列化在网络线程处理
2.内网消息只支持protobuf,因为网络变成多线程,如果网络消息引用Entity,比如Item,在网络线序列化的时候,主线程可以正在修改,会导致线程竞争
3.内网消息如果要发送Entity则必须以bytes传递
4.RandomGenerator支持多线程
5.NetKcpComponent拆分成NetClientComponent跟NetServerComponent
6.加入Benchmark,在Unity菜单ET/ServerTools 选择Benchmark 点击StartWatch启动

tanghai 3 lat temu
rodzic
commit
0f42d6c7f0
100 zmienionych plików z 398 dodań i 219 usunięć
  1. 2 0
      Config/StartConfig/Benchmark/StartMachineConfigCategory.bytes
  2. 4 0
      Config/StartConfig/Benchmark/StartProcessConfigCategory.bytes
  3. 4 0
      Config/StartConfig/Benchmark/StartSceneConfigCategory.bytes
  4. 2 0
      Config/StartConfig/Benchmark/StartZoneConfigCategory.bytes
  5. 1 1
      Config/StartConfig/Localhost/StartProcessConfigCategory.bytes
  6. 2 0
      DotNet/App/DotNet.App.csproj
  7. 1 6
      DotNet/App/Init.cs
  8. 1 0
      DotNet/Core/DotNet.Core.csproj
  9. 1 0
      DotNet/Hotfix/DotNet.Hotfix.csproj
  10. 2 1
      DotNet/Model/DotNet.Model.csproj
  11. 1 0
      DotNet/ThirdParty/DotNet.ThirdParty.csproj
  12. 10 10
      ET.sln
  13. 1 5
      Share/Tool/Init.cs
  14. 1 1
      Share/Tool/Share.Tool.csproj
  15. 1 1
      Unity/Assets/Bundles/Config/StartConfig/Localhost/StartProcessConfigCategory.bytes
  16. 8 0
      Unity/Assets/Config/Excel/Json/s/StartConfig/Benchmark.meta
  17. 3 0
      Unity/Assets/Config/Excel/Json/s/StartConfig/Benchmark/StartMachineConfig.txt
  18. 7 0
      Unity/Assets/Config/Excel/Json/s/StartConfig/Benchmark/StartMachineConfig.txt.meta
  19. 5 0
      Unity/Assets/Config/Excel/Json/s/StartConfig/Benchmark/StartProcessConfig.txt
  20. 7 0
      Unity/Assets/Config/Excel/Json/s/StartConfig/Benchmark/StartProcessConfig.txt.meta
  21. 5 0
      Unity/Assets/Config/Excel/Json/s/StartConfig/Benchmark/StartSceneConfig.txt
  22. 7 0
      Unity/Assets/Config/Excel/Json/s/StartConfig/Benchmark/StartSceneConfig.txt.meta
  23. 3 0
      Unity/Assets/Config/Excel/Json/s/StartConfig/Benchmark/StartZoneConfig.txt
  24. 7 0
      Unity/Assets/Config/Excel/Json/s/StartConfig/Benchmark/StartZoneConfig.txt.meta
  25. 1 1
      Unity/Assets/Config/Excel/Json/s/StartConfig/Localhost/StartProcessConfig.txt
  26. 8 0
      Unity/Assets/Config/Excel/StartConfig/Benchmark.meta
  27. BIN
      Unity/Assets/Config/Excel/StartConfig/Benchmark/StartMachineConfig@s.xlsx
  28. 1 1
      Unity/Assets/Config/Excel/StartConfig/Benchmark/StartMachineConfig@s.xlsx.meta
  29. BIN
      Unity/Assets/Config/Excel/StartConfig/Benchmark/StartProcessConfig@s.xlsx
  30. 7 0
      Unity/Assets/Config/Excel/StartConfig/Benchmark/StartProcessConfig@s.xlsx.meta
  31. BIN
      Unity/Assets/Config/Excel/StartConfig/Benchmark/StartSceneConfig@s.xlsx
  32. 7 0
      Unity/Assets/Config/Excel/StartConfig/Benchmark/StartSceneConfig@s.xlsx.meta
  33. BIN
      Unity/Assets/Config/Excel/StartConfig/Benchmark/StartZoneConfig@s.xlsx
  34. 7 0
      Unity/Assets/Config/Excel/StartConfig/Benchmark/StartZoneConfig@s.xlsx.meta
  35. BIN
      Unity/Assets/Config/Excel/StartConfig/Localhost/StartProcessConfig@s.xlsx
  36. 18 0
      Unity/Assets/Config/Proto/InnerMessage_S_20001.proto
  37. 0 21
      Unity/Assets/Config/Proto/MongoMessage_S_30001.proto
  38. 13 1
      Unity/Assets/Config/Proto/OuterMessage_C_10001.proto
  39. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Login/LoginHelper.cs
  40. 2 3
      Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Router/RouterAddressComponentSystem.cs
  41. 3 13
      Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Router/RouterCheckComponentSystem.cs
  42. 2 2
      Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Router/RouterHelper.cs
  43. 22 0
      Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Session/NetClientComponentOnReadEvent.cs
  44. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Session/NetClientComponentOnReadEvent.cs.meta
  45. 0 26
      Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Session/SessionStreamDispatcherClientOuter.cs
  46. 8 0
      Unity/Assets/Scripts/Codes/Hotfix/Client/Module.meta
  47. 8 0
      Unity/Assets/Scripts/Codes/Hotfix/Client/Module/Message.meta
  48. 85 0
      Unity/Assets/Scripts/Codes/Hotfix/Client/Module/Message/NetClientComponentSystem.cs
  49. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Client/Module/Message/NetClientComponentSystem.cs.meta
  50. 2 2
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/EntryEvent2_InitServer.cs
  51. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Helper/InnerMessageDispatcherHelper.cs
  52. 10 3
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Helper/SceneFactory.cs
  53. 0 109
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Helper/SessionStreamDispatcherServerInner.cs
  54. 8 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes.meta
  55. 8 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Benchmark.meta
  56. 42 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Benchmark/BenchmarkClientComponentSystem.cs
  57. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Benchmark/BenchmarkClientComponentSystem.cs.meta
  58. 19 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Benchmark/C2G_BenchmarkHandler.cs
  59. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Benchmark/C2G_BenchmarkHandler.cs.meta
  60. 8 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate.meta
  61. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/C2G_EnterMapHandler.cs
  62. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/C2G_EnterMapHandler.cs.meta
  63. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/C2G_LoginGateHandler.cs
  64. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/C2G_LoginGateHandler.cs.meta
  65. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/C2G_PingHandler.cs
  66. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/C2G_PingHandler.cs.meta
  67. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/GateSessionKeyComponentSystem.cs
  68. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/GateSessionKeyComponentSystem.cs.meta
  69. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/PlayerComponentSystem.cs
  70. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/PlayerComponentSystem.cs.meta
  71. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/PlayerSystem.cs
  72. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/PlayerSystem.cs.meta
  73. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/R2G_GetLoginKeyHandler.cs
  74. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/R2G_GetLoginKeyHandler.cs.meta
  75. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/SessionPlayerComponentSystem.cs
  76. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/SessionPlayerComponentSystem.cs.meta
  77. 8 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map.meta
  78. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/AOI.meta
  79. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/AOI/ChangePosition_NotifyAOI.cs
  80. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/AOI/ChangePosition_NotifyAOI.cs.meta
  81. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/C2M_TestRobotCaseHandler.cs
  82. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/C2M_TestRobotCaseHandler.cs.meta
  83. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/G2M_SessionDisconnectHandler.cs
  84. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/G2M_SessionDisconnectHandler.cs.meta
  85. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Move.meta
  86. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Move/C2M_PathfindingResultHandler.cs
  87. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Move/C2M_PathfindingResultHandler.cs.meta
  88. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Move/C2M_StopHandler.cs
  89. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Move/C2M_StopHandler.cs.meta
  90. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Move/MoveHelper.cs
  91. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Move/MoveHelper.cs.meta
  92. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Transfer.meta
  93. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Transfer/C2M_TransferMapHandler.cs
  94. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Transfer/C2M_TransferMapHandler.cs.meta
  95. 3 2
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Transfer/M2M_UnitTransferRequestHandler.cs
  96. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Transfer/M2M_UnitTransferRequestHandler.cs.meta
  97. 5 3
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Transfer/TransferHelper.cs
  98. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Transfer/TransferHelper.cs.meta
  99. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Unit.meta
  100. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Unit/UnitEnterSightRange_NotifyClient.cs

+ 2 - 0
Config/StartConfig/Benchmark/StartMachineConfigCategory.bytes

@@ -0,0 +1,2 @@
+
+	127.0.0.1	127.0.0.1"10000

+ 4 - 0
Config/StartConfig/Benchmark/StartProcessConfigCategory.bytes

@@ -0,0 +1,4 @@
+
+厺
+啙
+嚌

+ 4 - 0
Config/StartConfig/Benchmark/StartSceneConfigCategory.bytes

@@ -0,0 +1,4 @@
+
++"BenchmarkServer*BenchmarkServer0’N
+,"BenchmarkClient*BenchmarkClient10“N
+,"BenchmarkClient*BenchmarkClient20”N

+ 2 - 0
Config/StartConfig/Benchmark/StartZoneConfigCategory.bytes

@@ -0,0 +1,2 @@
+
+mongodb://127.0.0.1ET1

+ 1 - 1
Config/StartConfig/Localhost/StartProcessConfigCategory.bytes

@@ -1,2 +1,2 @@
 
-
+

+ 2 - 0
DotNet/App/DotNet.App.csproj

@@ -17,12 +17,14 @@
     <DefineConstants>DOTNET</DefineConstants>
     <OutputPath>..\..\Bin\</OutputPath>
     <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
+    <Optimize>true</Optimize>
   </PropertyGroup>
 
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
     <DefineConstants>DOTNET</DefineConstants>
     <OutputPath>..\..\Bin\</OutputPath>
     <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
   </PropertyGroup>
 
   <ItemGroup>

+ 1 - 6
DotNet/App/Init.cs

@@ -16,15 +16,13 @@ namespace ET
 				};
 				
 				// 异步方法全部会回掉到主线程
-				SynchronizationContext.SetSynchronizationContext(ThreadSynchronizationContext.Instance);
+				Game.AddSingleton<MainThreadSynchronizationContext>();
 
-				
 				// 命令行参数
 				Parser.Default.ParseArguments<Options>(args)
 					.WithNotParsed(error => throw new Exception($"命令行格式错误! {error}"))
 					.WithParsed(Game.AddSingleton);
 				
-				Game.AddSingleton<RandomGenerator>();
 				Game.AddSingleton<TimeInfo>();
 				Game.AddSingleton<Logger>().ILog = new NLogger(Options.Instance.AppType.ToString(), Options.Instance.Process, "../Config/NLog/NLog.config");
 				Game.AddSingleton<ObjectPool>();
@@ -32,8 +30,6 @@ namespace ET
 				Game.AddSingleton<EventSystem>();
 				Game.AddSingleton<TimerComponent>();
 				Game.AddSingleton<CoroutineLockComponent>();
-				Game.AddSingleton<NetServices>();
-				Game.AddSingleton<Root>();
 				
 				ETTask.ExceptionHandler += Log.Error;
 
@@ -46,7 +42,6 @@ namespace ET
 					try
 					{
 						Thread.Sleep(1);
-						ThreadSynchronizationContext.Instance.Update();
 						Game.Update();
 						Game.LateUpdate();
 						Game.FrameFinishUpdate();

+ 1 - 0
DotNet/Core/DotNet.Core.csproj

@@ -18,6 +18,7 @@
       <DefineConstants>DOTNET</DefineConstants>
       <OutputPath>..\..\Bin\</OutputPath>
       <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
+      <Optimize>true</Optimize>
     </PropertyGroup>
 
     <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">  

+ 1 - 0
DotNet/Hotfix/DotNet.Hotfix.csproj

@@ -19,6 +19,7 @@
         <OutputPath>..\..\Bin\</OutputPath>
         <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
         <Optimize>false</Optimize>
+        <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     </PropertyGroup>
     <ItemGroup>
 

+ 2 - 1
DotNet/Model/DotNet.Model.csproj

@@ -14,13 +14,14 @@
         <OutputPath>..\..\Bin\</OutputPath> 
         <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
         <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
+        <Optimize>true</Optimize>
     </PropertyGroup>
     <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> 
         <DefineConstants>DOTNET</DefineConstants>
         <OutputPath>..\..\Bin\</OutputPath>
         <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
         <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
-        <Optimize>false</Optimize>
+        <Optimize>true</Optimize>
     </PropertyGroup>
     <ItemGroup>
 

+ 1 - 0
DotNet/ThirdParty/DotNet.ThirdParty.csproj

@@ -18,6 +18,7 @@
       <OutputPath>..\..\Bin\</OutputPath>
       <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
       <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
+      <Optimize>true</Optimize>
     </PropertyGroup>
     
     <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">

+ 10 - 10
ET.sln

@@ -159,8 +159,6 @@ Global
 		{770E9BEB-B313-3761-FAA2-76DAF4B34ADA}.Release|x64.Build.0 = Debug|Any CPU
 		{770E9BEB-B313-3761-FAA2-76DAF4B34ADA}.Release|x86.ActiveCfg = Debug|Any CPU
 		{770E9BEB-B313-3761-FAA2-76DAF4B34ADA}.Release|x86.Build.0 = Debug|Any CPU
-		{CCF5D7E3-D5C6-4DE6-BB2D-1A931602F1AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{CCF5D7E3-D5C6-4DE6-BB2D-1A931602F1AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{CCF5D7E3-D5C6-4DE6-BB2D-1A931602F1AB}.Debug|x64.ActiveCfg = Debug|Any CPU
 		{CCF5D7E3-D5C6-4DE6-BB2D-1A931602F1AB}.Debug|x64.Build.0 = Debug|Any CPU
 		{CCF5D7E3-D5C6-4DE6-BB2D-1A931602F1AB}.Debug|x86.ActiveCfg = Debug|Any CPU
@@ -171,8 +169,8 @@ Global
 		{CCF5D7E3-D5C6-4DE6-BB2D-1A931602F1AB}.Release|x64.Build.0 = Release|Any CPU
 		{CCF5D7E3-D5C6-4DE6-BB2D-1A931602F1AB}.Release|x86.ActiveCfg = Release|Any CPU
 		{CCF5D7E3-D5C6-4DE6-BB2D-1A931602F1AB}.Release|x86.Build.0 = Release|Any CPU
-		{20CA1FD3-A23B-4F12-ADA5-C3B759814F9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{20CA1FD3-A23B-4F12-ADA5-C3B759814F9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{CCF5D7E3-D5C6-4DE6-BB2D-1A931602F1AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{CCF5D7E3-D5C6-4DE6-BB2D-1A931602F1AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{20CA1FD3-A23B-4F12-ADA5-C3B759814F9D}.Debug|x64.ActiveCfg = Debug|Any CPU
 		{20CA1FD3-A23B-4F12-ADA5-C3B759814F9D}.Debug|x64.Build.0 = Debug|Any CPU
 		{20CA1FD3-A23B-4F12-ADA5-C3B759814F9D}.Debug|x86.ActiveCfg = Debug|Any CPU
@@ -183,8 +181,8 @@ Global
 		{20CA1FD3-A23B-4F12-ADA5-C3B759814F9D}.Release|x64.Build.0 = Release|Any CPU
 		{20CA1FD3-A23B-4F12-ADA5-C3B759814F9D}.Release|x86.ActiveCfg = Release|Any CPU
 		{20CA1FD3-A23B-4F12-ADA5-C3B759814F9D}.Release|x86.Build.0 = Release|Any CPU
-		{1059524B-9F01-4C3E-8A7C-6BBDD1D174C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{1059524B-9F01-4C3E-8A7C-6BBDD1D174C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{20CA1FD3-A23B-4F12-ADA5-C3B759814F9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{20CA1FD3-A23B-4F12-ADA5-C3B759814F9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{1059524B-9F01-4C3E-8A7C-6BBDD1D174C7}.Debug|x64.ActiveCfg = Debug|Any CPU
 		{1059524B-9F01-4C3E-8A7C-6BBDD1D174C7}.Debug|x64.Build.0 = Debug|Any CPU
 		{1059524B-9F01-4C3E-8A7C-6BBDD1D174C7}.Debug|x86.ActiveCfg = Debug|Any CPU
@@ -195,8 +193,8 @@ Global
 		{1059524B-9F01-4C3E-8A7C-6BBDD1D174C7}.Release|x64.Build.0 = Release|Any CPU
 		{1059524B-9F01-4C3E-8A7C-6BBDD1D174C7}.Release|x86.ActiveCfg = Release|Any CPU
 		{1059524B-9F01-4C3E-8A7C-6BBDD1D174C7}.Release|x86.Build.0 = Release|Any CPU
-		{6AFC109E-85DE-4A14-9C81-95D93C3F90AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{6AFC109E-85DE-4A14-9C81-95D93C3F90AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{1059524B-9F01-4C3E-8A7C-6BBDD1D174C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{1059524B-9F01-4C3E-8A7C-6BBDD1D174C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{6AFC109E-85DE-4A14-9C81-95D93C3F90AE}.Debug|x64.ActiveCfg = Debug|Any CPU
 		{6AFC109E-85DE-4A14-9C81-95D93C3F90AE}.Debug|x64.Build.0 = Debug|Any CPU
 		{6AFC109E-85DE-4A14-9C81-95D93C3F90AE}.Debug|x86.ActiveCfg = Debug|Any CPU
@@ -207,8 +205,8 @@ Global
 		{6AFC109E-85DE-4A14-9C81-95D93C3F90AE}.Release|x64.Build.0 = Release|Any CPU
 		{6AFC109E-85DE-4A14-9C81-95D93C3F90AE}.Release|x86.ActiveCfg = Release|Any CPU
 		{6AFC109E-85DE-4A14-9C81-95D93C3F90AE}.Release|x86.Build.0 = Release|Any CPU
-		{4B15C845-B5BD-4105-AE91-9B057F8AC134}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{4B15C845-B5BD-4105-AE91-9B057F8AC134}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{6AFC109E-85DE-4A14-9C81-95D93C3F90AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{6AFC109E-85DE-4A14-9C81-95D93C3F90AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{4B15C845-B5BD-4105-AE91-9B057F8AC134}.Debug|x64.ActiveCfg = Debug|Any CPU
 		{4B15C845-B5BD-4105-AE91-9B057F8AC134}.Debug|x64.Build.0 = Debug|Any CPU
 		{4B15C845-B5BD-4105-AE91-9B057F8AC134}.Debug|x86.ActiveCfg = Debug|Any CPU
@@ -219,6 +217,8 @@ Global
 		{4B15C845-B5BD-4105-AE91-9B057F8AC134}.Release|x64.Build.0 = Release|Any CPU
 		{4B15C845-B5BD-4105-AE91-9B057F8AC134}.Release|x86.ActiveCfg = Release|Any CPU
 		{4B15C845-B5BD-4105-AE91-9B057F8AC134}.Release|x86.Build.0 = Release|Any CPU
+		{4B15C845-B5BD-4105-AE91-9B057F8AC134}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{4B15C845-B5BD-4105-AE91-9B057F8AC134}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{FCB2EF97-BA34-49F7-B859-68E1AC98877E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{FCB2EF97-BA34-49F7-B859-68E1AC98877E}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{FCB2EF97-BA34-49F7-B859-68E1AC98877E}.Debug|x64.ActiveCfg = Debug|Any CPU

+ 1 - 5
Share/Tool/Init.cs

@@ -14,20 +14,16 @@ namespace ET.Server
                 Log.Error(e.ExceptionObject.ToString());
             };
             
-            // 异步方法全部会回掉到主线程
-            SynchronizationContext.SetSynchronizationContext(ThreadSynchronizationContext.Instance);
-			
             try
             {
                 // 异步方法全部会回掉到主线程
-                SynchronizationContext.SetSynchronizationContext(ThreadSynchronizationContext.Instance);
+                Game.AddSingleton<MainThreadSynchronizationContext>();
 				
                 // 命令行参数
                 Parser.Default.ParseArguments<Options>(args)
                     .WithNotParsed(error => throw new Exception($"命令行格式错误! {error}"))
                     .WithParsed(Game.AddSingleton);
 				
-                Game.AddSingleton<RandomGenerator>();
                 Game.AddSingleton<TimeInfo>();
                 Game.AddSingleton<Logger>().ILog = new NLogger(Options.Instance.AppType.ToString(), Options.Instance.Process, "../Config/NLog/NLog.config");
                 Game.AddSingleton<ObjectPool>();

+ 1 - 1
Share/Tool/Share.Tool.csproj

@@ -43,7 +43,7 @@
             <Link>Module\Log\%(RecursiveDir)%(FileName)%(Extension)</Link>
         </Compile>
 
-        <Compile Include="..\..\Unity\Assets\Scripts\Codes\Model\Share\Module\Message\OpcodeRangeDefine.cs">
+        <Compile Include="..\..\Unity\Assets\Scripts\Core\Module\Network\OpcodeRangeDefine.cs">
             <Link>Module\Message\OpcodeRangeDefine.cs</Link>
         </Compile>
     </ItemGroup>

+ 1 - 1
Unity/Assets/Bundles/Config/StartConfig/Localhost/StartProcessConfigCategory.bytes

@@ -1,2 +1,2 @@
 
-
+

+ 8 - 0
Unity/Assets/Config/Excel/Json/s/StartConfig/Benchmark.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: e716f09144a65404f81177d691db103d
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 3 - 0
Unity/Assets/Config/Excel/Json/s/StartConfig/Benchmark/StartMachineConfig.txt

@@ -0,0 +1,3 @@
+{"list":[
+{"_t":"StartMachineConfig","_id":1,"InnerIP":"127.0.0.1","OuterIP":"127.0.0.1","WatcherPort":"10000"},
+]}

+ 7 - 0
Unity/Assets/Config/Excel/Json/s/StartConfig/Benchmark/StartMachineConfig.txt.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 599f63029f863ec46933bd9c7f57e682
+TextScriptImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 5 - 0
Unity/Assets/Config/Excel/Json/s/StartConfig/Benchmark/StartProcessConfig.txt

@@ -0,0 +1,5 @@
+{"list":[
+{"_t":"StartProcessConfig","_id":1,"MachineId":1,"InnerPort":20101},
+{"_t":"StartProcessConfig","_id":2,"MachineId":1,"InnerPort":20102},
+{"_t":"StartProcessConfig","_id":3,"MachineId":1,"InnerPort":20103},
+]}

+ 7 - 0
Unity/Assets/Config/Excel/Json/s/StartConfig/Benchmark/StartProcessConfig.txt.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: daedfec9735536b46a1fef4d3a9683e7
+TextScriptImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 5 - 0
Unity/Assets/Config/Excel/Json/s/StartConfig/Benchmark/StartSceneConfig.txt

@@ -0,0 +1,5 @@
+{"list":[
+{"_t":"StartSceneConfig","_id":1,"Process":1,"Zone":1,"SceneType":"BenchmarkServer","Name":"BenchmarkServer","OuterPort":10002},
+{"_t":"StartSceneConfig","_id":2,"Process":2,"Zone":1,"SceneType":"BenchmarkClient","Name":"BenchmarkClient1","OuterPort":10003},
+{"_t":"StartSceneConfig","_id":3,"Process":3,"Zone":1,"SceneType":"BenchmarkClient","Name":"BenchmarkClient2","OuterPort":10004},
+]}

+ 7 - 0
Unity/Assets/Config/Excel/Json/s/StartConfig/Benchmark/StartSceneConfig.txt.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 78a8b84339602ae479d57adc2c3653c5
+TextScriptImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 3 - 0
Unity/Assets/Config/Excel/Json/s/StartConfig/Benchmark/StartZoneConfig.txt

@@ -0,0 +1,3 @@
+{"list":[
+{"_t":"StartZoneConfig","_id":1,"DBConnection":"mongodb://127.0.0.1","DBName":"ET1"},
+]}

+ 7 - 0
Unity/Assets/Config/Excel/Json/s/StartConfig/Benchmark/StartZoneConfig.txt.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 97a8e81e26b5ae14b9dabc4c3a62f435
+TextScriptImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 1 - 1
Unity/Assets/Config/Excel/Json/s/StartConfig/Localhost/StartProcessConfig.txt

@@ -1,3 +1,3 @@
 {"list":[
-{"_t":"StartProcessConfig","_id":1,"MachineId":1,"InnerPort":20001},
+{"_t":"StartProcessConfig","_id":1,"MachineId":1,"InnerPort":20101},
 ]}

+ 8 - 0
Unity/Assets/Config/Excel/StartConfig/Benchmark.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 1ac7bf9ce8fc4ad46bd02dcb08165b1f
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

BIN
Unity/Assets/Config/Excel/StartConfig/Benchmark/StartMachineConfig@s.xlsx


+ 1 - 1
Unity/Assets/Config/Proto/MongoMessage_S_30001.proto.meta → Unity/Assets/Config/Excel/StartConfig/Benchmark/StartMachineConfig@s.xlsx.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 11a04304135cefb46ad32d0a1ae88064
+guid: 03fee2b7103050f478a689d2785db7e9
 DefaultImporter:
   externalObjects: {}
   userData: 

BIN
Unity/Assets/Config/Excel/StartConfig/Benchmark/StartProcessConfig@s.xlsx


+ 7 - 0
Unity/Assets/Config/Excel/StartConfig/Benchmark/StartProcessConfig@s.xlsx.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: bc469d982414eb143bcf5791b3822164
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

BIN
Unity/Assets/Config/Excel/StartConfig/Benchmark/StartSceneConfig@s.xlsx


+ 7 - 0
Unity/Assets/Config/Excel/StartConfig/Benchmark/StartSceneConfig@s.xlsx.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: cdee8addbf3a11249b9b4fba7f31a153
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

BIN
Unity/Assets/Config/Excel/StartConfig/Benchmark/StartZoneConfig@s.xlsx


+ 7 - 0
Unity/Assets/Config/Excel/StartConfig/Benchmark/StartZoneConfig@s.xlsx.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: ed6f82bcc72d949458b8787862d71c29
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

BIN
Unity/Assets/Config/Excel/StartConfig/Localhost/StartProcessConfig@s.xlsx


+ 18 - 0
Unity/Assets/Config/Proto/InnerMessage_S_20001.proto

@@ -153,4 +153,22 @@ message M2M_UnitTransferResponse // IActorResponse
 message G2M_SessionDisconnect // IActorLocationMessage
 {
 	int32 RpcId = 90;
+}
+
+message ObjectQueryResponse // IActorResponse
+{
+	int32 RpcId = 90;
+	int32 Error = 91;
+	string Message = 92;
+
+	bytes entity = 1;
+}
+
+
+//ResponseType M2M_UnitTransferResponse
+message M2M_UnitTransferRequest // IActorRequest
+{
+	int32 RpcId = 1;
+	bytes Unit = 2;
+	repeated bytes Entitys = 3;
 }

+ 0 - 21
Unity/Assets/Config/Proto/MongoMessage_S_30001.proto

@@ -1,21 +0,0 @@
-syntax = "proto3";
-package ET;
-
-
-message ObjectQueryResponse // IActorResponse
-{
-	int32 RpcId = 90;
-	int32 Error = 91;
-	string Message = 92;
-
-	Entity entity = 1;
-}
-
-
-//ResponseType M2M_UnitTransferResponse
-message M2M_UnitTransferRequest // IActorRequest
-{
-	int32 RpcId = 1;
-	Unit Unit = 2;
-	repeated Entity Entitys = 3;
-}

+ 13 - 1
Unity/Assets/Config/Proto/OuterMessage_C_10001.proto

@@ -250,4 +250,16 @@ message M2C_TransferMap // IActorLocationResponse
 	int32 Error = 91;
 	string Message = 92;
 }
- 
+
+//ResponseType G2C_Benchmark
+message C2G_Benchmark // IRequest
+{
+	int32 RpcId = 90;
+}
+
+message G2C_Benchmark // IResponse
+{
+	int32 RpcId = 90;
+	int32 Error = 91;
+	string Message = 92;
+}

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Login/LoginHelper.cs

@@ -19,7 +19,7 @@ namespace ET.Client
                     routerAddressComponent = clientScene.AddComponent<RouterAddressComponent, string, int>(ConstValue.RouterHttpHost, ConstValue.RouterHttpPort);
                     await routerAddressComponent.Init();
                     
-                    clientScene.AddComponent<NetKcpComponent, AddressFamily, int>(routerAddressComponent.RouterManagerIPAddress.AddressFamily, SessionStreamCallbackId.SessionStreamDispatcherClientOuter);
+                    clientScene.AddComponent<NetClientComponent, AddressFamily>(routerAddressComponent.RouterManagerIPAddress.AddressFamily);
                 }
                 IPEndPoint realmAddress = routerAddressComponent.GetRealmAddress(account);
                 

+ 2 - 3
Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Router/RouterAddressComponentSystem.cs

@@ -2,7 +2,6 @@
 using System.IO;
 using System.Net;
 using System.Net.Sockets;
-using System.Runtime.InteropServices;
 
 namespace ET.Client
 {
@@ -26,7 +25,7 @@ namespace ET.Client
 
         private static async ETTask GetAllRouter(this RouterAddressComponent self)
         {
-            string url = $"http://{self.RouterManagerHost}:{self.RouterManagerPort}/get_router?v={RandomGenerator.Instance.RandUInt32()}";
+            string url = $"http://{self.RouterManagerHost}:{self.RouterManagerPort}/get_router?v={RandomGenerator.RandUInt32()}";
             Log.Debug($"start get router info: {url}");
             string routerInfo = await HttpClientHelper.Get(url);
             Log.Debug($"recv router info: {routerInfo}");
@@ -35,7 +34,7 @@ namespace ET.Client
             Log.Debug($"start get router info finish: {JsonHelper.ToJson(httpGetRouterResponse)}");
             
             // 打乱顺序
-            RandomGenerator.Instance.BreakRank(self.Info.Routers);
+            RandomGenerator.BreakRank(self.Info.Routers);
             
             self.WaitTenMinGetAllRouter().Coroutine();
         }

+ 3 - 13
Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Router/RouterCheckComponentSystem.cs

@@ -40,19 +40,9 @@ namespace ET.Client
                 try
                 {
                     long sessionId = session.Id;
-                    uint localConn = 0;
-                    uint remoteConn = 0;
-                    KService service = session.AService as KService;
-                    KChannel kChannel = service.Get(sessionId);
-                    if (kChannel == null)
-                    {
-                        Log.Warning($"not found remoteConn: {sessionId}");
-                        continue;
-                    }
-
-                    localConn = kChannel.LocalConn;
-                    remoteConn = kChannel.RemoteConn;
 
+                    (uint localConn, uint remoteConn) = await NetServices.Instance.GetKChannelConn(session.ServiceId, sessionId);
+                    
                     IPEndPoint realAddress = self.GetParent<Session>().RemoteAddress;
                     Log.Info($"get recvLocalConn start: {self.ClientScene().Id} {realAddress} {localConn} {remoteConn}");
 
@@ -67,7 +57,7 @@ namespace ET.Client
                     
                     session.LastRecvTime = TimeHelper.ClientNow();
                     
-                    ((KService)session.AService).ChangeAddress(sessionId, routerAddress);
+                    NetServices.Instance.ChangeAddress(session.ServiceId, sessionId, routerAddress);
                 }
                 catch (Exception e)
                 {

+ 2 - 2
Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Router/RouterHelper.cs

@@ -18,7 +18,7 @@ namespace ET.Client
             
             Log.Info($"get router: {recvLocalConn} {routerAddress}");
 
-            Session routerSession = clientScene.GetComponent<NetKcpComponent>().Create(routerAddress, address, recvLocalConn);
+            Session routerSession = clientScene.GetComponent<NetClientComponent>().Create(routerAddress, address, recvLocalConn);
             routerSession.AddComponent<PingComponent>();
             routerSession.AddComponent<RouterCheckComponent>();
             
@@ -41,7 +41,7 @@ namespace ET.Client
         // 向router申请
         private static async ETTask<uint> Connect(IPEndPoint routerAddress, IPEndPoint realAddress, uint localConn, uint remoteConn)
         {
-            uint connectId = RandomGenerator.Instance.RandUInt32();
+            uint connectId = RandomGenerator.RandUInt32();
             
             using Socket socket = new Socket(routerAddress.AddressFamily, SocketType.Dgram, ProtocolType.Udp);
             

+ 22 - 0
Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Session/NetClientComponentOnReadEvent.cs

@@ -0,0 +1,22 @@
+namespace ET.Client
+{
+    [Event(SceneType.Process)]
+    public class NetClientComponentOnReadEvent: AEvent<NetClientComponentOnRead>
+    {
+        protected override async ETTask Run(Scene scene, NetClientComponentOnRead args)
+        {
+            Session session = args.Session;
+            object message = args.Message;
+            if (message is IResponse response)
+            {
+                session.OnResponse(response);
+                return;
+            }
+
+            OpcodeHelper.LogMsg(session.DomainZone(), message);
+            // 普通消息或者是Rpc请求消息
+            MessageDispatcherComponent.Instance.Handle(session, message);
+            await ETTask.CompletedTask;
+        }
+    }
+}

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Helper/SessionStreamDispatcherServerInner.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Session/NetClientComponentOnReadEvent.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: d857f83aa8437dd47875cfba93f7c514
+guid: 6b4dd37b5016f8a4aae643980803e761
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 0 - 26
Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Session/SessionStreamDispatcherClientOuter.cs

@@ -1,26 +0,0 @@
-using System;
-using System.IO;
-
-namespace ET.Client
-{
-    [Callback(SessionStreamCallbackId.SessionStreamDispatcherClientOuter)]
-    public class SessionStreamDispatcherClientOuter: ACallbackHandler<SessionStreamCallback>
-    {
-        public override void Handle(SessionStreamCallback sessionStreamCallback)
-        {
-            ushort opcode = BitConverter.ToUInt16(sessionStreamCallback.MemoryStream.GetBuffer(), Packet.KcpOpcodeIndex);
-            Type type = OpcodeTypeComponent.Instance.GetType(opcode);
-            object message = MessageSerializeHelper.DeserializeFrom(opcode, type, sessionStreamCallback.MemoryStream);
-            
-            if (message is IResponse response)
-            {
-                sessionStreamCallback.Session.OnRead(opcode, response);
-                return;
-            }
-
-            OpcodeHelper.LogMsg(sessionStreamCallback.Session.DomainZone(), opcode, message);
-            // 普通消息或者是Rpc请求消息
-            MessageDispatcherComponent.Instance.Handle(sessionStreamCallback.Session, opcode, message);
-        }
-    }
-}

+ 8 - 0
Unity/Assets/Scripts/Codes/Hotfix/Client/Module.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 83e42b45e303e71468c08f3d8f2d271a
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 8 - 0
Unity/Assets/Scripts/Codes/Hotfix/Client/Module/Message.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 6378fb95ea17e6d46b536062736457a5
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 85 - 0
Unity/Assets/Scripts/Codes/Hotfix/Client/Module/Message/NetClientComponentSystem.cs

@@ -0,0 +1,85 @@
+using System.Net;
+using System.Net.Sockets;
+
+namespace ET.Client
+{
+    [FriendOf(typeof(NetClientComponent))]
+    public static class NetClientComponentSystem
+    {
+        [ObjectSystem]
+        public class AwakeSystem: AwakeSystem<NetClientComponent, AddressFamily>
+        {
+            protected override void Awake(NetClientComponent self, AddressFamily addressFamily)
+            {
+                KService kService = new KService(addressFamily, ServiceType.Outer);
+                self.ServiceId = NetThreadComponent.Instance.Add(kService);
+                NetServices.Instance.RegisterReadCallback(self.ServiceId, self.OnRead);
+                NetServices.Instance.RegisterErrorCallback(self.ServiceId, self.OnError);
+            }
+        }
+
+        [ObjectSystem]
+        public class DestroySystem: DestroySystem<NetClientComponent>
+        {
+            protected override void Destroy(NetClientComponent self)
+            {
+                NetThreadComponent.Instance.Remove(self.ServiceId);
+            }
+        }
+
+        private static void OnRead(this NetClientComponent self, long channelId, long actorId, object message)
+        {
+            Session session = self.GetChild<Session>(channelId);
+            if (session == null)
+            {
+                return;
+            }
+
+            session.LastRecvTime = TimeHelper.ClientNow();
+            
+            OpcodeHelper.LogMsg(self.DomainZone(), message);
+            
+            EventSystem.Instance.Publish(Root.Instance.Scene, new NetClientComponentOnRead() {Session = session, ActorId = actorId, Message = message});
+        }
+
+        private static void OnError(this NetClientComponent self, long channelId, int error)
+        {
+            Session session = self.GetChild<Session>(channelId);
+            if (session == null)
+            {
+                return;
+            }
+
+            session.Error = error;
+            session.Dispose();
+        }
+
+        public static Session Create(this NetClientComponent self, IPEndPoint realIPEndPoint)
+        {
+            long channelId = RandomGenerator.RandInt64();
+            Session session = self.AddChildWithId<Session, int>(channelId, self.ServiceId);
+            session.RemoteAddress = realIPEndPoint;
+            if (self.DomainScene().SceneType != SceneType.BenchmarkClient)
+            {
+                session.AddComponent<SessionIdleCheckerComponent>();
+            }
+            NetServices.Instance.GetChannel(self.ServiceId, session.Id, realIPEndPoint);
+
+            return session;
+        }
+        
+        public static Session Create(this NetClientComponent self, IPEndPoint routerIPEndPoint, IPEndPoint realIPEndPoint, uint localConn)
+        {
+            long channelId = NetServices.Instance.CreateConnectChannelId(localConn);
+            Session session = self.AddChildWithId<Session, int>(channelId, self.ServiceId);
+            session.RemoteAddress = realIPEndPoint;
+            if (self.DomainScene().SceneType != SceneType.BenchmarkClient)
+            {
+                session.AddComponent<SessionIdleCheckerComponent>();
+            }
+            NetServices.Instance.GetChannel(self.ServiceId, session.Id, routerIPEndPoint);
+
+            return session;
+        }
+    }
+}

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Share/Module/Message/NetKcpComponentSystem.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Client/Module/Message/NetClientComponentSystem.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 539567d3d8f50ed4db1d4c7047f34d46
+guid: 7fb1278bab55fff4789e94463d9cbdab
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 2 - 2
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/EntryEvent2_InitServer.cs

@@ -24,7 +24,7 @@ namespace ET.Server
             {
                 case AppType.Server:
                 {
-                    Root.Instance.Scene.AddComponent<NetInnerComponent, IPEndPoint, int>(processConfig.InnerIPPort, SessionStreamCallbackId.SessionStreamDispatcherServerInner);
+                    Root.Instance.Scene.AddComponent<NetInnerComponent, IPEndPoint>(processConfig.InnerIPPort);
 
                     var processScenes = StartSceneConfigCategory.Instance.GetByProcess(Options.Instance.Process);
                     foreach (StartSceneConfig startConfig in processScenes)
@@ -40,7 +40,7 @@ namespace ET.Server
                     StartMachineConfig startMachineConfig = WatcherHelper.GetThisMachineConfig();
                     WatcherComponent watcherComponent = Root.Instance.Scene.AddComponent<WatcherComponent>();
                     watcherComponent.Start(Options.Instance.CreateScenes);
-                    Root.Instance.Scene.AddComponent<NetInnerComponent, IPEndPoint, int>(NetworkHelper.ToIPEndPoint($"{startMachineConfig.InnerIP}:{startMachineConfig.WatcherPort}"), SessionStreamCallbackId.SessionStreamDispatcherServerInner);
+                    Root.Instance.Scene.AddComponent<NetInnerComponent, IPEndPoint>(NetworkHelper.ToIPEndPoint($"{startMachineConfig.InnerIP}:{startMachineConfig.WatcherPort}"));
                     break;
                 }
                 case AppType.GameTool:

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Helper/InnerMessageDispatcherHelper.cs

@@ -67,7 +67,7 @@ namespace ET.Server
         [EnableAccessEntiyChild]
         public static void HandleIActorMessage(ushort opcode, long actorId, IActorMessage iActorMessage)
         {
-            OpcodeHelper.LogMsg(opcode, actorId, iActorMessage);
+            OpcodeHelper.LogMsg(actorId, iActorMessage);
 
             Entity entity = EventSystem.Instance.Get(actorId);
             if (entity == null)

+ 10 - 3
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Helper/SceneFactory.cs

@@ -1,4 +1,5 @@
 using System.Net;
+using System.Net.Sockets;
 
 namespace ET.Server
 {
@@ -22,10 +23,10 @@ namespace ET.Server
                     scene.AddComponent<HttpComponent, string>($"http://{startSceneConfig.OuterIPPort}/");
                     break;
                 case SceneType.Realm:
-                    scene.AddComponent<NetKcpComponent, IPEndPoint, int>(startSceneConfig.InnerIPOutPort, SessionStreamCallbackId.SessionStreamDispatcherServerOuter);
+                    scene.AddComponent<NetServerComponent, IPEndPoint>(startSceneConfig.InnerIPOutPort);
                     break;
                 case SceneType.Gate:
-                    scene.AddComponent<NetKcpComponent, IPEndPoint, int>(startSceneConfig.InnerIPOutPort, SessionStreamCallbackId.SessionStreamDispatcherServerOuter);
+                    scene.AddComponent<NetServerComponent, IPEndPoint>(startSceneConfig.InnerIPOutPort);
                     scene.AddComponent<PlayerComponent>();
                     scene.AddComponent<GateSessionKeyComponent>();
                     break;
@@ -38,7 +39,13 @@ namespace ET.Server
                     break;
                 case SceneType.Robot:
                     scene.AddComponent<RobotManagerComponent>();
-                    
+                    break;
+                case SceneType.BenchmarkServer:
+                    scene.AddComponent<BenchmarkServerComponent>();
+                    scene.AddComponent<NetServerComponent, IPEndPoint>(startSceneConfig.OuterIPPort);
+                    break;
+                case SceneType.BenchmarkClient:
+                    scene.AddComponent<BenchmarkClientComponent>();
                     break;
             }
 

+ 0 - 109
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Helper/SessionStreamDispatcherServerInner.cs

@@ -1,109 +0,0 @@
-using System;
-using System.IO;
-
-namespace ET.Server
-{
-    [Callback(SessionStreamCallbackId.SessionStreamDispatcherServerInner)]
-    public class SessionStreamDispatcherServerInner: ACallbackHandler<SessionStreamCallback>
-    {
-        public override void Handle(SessionStreamCallback args)
-        {
-            Session session = args.Session;
-            MemoryStream memoryStream = args.MemoryStream;
-            ushort opcode = 0;
-            try
-            {
-                long actorId = BitConverter.ToInt64(memoryStream.GetBuffer(), Packet.ActorIdIndex);
-                opcode = BitConverter.ToUInt16(memoryStream.GetBuffer(), Packet.OpcodeIndex);
-                Type type = null;
-                object message = null;
-
-                // 内网收到外网消息,有可能是gateUnit消息,还有可能是gate广播消息
-                if (OpcodeTypeComponent.Instance.IsOutrActorMessage(opcode))
-                {
-                    InstanceIdStruct instanceIdStruct = new InstanceIdStruct(actorId);
-                    instanceIdStruct.Process = Options.Instance.Process;
-                    long realActorId = instanceIdStruct.ToLong();
-                    
-                    
-                    Entity entity = EventSystem.Instance.Get(realActorId);
-                    if (entity == null)
-                    {
-                        type = OpcodeTypeComponent.Instance.GetType(opcode);
-                        message = MessageSerializeHelper.DeserializeFrom(opcode, type, memoryStream);
-                        Log.Error($"not found actor: {session.DomainScene().Name}  {opcode} {realActorId} {message}");
-                        return;
-                    }
-                    
-                    if (entity is Session gateSession)
-                    {
-                        // 发送给客户端
-                        memoryStream.Seek(Packet.OpcodeIndex, SeekOrigin.Begin);
-                        gateSession.Send(0, memoryStream);
-                        return;
-                    }
-                }
-
-                type = OpcodeTypeComponent.Instance.GetType(opcode);
-                message = MessageSerializeHelper.DeserializeFrom(opcode, type, memoryStream);
-
-                if (message is IResponse iResponse && !(message is IActorResponse))
-                {
-                    session.OnRead(opcode, iResponse);
-                    return;
-                }
-
-                OpcodeHelper.LogMsg(session.DomainZone(), opcode, message);
-
-                // 收到actor消息,放入actor队列
-                switch (message)
-                {
-                    case IActorRequest iActorRequest:
-                    {
-                        InstanceIdStruct instanceIdStruct = new InstanceIdStruct(actorId);
-                        int fromProcess = instanceIdStruct.Process;
-                        instanceIdStruct.Process = Options.Instance.Process;
-                        long realActorId = instanceIdStruct.ToLong();
-                        
-                        void Reply(IActorResponse response)
-                        {
-                            Session replySession = NetInnerComponent.Instance.Get(fromProcess);
-                            // 发回真实的actorId 做查问题使用
-                            replySession.Send(realActorId, response);
-                        }
-
-                        InnerMessageDispatcherHelper.HandleIActorRequest(opcode, realActorId, iActorRequest, Reply);
-                        return;
-                    }
-                    case IActorResponse iActorResponse:
-                    {
-                        InstanceIdStruct instanceIdStruct = new InstanceIdStruct(actorId);
-                        instanceIdStruct.Process = Options.Instance.Process;
-                        long realActorId = instanceIdStruct.ToLong();
-                        InnerMessageDispatcherHelper.HandleIActorResponse(opcode, realActorId, iActorResponse);
-                        return;
-                    }
-                    case IActorMessage iactorMessage:
-                    {
-                        InstanceIdStruct instanceIdStruct = new InstanceIdStruct(actorId);
-                        instanceIdStruct.Process = Options.Instance.Process;
-                        long realActorId = instanceIdStruct.ToLong();
-                        InnerMessageDispatcherHelper.HandleIActorMessage(opcode, realActorId, iactorMessage);
-                        return;
-                    }
-                    default:
-                    {
-                        MessageDispatcherComponent.Instance.Handle(session, opcode, message);
-                        break;
-                    }
-                }
-            }
-            catch (Exception e)
-            {
-                Log.Error($"InnerMessageDispatcher error: {opcode}\n{e}");
-            }
-        }
-
-
-    }
-}

+ 8 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 1020089e1cc94854f8c609e90cd52717
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 8 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Benchmark.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: fb5bd93163a7603438eb1431a0a211a3
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 42 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Benchmark/BenchmarkClientComponentSystem.cs

@@ -0,0 +1,42 @@
+using System.Collections.Generic;
+using System.Net.Sockets;
+using ET.Client;
+
+namespace ET.Server
+{
+    public static class BenchmarkClientComponentSystem
+    {
+        public class AwakeSystem: AwakeSystem<BenchmarkClientComponent>
+        {
+            protected override void Awake(BenchmarkClientComponent self)
+            {
+                for (int i = 0; i < 50; ++i)
+                {
+                    self.Start().Coroutine();
+                }
+            }
+        }
+
+        private static async ETTask Start(this BenchmarkClientComponent self)
+        {
+            await TimerComponent.Instance.WaitAsync(1000);
+
+            Scene scene = await SceneFactory.CreateServerScene(self, IdGenerater.Instance.GenerateId(), IdGenerater.Instance.GenerateInstanceId(),
+                self.DomainZone(), "bechmark", SceneType.BenchmarkClient);
+            
+            NetClientComponent netClientComponent = scene.AddComponent<NetClientComponent, AddressFamily>(AddressFamily.InterNetwork);
+
+            using Session session = netClientComponent.Create(StartSceneConfigCategory.Instance.BenchmarkServer.OuterIPPort);
+            List<ETTask<IResponse>> list = new List<ETTask<IResponse>>(100000);
+            for (int j = 0; j < 100000000; ++j)
+            {
+                list.Clear();
+                for (int i = 0; i < list.Capacity; ++i)
+                {
+                    list.Add(session.Call(new C2G_Benchmark()));
+                }
+                await ETTaskHelper.WaitAll(list);
+            }
+        }
+    }
+}

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Helper/SessionStreamDispatcherServerOuter.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Benchmark/BenchmarkClientComponentSystem.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: ad3ec669a606f3c428d6510d22ee19c1
+guid: 9a7a85a66452bf3488c137e5c2caaf2a
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 19 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Benchmark/C2G_BenchmarkHandler.cs

@@ -0,0 +1,19 @@
+using System;
+
+namespace ET.Server
+{
+    [MessageHandler(SceneType.BenchmarkServer)]
+    public class C2G_BenchmarkHandler: AMRpcHandler<C2G_Benchmark, G2C_Benchmark>
+    {
+        protected override async ETTask Run(Session session, C2G_Benchmark request, G2C_Benchmark response, Action reply)
+        {            
+            BenchmarkServerComponent benchmarkServerComponent = session.DomainScene().GetComponent<BenchmarkServerComponent>();
+            if (benchmarkServerComponent.Count++ % 1000000 == 0)
+            {
+                Log.Debug($"benchmark count: {benchmarkServerComponent.Count} {TimeHelper.ClientNow()}");
+            }
+            reply();
+            await ETTask.CompletedTask;
+        }
+    }
+}

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Session/SessionStreamDispatcherClientOuter.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Benchmark/C2G_BenchmarkHandler.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 6e099bf7aa1418e4d97079e85de636ac
+guid: f26aed201cdde2142bab5f5c301087e9
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 8 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 809d1d711564bc74d990a54937767a79
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Gate/C2G_EnterMapHandler.cs → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/C2G_EnterMapHandler.cs


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Gate/C2G_EnterMapHandler.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/C2G_EnterMapHandler.cs.meta


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Gate/C2G_LoginGateHandler.cs → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/C2G_LoginGateHandler.cs


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Gate/C2G_LoginGateHandler.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/C2G_LoginGateHandler.cs.meta


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Gate/C2G_PingHandler.cs → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/C2G_PingHandler.cs


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Gate/C2G_PingHandler.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/C2G_PingHandler.cs.meta


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Gate/GateSessionKeyComponentSystem.cs → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/GateSessionKeyComponentSystem.cs


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Gate/GateSessionKeyComponentSystem.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/GateSessionKeyComponentSystem.cs.meta


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Gate/PlayerComponentSystem.cs → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/PlayerComponentSystem.cs


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Gate/PlayerComponentSystem.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/PlayerComponentSystem.cs.meta


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Gate/PlayerSystem.cs → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/PlayerSystem.cs


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Gate/PlayerSystem.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/PlayerSystem.cs.meta


+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Gate/R2G_GetLoginKeyHandler.cs → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/R2G_GetLoginKeyHandler.cs

@@ -8,7 +8,7 @@ namespace ET.Server
 	{
 		protected override async ETTask Run(Scene scene, R2G_GetLoginKey request, G2R_GetLoginKey response, Action reply)
 		{
-			long key = RandomGenerator.Instance.RandInt64();
+			long key = RandomGenerator.RandInt64();
 			scene.GetComponent<GateSessionKeyComponent>().Add(key, request.Account);
 			response.Key = key;
 			response.GateId = scene.Id;

+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Gate/R2G_GetLoginKeyHandler.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/R2G_GetLoginKeyHandler.cs.meta


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Gate/SessionPlayerComponentSystem.cs → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/SessionPlayerComponentSystem.cs


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Gate/SessionPlayerComponentSystem.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/SessionPlayerComponentSystem.cs.meta


+ 8 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 5465ba9a6b420c8458ffaf84f2c50261
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Map/AOI.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/AOI.meta


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Map/AOI/ChangePosition_NotifyAOI.cs → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/AOI/ChangePosition_NotifyAOI.cs


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Map/AOI/ChangePosition_NotifyAOI.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/AOI/ChangePosition_NotifyAOI.cs.meta


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Map/C2M_TestRobotCaseHandler.cs → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/C2M_TestRobotCaseHandler.cs


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Map/C2M_TestRobotCaseHandler.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/C2M_TestRobotCaseHandler.cs.meta


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Map/G2M_SessionDisconnectHandler.cs → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/G2M_SessionDisconnectHandler.cs


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Map/G2M_SessionDisconnectHandler.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/G2M_SessionDisconnectHandler.cs.meta


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Map/Move.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Move.meta


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Map/Move/C2M_PathfindingResultHandler.cs → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Move/C2M_PathfindingResultHandler.cs


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Map/Move/C2M_PathfindingResultHandler.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Move/C2M_PathfindingResultHandler.cs.meta


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Map/Move/C2M_StopHandler.cs → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Move/C2M_StopHandler.cs


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Map/Move/C2M_StopHandler.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Move/C2M_StopHandler.cs.meta


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Map/Move/MoveHelper.cs → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Move/MoveHelper.cs


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Map/Move/MoveHelper.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Move/MoveHelper.cs.meta


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Map/Transfer.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Transfer.meta


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Map/Transfer/C2M_TransferMapHandler.cs → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Transfer/C2M_TransferMapHandler.cs


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Map/Transfer/C2M_TransferMapHandler.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Transfer/C2M_TransferMapHandler.cs.meta


+ 3 - 2
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Map/Transfer/M2M_UnitTransferRequestHandler.cs → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Transfer/M2M_UnitTransferRequestHandler.cs

@@ -10,13 +10,14 @@ namespace ET.Server
 		{
 			await ETTask.CompletedTask;
 			UnitComponent unitComponent = scene.GetComponent<UnitComponent>();
-			Unit unit = request.Unit;
+			Unit unit = MongoHelper.FromBson<Unit>(request.Unit);
 			
 			unitComponent.AddChild(unit);
 			unitComponent.Add(unit);
 
-			foreach (Entity entity in request.Entitys)
+			foreach (byte[] bytes in request.Entitys)
 			{
+				Entity entity = MongoHelper.FromBson<Entity>(bytes);
 				unit.AddComponent(entity);
 			}
 			

+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Map/Transfer/M2M_UnitTransferRequestHandler.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Transfer/M2M_UnitTransferRequestHandler.cs.meta


+ 5 - 3
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Map/Transfer/TransferHelper.cs → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Transfer/TransferHelper.cs

@@ -1,4 +1,6 @@
-namespace ET.Server
+using MongoDB.Bson;
+
+namespace ET.Server
 {
     public static class TransferHelper
     {
@@ -9,12 +11,12 @@
             MessageHelper.SendToClient(unit, m2CStartSceneChange);
             
             M2M_UnitTransferRequest request = new M2M_UnitTransferRequest();
-            request.Unit = unit;
+            request.Unit = unit.ToBson();
             foreach (Entity entity in unit.Components.Values)
             {
                 if (entity is ITransfer)
                 {
-                    request.Entitys.Add(entity);
+                    request.Entitys.Add(entity.ToBson());
                 }
             }
             // 删除Mailbox,让发给Unit的ActorLocation消息重发

+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Map/Transfer/TransferHelper.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Transfer/TransferHelper.cs.meta


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Map/Unit.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Unit.meta


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Map/Unit/UnitEnterSightRange_NotifyClient.cs → Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Unit/UnitEnterSightRange_NotifyClient.cs


Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików