Răsfoiți Sursa

重构了一下Actor消息,把拦截器的概念去掉了,改成MailboxType,不同的mailbox类型有相应的处理,比如:
gate session类型的就交给MailboxGateSessionHandler处理,它会把actor消息转发给客户端,
其它的基本上默认是MessageDispatcher类型的mailbox,交给MailboxMessageDispatcherHandler处理,它会对actor消息进行分发处理

tanghai 7 ani în urmă
părinte
comite
67e4883c82
82 a modificat fișierele cu 303 adăugiri și 290 ștergeri
  1. 33 7
      Server/App/Program.cs
  2. 85 0
      Server/Hotfix/Module/Actor/ActorMessageDispatcherComponentSystem.cs
  3. 0 118
      Server/Hotfix/Module/Actor/ActorMessageDispatherComponentSystem.cs
  4. 1 2
      Server/Hotfix/Module/Actor/ActorMessageSenderHelper.cs
  5. 6 8
      Server/Hotfix/Module/Actor/MailBoxComponentSystem.cs
  6. 79 0
      Server/Hotfix/Module/Actor/MailboxDispatcherComponentSystem.cs
  7. 3 4
      Server/Hotfix/Module/Actor/MailboxGateSessionHandler.cs
  8. 25 0
      Server/Hotfix/Module/Actor/MailboxMessageDispatcherHandler.cs
  9. 1 1
      Server/Hotfix/Module/Demo/C2G_LoginGateHandler.cs
  10. 0 1
      Server/Hotfix/Module/Demo/MessageHelper.cs
  11. 1 3
      Server/Model/Base/Helper/DllHelper.cs
  12. 0 1
      Server/Model/Module/Actor/AMActorHandler.cs
  13. 0 1
      Server/Model/Module/Actor/AMActorRpcHandler.cs
  14. 0 8
      Server/Model/Module/Actor/ActorInterceptType.cs
  15. 0 17
      Server/Model/Module/Actor/ActorInterceptTypeHandlerAttribute.cs
  16. 1 4
      Server/Model/Module/Actor/ActorMessageDispatcherComponent.cs
  17. 1 3
      Server/Model/Module/Actor/ActorMessageHandlerAttribute.cs
  18. 0 1
      Server/Model/Module/Actor/IMActorHandler.cs
  19. 1 1
      Server/Model/Module/Actor/IMailboxHandler.cs
  20. 2 3
      Server/Model/Module/Actor/MailBoxComponent.cs
  21. 23 0
      Server/Model/Module/Actor/MailboxDispatcherComponent.cs
  22. 15 0
      Server/Model/Module/Actor/MailboxHandlerAttribute.cs
  23. 8 0
      Server/Model/Module/Actor/MailboxType.cs
  24. 0 1
      Server/Model/Module/ActorLocation/AMActorLocationHandler.cs
  25. 0 1
      Server/Model/Module/ActorLocation/AMActorLocationRpcHandler.cs
  26. 0 1
      Server/Model/Module/ActorLocation/ActorLocationSender.cs
  27. 0 2
      Server/Model/Module/ActorLocation/LocationComponent.cs
  28. 0 1
      Server/Model/Module/ActorLocation/LocationProxyComponent.cs
  29. 1 5
      Server/Model/Module/Benchmark/BenchmarkComponent.cs
  30. 1 5
      Server/Model/Module/Benchmark/WebSocketBenchmarkComponent.cs
  31. 1 3
      Server/Model/Module/BigWorld/LockComponent.cs
  32. 0 1
      Server/Model/Module/BigWorld/MasterComponent.cs
  33. 1 4
      Server/Model/Module/DB/DBCacheComponent.cs
  34. 0 2
      Server/Model/Module/DB/DBQueryBatchTask.cs
  35. 0 1
      Server/Model/Module/DB/DBQueryJsonTask.cs
  36. 0 1
      Server/Model/Module/DB/DBQueryTask.cs
  37. 0 1
      Server/Model/Module/DB/DBSaveBatchTask.cs
  38. 0 1
      Server/Model/Module/DB/DBSaveTask.cs
  39. 0 1
      Server/Model/Module/DB/DBTaskQueue.cs
  40. 0 1
      Server/Model/Module/Http/HttpComponent.cs
  41. 0 1
      Server/Model/Module/Message/InnerMessage.cs
  42. 3 1
      Unity/Assets/Hotfix/Module/Message/MessagePool.cs
  43. 1 2
      Unity/Assets/Model/Base/Helper/ByteHelper.cs
  44. 0 2
      Unity/Assets/Model/Base/Helper/FileHelper.cs
  45. 1 2
      Unity/Assets/Model/Base/Object/ComponentWithId.cs
  46. 0 1
      Unity/Assets/Model/Base/Object/EventSystem.cs
  47. 0 1
      Unity/Assets/Model/Base/UnityMath/Matrix4x4.cs
  48. 1 4
      Unity/Assets/Model/Component/Config/ClientConfig.cs
  49. 1 2
      Unity/Assets/Model/Component/Config/OuterConfig.cs
  50. 0 1
      Unity/Assets/Model/Component/TimerComponent.cs
  51. 1 3
      Unity/Assets/Model/Module/Message/MessageAttribute.cs
  52. 1 3
      Unity/Assets/Model/Module/Message/MessageHandlerAttribute.cs
  53. 3 1
      Unity/Assets/Model/Module/Message/MessagePool.cs
  54. 0 2
      Unity/Assets/Model/Module/Message/Network/Circularbuffer.cs
  55. 0 3
      Unity/Assets/Model/Module/Message/Network/TCP/TChannel.cs
  56. 0 1
      Unity/Assets/Model/Module/Message/Network/TCP/TService.cs
  57. 0 1
      Unity/Assets/Model/Module/Message/OuterOpcode.cs
  58. 0 2
      Unity/Assets/Model/Module/Message/Session.cs
  59. 1 3
      Unity/Assets/Model/Module/Numeric/NumericWatcherAttribute.cs
  60. 0 1
      Unity/Assets/Model/Module/Pathfinding/Recast/AstarMath.cs
  61. 0 1
      Unity/Assets/Model/Module/Pathfinding/Recast/BBTree.cs
  62. 0 1
      Unity/Assets/Model/Module/Pathfinding/Recast/GraphNode.cs
  63. 0 2
      Unity/Assets/Model/Module/Pathfinding/Recast/GraphTransform.cs
  64. 0 2
      Unity/Assets/Model/Module/Pathfinding/Recast/Int3.cs
  65. 0 2
      Unity/Assets/Model/Module/Pathfinding/Recast/NN.cs
  66. 0 1
      Unity/Assets/Model/Module/Pathfinding/Recast/NavmeshBase.cs
  67. 0 1
      Unity/Assets/Model/Module/Pathfinding/Recast/Path.cs
  68. 0 2
      Unity/Assets/Model/Module/Pathfinding/Recast/PathFindHelper.cs
  69. 0 2
      Unity/Assets/Model/Module/Pathfinding/Recast/PathHandler.cs
  70. 0 2
      Unity/Assets/Model/Module/Pathfinding/Recast/PathProcessor.cs
  71. 1 1
      Unity/Assets/Model/Module/Pathfinding/Recast/PathReturnQueue.cs
  72. 0 2
      Unity/Assets/Model/Module/Pathfinding/Recast/Pathfinders/ABPath.cs
  73. 0 1
      Unity/Assets/Model/Module/Pathfinding/Recast/Pathfinders/ConstantPath.cs
  74. 0 2
      Unity/Assets/Model/Module/Pathfinding/Recast/Pathfinders/FleePath.cs
  75. 0 1
      Unity/Assets/Model/Module/Pathfinding/Recast/Pathfinders/FloodPath.cs
  76. 0 2
      Unity/Assets/Model/Module/Pathfinding/Recast/Pathfinders/FloodPathTracer.cs
  77. 0 1
      Unity/Assets/Model/Module/Pathfinding/Recast/Pathfinders/MultiTargetPath.cs
  78. 0 2
      Unity/Assets/Model/Module/Pathfinding/Recast/Pathfinders/RandomPath.cs
  79. 0 2
      Unity/Assets/Model/Module/Pathfinding/Recast/Pathfinders/XPath.cs
  80. 0 2
      Unity/Assets/Model/Module/Pathfinding/Recast/Serialization/JsonSerializer.cs
  81. 0 2
      Unity/Assets/Model/Module/Pathfinding/Recast/Serialization/TinyJson.cs
  82. 0 4
      Unity/Assets/Model/Module/Pathfinding/Recast/ThreadControlQueue.cs

+ 33 - 7
Server/App/Program.cs

@@ -51,7 +51,8 @@ namespace App
 						Game.Scene.AddComponent<NetOuterComponent, string>(outerConfig.Address);
 						break;
 					case AppType.Realm:
-						Game.Scene.AddComponent<ActorMessageDispatherComponent>();
+						Game.Scene.AddComponent<MailboxDispatcherComponent>();
+						Game.Scene.AddComponent<ActorMessageDispatcherComponent>();
 						Game.Scene.AddComponent<NetInnerComponent, string>(innerConfig.Address);
 						Game.Scene.AddComponent<NetOuterComponent, string>(outerConfig.Address);
 						Game.Scene.AddComponent<LocationProxyComponent>();
@@ -59,7 +60,8 @@ namespace App
 						break;
 					case AppType.Gate:
 						Game.Scene.AddComponent<PlayerComponent>();
-						Game.Scene.AddComponent<ActorMessageDispatherComponent>();
+						Game.Scene.AddComponent<MailboxDispatcherComponent>();
+						Game.Scene.AddComponent<ActorMessageDispatcherComponent>();
 						Game.Scene.AddComponent<NetInnerComponent, string>(innerConfig.Address);
 						Game.Scene.AddComponent<NetOuterComponent, string>(outerConfig.Address);
 						Game.Scene.AddComponent<LocationProxyComponent>();
@@ -77,27 +79,51 @@ namespace App
 						Game.Scene.AddComponent<LocationProxyComponent>();
 						Game.Scene.AddComponent<ActorMessageSenderComponent>();
 						Game.Scene.AddComponent<ActorLocationSenderComponent>();
-						Game.Scene.AddComponent<ActorMessageDispatherComponent>();
+						Game.Scene.AddComponent<MailboxDispatcherComponent>();
+						Game.Scene.AddComponent<ActorMessageDispatcherComponent>();
 						Game.Scene.AddComponent<PathfindingComponent>();
 						break;
 					case AppType.AllServer:
+						// 发送普通actor消息
 						Game.Scene.AddComponent<ActorMessageSenderComponent>();
+						
+						// 发送location actor消息
 						Game.Scene.AddComponent<ActorLocationSenderComponent>();
-						Game.Scene.AddComponent<PlayerComponent>();
-						Game.Scene.AddComponent<UnitComponent>();
+						
 						//Game.Scene.AddComponent<DBComponent>();
 						//Game.Scene.AddComponent<DBProxyComponent>();
 						//Game.Scene.AddComponent<DBCacheComponent>();
+						
+						// location server需要的组件
 						Game.Scene.AddComponent<LocationComponent>();
-						Game.Scene.AddComponent<ActorMessageDispatherComponent>();
+						
+						// 访问location server的组件
+						Game.Scene.AddComponent<LocationProxyComponent>();
+						
+						// 这两个组件是处理actor消息使用的
+						Game.Scene.AddComponent<MailboxDispatcherComponent>();
+						Game.Scene.AddComponent<ActorMessageDispatcherComponent>();
+						
+						// 内网消息组件
 						Game.Scene.AddComponent<NetInnerComponent, string>(innerConfig.Address);
+						
+						// 外网消息组件
 						Game.Scene.AddComponent<NetOuterComponent, string>(outerConfig.Address);
-						Game.Scene.AddComponent<LocationProxyComponent>();
+						
+						// manager server组件,用来管理其它进程使用
 						Game.Scene.AddComponent<AppManagerComponent>();
 						Game.Scene.AddComponent<RealmGateAddressComponent>();
 						Game.Scene.AddComponent<GateSessionKeyComponent>();
+						
+						// 配置管理
 						Game.Scene.AddComponent<ConfigComponent>();
+						
+						// recast寻路组件
 						Game.Scene.AddComponent<PathfindingComponent>();
+						
+						Game.Scene.AddComponent<PlayerComponent>();
+						Game.Scene.AddComponent<UnitComponent>();
+						
 						// Game.Scene.AddComponent<HttpComponent>();
 						break;
 					case AppType.Benchmark:

+ 85 - 0
Server/Hotfix/Module/Actor/ActorMessageDispatcherComponentSystem.cs

@@ -0,0 +1,85 @@
+using System;
+using System.Collections.Generic;
+using ETModel;
+
+namespace ETHotfix
+{
+	[ObjectSystem]
+	public class ActorMessageDispatcherComponentStartSystem: AwakeSystem<ActorMessageDispatcherComponent>
+	{
+		public override void Awake(ActorMessageDispatcherComponent self)
+		{
+			self.Awake();
+		}
+	}
+
+	[ObjectSystem]
+	public class ActorMessageDispatcherComponentLoadSystem: LoadSystem<ActorMessageDispatcherComponent>
+	{
+		public override void Load(ActorMessageDispatcherComponent self)
+		{
+			self.Load();
+		}
+	}
+
+	/// <summary>
+	/// Actor消息分发组件
+	/// </summary>
+	public static class ActorMessageDispatcherComponentHelper
+	{
+		public static void Awake(this ActorMessageDispatcherComponent self)
+		{
+			self.Load();
+		}
+
+		public static void Load(this ActorMessageDispatcherComponent self)
+		{
+			AppType appType = StartConfigComponent.Instance.StartConfig.AppType;
+
+			self.ActorMessageHandlers.Clear();
+
+			List<Type> types = Game.EventSystem.GetTypes(typeof(ActorMessageHandlerAttribute));
+
+			types = Game.EventSystem.GetTypes(typeof (ActorMessageHandlerAttribute));
+			foreach (Type type in types)
+			{
+				object[] attrs = type.GetCustomAttributes(typeof(ActorMessageHandlerAttribute), false);
+				if (attrs.Length == 0)
+				{
+					continue;
+				}
+				
+				ActorMessageHandlerAttribute messageHandlerAttribute = (ActorMessageHandlerAttribute) attrs[0];
+				if (!messageHandlerAttribute.Type.Is(appType))
+				{
+					continue;
+				}
+
+				object obj = Activator.CreateInstance(type);
+
+				IMActorHandler imHandler = obj as IMActorHandler;
+				if (imHandler == null)
+				{
+					throw new Exception($"message handler not inherit IMActorHandler abstract class: {obj.GetType().FullName}");
+				}
+
+				Type messageType = imHandler.GetMessageType();
+				self.ActorMessageHandlers.Add(messageType, imHandler);
+			}
+		}
+
+		/// <summary>
+		/// 分发actor消息
+		/// </summary>
+		public static async ETTask Handle(
+				this ActorMessageDispatcherComponent self, Entity entity, ActorMessageInfo actorMessageInfo)
+		{
+			if (!self.ActorMessageHandlers.TryGetValue(actorMessageInfo.Message.GetType(), out IMActorHandler handler))
+			{
+				throw new Exception($"not found message handler: {MongoHelper.ToJson(actorMessageInfo.Message)}");
+			}
+
+			await handler.Handle(actorMessageInfo.Session, entity, actorMessageInfo.Message);
+		}
+	}
+}

+ 0 - 118
Server/Hotfix/Module/Actor/ActorMessageDispatherComponentSystem.cs

@@ -1,118 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using ETModel;
-
-namespace ETHotfix
-{
-	[ObjectSystem]
-	public class ActorMessageDispatherComponentStartSystem: AwakeSystem<ActorMessageDispatherComponent>
-	{
-		public override void Awake(ActorMessageDispatherComponent self)
-		{
-			self.Awake();
-		}
-	}
-
-	[ObjectSystem]
-	public class ActorMessageDispatherComponentLoadSystem: LoadSystem<ActorMessageDispatherComponent>
-	{
-		public override void Load(ActorMessageDispatherComponent self)
-		{
-			self.Load();
-		}
-	}
-
-	/// <summary>
-	/// Actor消息分发组件
-	/// </summary>
-	public static class ActorMessageDispatherComponentHelper
-	{
-		public static void Awake(this ActorMessageDispatherComponent self)
-		{
-			self.Load();
-		}
-
-		public static void Load(this ActorMessageDispatherComponent self)
-		{
-			AppType appType = StartConfigComponent.Instance.StartConfig.AppType;
-
-			self.ActorMessageHandlers.Clear();
-			self.ActorTypeHandlers.Clear();
-
-			List<Type> types = Game.EventSystem.GetTypes(typeof(ActorInterceptTypeHandlerAttribute));
-
-			foreach (Type type in types)
-			{
-				object[] attrs = type.GetCustomAttributes(typeof(ActorInterceptTypeHandlerAttribute), false);
-				if (attrs.Length == 0)
-				{
-					continue;
-				}
-
-				ActorInterceptTypeHandlerAttribute actorInterceptTypeHandlerAttribute = (ActorInterceptTypeHandlerAttribute) attrs[0];
-				if (!actorInterceptTypeHandlerAttribute.Type.Is(appType))
-				{
-					continue;
-				}
-
-				object obj = Activator.CreateInstance(type);
-
-				IActorInterceptTypeHandler iActorInterceptTypeHandler = obj as IActorInterceptTypeHandler;
-				if (iActorInterceptTypeHandler == null)
-				{
-					throw new Exception($"actor handler not inherit IEntityActorHandler: {obj.GetType().FullName}");
-				}
-
-				self.ActorTypeHandlers.Add(actorInterceptTypeHandlerAttribute.ActorType, iActorInterceptTypeHandler);
-			}
-
-			types = Game.EventSystem.GetTypes(typeof (ActorMessageHandlerAttribute));
-			foreach (Type type in types)
-			{
-				object[] attrs = type.GetCustomAttributes(typeof(ActorMessageHandlerAttribute), false);
-				if (attrs.Length == 0)
-				{
-					continue;
-				}
-				
-				ActorMessageHandlerAttribute messageHandlerAttribute = (ActorMessageHandlerAttribute) attrs[0];
-				if (!messageHandlerAttribute.Type.Is(appType))
-				{
-					continue;
-				}
-
-				object obj = Activator.CreateInstance(type);
-
-				IMActorHandler imHandler = obj as IMActorHandler;
-				if (imHandler == null)
-				{
-					throw new Exception($"message handler not inherit IMActorHandler abstract class: {obj.GetType().FullName}");
-				}
-
-				Type messageType = imHandler.GetMessageType();
-				self.ActorMessageHandlers.Add(messageType, imHandler);
-			}
-		}
-
-		public static async ETTask Handle(
-				this ActorMessageDispatherComponent self, MailBoxComponent mailBoxComponent, ActorMessageInfo actorMessageInfo)
-		{
-			// 有拦截器使用拦截器处理
-			IActorInterceptTypeHandler iActorInterceptTypeHandler;
-			if (self.ActorTypeHandlers.TryGetValue(mailBoxComponent.ActorInterceptType, out iActorInterceptTypeHandler))
-			{
-				await iActorInterceptTypeHandler.Handle(actorMessageInfo.Session, mailBoxComponent.Entity, actorMessageInfo.Message);
-				return;
-			}
-			
-			// 没有拦截器就用IMActorHandler处理
-			if (!self.ActorMessageHandlers.TryGetValue(actorMessageInfo.Message.GetType(), out IMActorHandler handler))
-			{
-				throw new Exception($"not found message handler: {MongoHelper.ToJson(actorMessageInfo.Message)}");
-			}
-
-			await handler.Handle(actorMessageInfo.Session, mailBoxComponent.Entity, actorMessageInfo.Message);
-		}
-	}
-}

+ 1 - 2
Server/Hotfix/Module/Actor/ActorMessageSenderHelper.cs

@@ -1,5 +1,4 @@
-using System.Threading.Tasks;
-using ETModel;
+using ETModel;
 
 namespace ETHotfix
 {

+ 6 - 8
Server/Hotfix/Module/Actor/MailBoxComponentSystem.cs

@@ -1,6 +1,4 @@
 using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
 using ETModel;
 
 namespace ETHotfix
@@ -10,7 +8,7 @@ namespace ETHotfix
 	{
 		public override void Awake(MailBoxComponent self)
 		{
-			self.ActorInterceptType = ActorInterceptType.None;
+			self.MailboxType = MailboxType.MessageDispatcher;
 			self.Queue.Clear();
 		}
 	}
@@ -18,9 +16,9 @@ namespace ETHotfix
 	[ObjectSystem]
 	public class MailBoxComponentAwake1System : AwakeSystem<MailBoxComponent, string>
 	{
-		public override void Awake(MailBoxComponent self, string actorInterceptType)
+		public override void Awake(MailBoxComponent self, string mailboxType)
 		{
-			self.ActorInterceptType = actorInterceptType;
+			self.MailboxType = mailboxType;
 			self.Queue.Clear();
 		}
 	}
@@ -76,7 +74,7 @@ namespace ETHotfix
 
 		public static async ETVoid HandleAsync(this MailBoxComponent self)
 		{
-			ActorMessageDispatherComponent actorMessageDispatherComponent = Game.Scene.GetComponent<ActorMessageDispatherComponent>();
+			MailboxDispatcherComponent mailboxDispatcherComponent = Game.Scene.GetComponent<MailboxDispatcherComponent>();
 			
 			long instanceId = self.InstanceId;
 			
@@ -95,8 +93,8 @@ namespace ETHotfix
 						return;
 					}
 
-					// 根据这个actor的类型分发给相应的ActorHandler处理
-					await actorMessageDispatherComponent.Handle(self, info);
+					// 根据这个mailbox类型分发给相应的处理
+					await mailboxDispatcherComponent.Handle(self, info);
 				}
 				catch (Exception e)
 				{

+ 79 - 0
Server/Hotfix/Module/Actor/MailboxDispatcherComponentSystem.cs

@@ -0,0 +1,79 @@
+using System;
+using System.Collections.Generic;
+using ETModel;
+
+namespace ETHotfix
+{
+	[ObjectSystem]
+	public class MailboxDispatcherComponentStartSystem: AwakeSystem<MailboxDispatcherComponent>
+	{
+		public override void Awake(MailboxDispatcherComponent self)
+		{
+			self.Awake();
+		}
+	}
+
+	[ObjectSystem]
+	public class MailboxDispatcherComponentLoadSystem: LoadSystem<MailboxDispatcherComponent>
+	{
+		public override void Load(MailboxDispatcherComponent self)
+		{
+			self.Load();
+		}
+	}
+
+	public static class MailboxDispatcherComponentHelper
+	{
+		public static void Awake(this MailboxDispatcherComponent self)
+		{
+			self.Load();
+		}
+
+		public static void Load(this MailboxDispatcherComponent self)
+		{
+			AppType appType = StartConfigComponent.Instance.StartConfig.AppType;
+
+			self.MailboxHandlers.Clear();
+
+			List<Type> types = Game.EventSystem.GetTypes(typeof(MailboxHandlerAttribute));
+
+			foreach (Type type in types)
+			{
+				object[] attrs = type.GetCustomAttributes(typeof(MailboxHandlerAttribute), false);
+				if (attrs.Length == 0)
+				{
+					continue;
+				}
+
+				MailboxHandlerAttribute mailboxHandlerAttribute = (MailboxHandlerAttribute) attrs[0];
+				if (!mailboxHandlerAttribute.Type.Is(appType))
+				{
+					continue;
+				}
+
+				object obj = Activator.CreateInstance(type);
+
+				IMailboxHandler iMailboxHandler = obj as IMailboxHandler;
+				if (iMailboxHandler == null)
+				{
+					throw new Exception($"actor handler not inherit IEntityActorHandler: {obj.GetType().FullName}");
+				}
+
+				self.MailboxHandlers.Add(mailboxHandlerAttribute.MailboxType, iMailboxHandler);
+			}
+		}
+
+		/// <summary>
+		/// 根据mailbox类型做不同的处理
+		/// </summary>
+		public static async ETTask Handle(
+				this MailboxDispatcherComponent self, MailBoxComponent mailBoxComponent, ActorMessageInfo actorMessageInfo)
+		{
+			IMailboxHandler iMailboxHandler;
+			if (self.MailboxHandlers.TryGetValue(mailBoxComponent.MailboxType, out iMailboxHandler))
+			{
+				await iMailboxHandler.Handle(actorMessageInfo.Session, mailBoxComponent.Entity, actorMessageInfo.Message);
+			}
+		}
+	}
+}

+ 3 - 4
Server/Hotfix/Module/Actor/GateSessionActorInterceptInterceptTypeHandler.cs → Server/Hotfix/Module/Actor/MailboxGateSessionHandler.cs

@@ -1,14 +1,13 @@
 using System;
-using System.Threading.Tasks;
 using ETModel;
 
 namespace ETHotfix
 {
 	/// <summary>
-	/// gate session 拦截器,收到的actor消息直接转发给客户端
+	/// gate session类型的Mailbox,收到的actor消息直接转发给客户端
 	/// </summary>
-	[ActorInterceptTypeHandler(AppType.Gate, ActorInterceptType.GateSession)]
-	public class GateSessionActorInterceptInterceptTypeHandler : IActorInterceptTypeHandler
+	[MailboxHandler(AppType.Gate, MailboxType.GateSession)]
+	public class MailboxGateSessionHandler : IMailboxHandler
 	{
 		public async ETTask Handle(Session session, Entity entity, object actorMessage)
 		{

+ 25 - 0
Server/Hotfix/Module/Actor/MailboxMessageDispatcherHandler.cs

@@ -0,0 +1,25 @@
+using System;
+using ETModel;
+
+namespace ETHotfix
+{
+	/// <summary>
+	/// 消息分发类型的Mailbox,对mailbox中的消息进行分发处理
+	/// </summary>
+	[MailboxHandler(AppType.AllServer, MailboxType.MessageDispatcher)]
+	public class MailboxMessageDispatcherHandler : IMailboxHandler
+	{
+		public async ETTask Handle(Session session, Entity entity, object actorMessage)
+		{
+			try
+			{
+				await Game.Scene.GetComponent<ActorMessageDispatcherComponent>().Handle(
+					entity, new ActorMessageInfo() { Session = session, Message = actorMessage });
+			}
+			catch (Exception e)
+			{
+				Log.Error(e);
+			}
+		}
+	}
+}

+ 1 - 1
Server/Hotfix/Module/Demo/C2G_LoginGateHandler.cs

@@ -22,7 +22,7 @@ namespace ETHotfix
 				Player player = ComponentFactory.Create<Player, string>(account);
 				Game.Scene.GetComponent<PlayerComponent>().Add(player);
 				session.AddComponent<SessionPlayerComponent>().Player = player;
-				session.AddComponent<MailBoxComponent, string>(ActorInterceptType.GateSession);
+				session.AddComponent<MailBoxComponent, string>(MailboxType.GateSession);
 
 				response.PlayerId = player.Id;
 				reply(response);

+ 0 - 1
Server/Hotfix/Module/Demo/MessageHelper.cs

@@ -1,5 +1,4 @@
 using ETModel;
-using PF;
 
 namespace ETHotfix
 {

+ 1 - 3
Server/Model/Base/Helper/DllHelper.cs

@@ -1,6 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
+using System.IO;
 using System.Reflection;
 
 namespace ETModel

+ 0 - 1
Server/Model/Module/Actor/AMActorHandler.cs

@@ -1,5 +1,4 @@
 using System;
-using System.Threading.Tasks;
 
 namespace ETModel
 {

+ 0 - 1
Server/Model/Module/Actor/AMActorRpcHandler.cs

@@ -1,5 +1,4 @@
 using System;
-using System.Threading.Tasks;
 
 namespace ETModel
 {

+ 0 - 8
Server/Model/Module/Actor/ActorInterceptType.cs

@@ -1,8 +0,0 @@
-namespace ETModel
-{
-    public static partial class ActorInterceptType
-    {
-	    public const string None = "None";
-		public const string GateSession = "GateSession";
-    }
-}

+ 0 - 17
Server/Model/Module/Actor/ActorInterceptTypeHandlerAttribute.cs

@@ -1,17 +0,0 @@
-using System;
-
-namespace ETModel
-{
-	public class ActorInterceptTypeHandlerAttribute : BaseAttribute
-	{
-		public AppType Type { get; }
-
-		public string ActorType { get; }
-
-		public ActorInterceptTypeHandlerAttribute(AppType appType, string actorType)
-		{
-			this.Type = appType;
-			this.ActorType = actorType;
-		}
-	}
-}

+ 1 - 4
Server/Model/Module/Actor/ActorMessageDispatherComponent.cs → Server/Model/Module/Actor/ActorMessageDispatcherComponent.cs

@@ -6,10 +6,8 @@ namespace ETModel
 	/// <summary>
 	/// Actor消息分发组件
 	/// </summary>
-	public class ActorMessageDispatherComponent : Component
+	public class ActorMessageDispatcherComponent : Component
 	{
-		public readonly Dictionary<string, IActorInterceptTypeHandler> ActorTypeHandlers = new Dictionary<string, IActorInterceptTypeHandler>();
-
 		public readonly Dictionary<Type, IMActorHandler> ActorMessageHandlers = new Dictionary<Type, IMActorHandler>();
 
 		public override void Dispose()
@@ -21,7 +19,6 @@ namespace ETModel
 			base.Dispose();
 
 			this.ActorMessageHandlers.Clear();
-			this.ActorTypeHandlers.Clear();
 		}
 	}
 }

+ 1 - 3
Server/Model/Module/Actor/ActorMessageHandlerAttribute.cs

@@ -1,6 +1,4 @@
-using System;
-
-namespace ETModel
+namespace ETModel
 {
 	public class ActorMessageHandlerAttribute : BaseAttribute
 	{

+ 0 - 1
Server/Model/Module/Actor/IMActorHandler.cs

@@ -1,5 +1,4 @@
 using System;
-using System.Threading.Tasks;
 
 namespace ETModel
 {

+ 1 - 1
Server/Model/Module/Actor/IActorInterceptTypeHandler.cs → Server/Model/Module/Actor/IMailboxHandler.cs

@@ -1,6 +1,6 @@
 namespace ETModel
 {
-	public interface IActorInterceptTypeHandler
+	public interface IMailboxHandler
 	{
 		ETTask Handle(Session session, Entity entity, object actorMessage);
 	}

+ 2 - 3
Server/Model/Module/Actor/MailBoxComponent.cs

@@ -1,5 +1,4 @@
 using System.Collections.Generic;
-using System.Threading.Tasks;
 
 namespace ETModel
 {
@@ -14,8 +13,8 @@ namespace ETModel
 	/// </summary>
 	public class MailBoxComponent: Component
 	{
-		// 拦截器类型,默认没有拦截器
-		public string ActorInterceptType;
+		// Mailbox的类型
+		public string MailboxType;
 
 		// 队列处理消息
 		public Queue<ActorMessageInfo> Queue = new Queue<ActorMessageInfo>();

+ 23 - 0
Server/Model/Module/Actor/MailboxDispatcherComponent.cs

@@ -0,0 +1,23 @@
+using System.Collections.Generic;
+
+namespace ETModel
+{
+	/// <summary>
+	/// mailbox分发组件,不同类型的mailbox交给不同的MailboxHandle处理
+	/// </summary>
+	public class MailboxDispatcherComponent : Component
+	{
+		public readonly Dictionary<string, IMailboxHandler> MailboxHandlers = new Dictionary<string, IMailboxHandler>();
+
+		public override void Dispose()
+		{
+			if (this.IsDisposed)
+			{
+				return;
+			}
+			base.Dispose();
+
+			this.MailboxHandlers.Clear();
+		}
+	}
+}

+ 15 - 0
Server/Model/Module/Actor/MailboxHandlerAttribute.cs

@@ -0,0 +1,15 @@
+namespace ETModel
+{
+	public class MailboxHandlerAttribute : BaseAttribute
+	{
+		public AppType Type { get; }
+
+		public string MailboxType { get; }
+
+		public MailboxHandlerAttribute(AppType appType, string mailboxType)
+		{
+			this.Type = appType;
+			this.MailboxType = mailboxType;
+		}
+	}
+}

+ 8 - 0
Server/Model/Module/Actor/MailboxType.cs

@@ -0,0 +1,8 @@
+namespace ETModel
+{
+    public static partial class MailboxType
+    {
+	    public const string MessageDispatcher = "Dispatcher";
+		public const string GateSession = "GateSession";
+    }
+}

+ 0 - 1
Server/Model/Module/ActorLocation/AMActorLocationHandler.cs

@@ -1,5 +1,4 @@
 using System;
-using System.Threading.Tasks;
 
 namespace ETModel
 {

+ 0 - 1
Server/Model/Module/ActorLocation/AMActorLocationRpcHandler.cs

@@ -1,5 +1,4 @@
 using System;
-using System.Threading.Tasks;
 
 namespace ETModel
 {

+ 0 - 1
Server/Model/Module/ActorLocation/ActorLocationSender.cs

@@ -1,6 +1,5 @@
 using System.Collections.Generic;
 using System.Net;
-using System.Threading.Tasks;
 
 namespace ETModel
 {

+ 0 - 2
Server/Model/Module/ActorLocation/LocationComponent.cs

@@ -1,7 +1,5 @@
 using System;
 using System.Collections.Generic;
-using System.Threading.Tasks;
-using MongoDB.Bson.Serialization.Attributes;
 
 namespace ETModel
 {

+ 0 - 1
Server/Model/Module/ActorLocation/LocationProxyComponent.cs

@@ -1,5 +1,4 @@
 using System.Net;
-using System.Threading.Tasks;
 
 namespace ETModel
 {

+ 1 - 5
Server/Model/Module/Benchmark/BenchmarkComponent.cs

@@ -1,8 +1,4 @@
-using System;
-using System.Net;
-using System.Threading.Tasks;
-
-namespace ETModel
+namespace ETModel
 {
 	public class BenchmarkComponent: Component
 	{

+ 1 - 5
Server/Model/Module/Benchmark/WebSocketBenchmarkComponent.cs

@@ -1,8 +1,4 @@
-using System;
-using System.Net;
-using System.Threading.Tasks;
-
-namespace ETModel
+namespace ETModel
 {
 	public class WebSocketBenchmarkComponent: Component
 	{

+ 1 - 3
Server/Model/Module/BigWorld/LockComponent.cs

@@ -1,7 +1,5 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
 using System.Net;
-using System.Threading.Tasks;
 
 namespace ETModel
 {

+ 0 - 1
Server/Model/Module/BigWorld/MasterComponent.cs

@@ -1,6 +1,5 @@
 using System.Collections.Generic;
 using System.Net;
-using System.Threading.Tasks;
 
 namespace ETModel
 {

+ 1 - 4
Server/Model/Module/DB/DBCacheComponent.cs

@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq.Expressions;
-using System.Threading.Tasks;
+using System.Collections.Generic;
 
 namespace ETModel
 {

+ 0 - 2
Server/Model/Module/DB/DBQueryBatchTask.cs

@@ -1,7 +1,5 @@
 using System;
 using System.Collections.Generic;
-using System.Threading.Tasks;
-using MongoDB.Bson;
 using MongoDB.Driver;
 
 namespace ETModel

+ 0 - 1
Server/Model/Module/DB/DBQueryJsonTask.cs

@@ -1,6 +1,5 @@
 using System;
 using System.Collections.Generic;
-using System.Threading.Tasks;
 using MongoDB.Driver;
 
 namespace ETModel

+ 0 - 1
Server/Model/Module/DB/DBQueryTask.cs

@@ -1,5 +1,4 @@
 using System;
-using System.Threading.Tasks;
 using MongoDB.Driver;
 
 namespace ETModel

+ 0 - 1
Server/Model/Module/DB/DBSaveBatchTask.cs

@@ -1,6 +1,5 @@
 using System;
 using System.Collections.Generic;
-using System.Threading.Tasks;
 using MongoDB.Bson;
 using MongoDB.Driver;
 

+ 0 - 1
Server/Model/Module/DB/DBSaveTask.cs

@@ -1,5 +1,4 @@
 using System;
-using System.Threading.Tasks;
 using MongoDB.Driver;
 
 namespace ETModel

+ 0 - 1
Server/Model/Module/DB/DBTaskQueue.cs

@@ -1,6 +1,5 @@
 using System;
 using System.Collections.Generic;
-using System.Threading.Tasks;
 
 namespace ETModel
 {

+ 0 - 1
Server/Model/Module/Http/HttpComponent.cs

@@ -3,7 +3,6 @@ using System.Collections.Generic;
 using System.IO;
 using System.Net;
 using System.Reflection;
-using System.Threading.Tasks;
 
 namespace ETModel
 {

+ 0 - 1
Server/Model/Module/Message/InnerMessage.cs

@@ -1,4 +1,3 @@
-using ETModel;
 using System.Collections.Generic;
 namespace ETModel
 {

+ 3 - 1
Unity/Assets/Hotfix/Module/Message/MessagePool.cs

@@ -1,5 +1,7 @@
 using System;
-using System.Collections.Generic;
+#if !SERVER
+using System.Collections.Generic;		
+#endif
 
 namespace ETHotfix
 {

+ 1 - 2
Unity/Assets/Model/Base/Helper/ByteHelper.cs

@@ -1,5 +1,4 @@
-using System;
-using System.Text;
+using System.Text;
 
 namespace ETModel
 {

+ 0 - 2
Unity/Assets/Model/Base/Helper/FileHelper.cs

@@ -1,8 +1,6 @@
 using System;
 using System.Collections.Generic;
 using System.IO;
-using System.Linq;
-using System.Text;
 
 namespace ETModel
 {

+ 1 - 2
Unity/Assets/Model/Base/Object/ComponentWithId.cs

@@ -1,5 +1,4 @@
-using System;
-using MongoDB.Bson.Serialization.Attributes;
+using MongoDB.Bson.Serialization.Attributes;
 
 namespace ETModel
 {

+ 0 - 1
Unity/Assets/Model/Base/Object/EventSystem.cs

@@ -1,6 +1,5 @@
 using System;
 using System.Collections.Generic;
-using System.Linq;
 using System.Reflection;
 
 namespace ETModel

+ 0 - 1
Unity/Assets/Model/Base/UnityMath/Matrix4x4.cs

@@ -1,6 +1,5 @@
 using System;
 using System.Globalization;
-using PF;
 
 namespace PF
 {

+ 1 - 4
Unity/Assets/Model/Component/Config/ClientConfig.cs

@@ -1,7 +1,4 @@
-using System.Net;
-using MongoDB.Bson.Serialization.Attributes;
-
-namespace ETModel
+namespace ETModel
 {
 	public class ClientConfig: AConfigComponent
 	{

+ 1 - 2
Unity/Assets/Model/Component/Config/OuterConfig.cs

@@ -1,5 +1,4 @@
-using System.Net;
-using MongoDB.Bson.Serialization.Attributes;
+using MongoDB.Bson.Serialization.Attributes;
 
 namespace ETModel
 {

+ 0 - 1
Unity/Assets/Model/Component/TimerComponent.cs

@@ -1,6 +1,5 @@
 using System.Collections.Generic;
 using System.Threading;
-using System.Threading.Tasks;
 
 namespace ETModel
 {

+ 1 - 3
Unity/Assets/Model/Module/Message/MessageAttribute.cs

@@ -1,6 +1,4 @@
-using System;
-
-namespace ETModel
+namespace ETModel
 {
 	public class MessageAttribute: BaseAttribute
 	{

+ 1 - 3
Unity/Assets/Model/Module/Message/MessageHandlerAttribute.cs

@@ -1,6 +1,4 @@
-using System;
-
-namespace ETModel
+namespace ETModel
 {
 	public class MessageHandlerAttribute : BaseAttribute
 	{

+ 3 - 1
Unity/Assets/Model/Module/Message/MessagePool.cs

@@ -1,5 +1,7 @@
 using System;
-using System.Collections.Generic;
+#if !SERVER
+using System.Collections.Generic;		
+#endif
 
 namespace ETModel
 {

+ 0 - 2
Unity/Assets/Model/Module/Message/Network/Circularbuffer.cs

@@ -1,8 +1,6 @@
 using System;
 using System.Collections.Generic;
 using System.IO;
-using System.Net.Sockets;
-using System.Threading.Tasks;
 
 namespace ETModel
 {

+ 0 - 3
Unity/Assets/Model/Module/Message/Network/TCP/TChannel.cs

@@ -1,10 +1,7 @@
 using System;
-using System.Collections.Generic;
 using System.IO;
-using System.Linq;
 using System.Net;
 using System.Net.Sockets;
-using Microsoft.IO;
 
 namespace ETModel
 {

+ 0 - 1
Unity/Assets/Model/Module/Message/Network/TCP/TService.cs

@@ -3,7 +3,6 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Net;
 using System.Net.Sockets;
-using System.Threading.Tasks;
 using Microsoft.IO;
 
 namespace ETModel

+ 0 - 1
Unity/Assets/Model/Module/Message/OuterOpcode.cs

@@ -1,4 +1,3 @@
-using ETModel;
 namespace ETModel
 {
 	[Message(OuterOpcode.Actor_Test)]

+ 0 - 2
Unity/Assets/Model/Module/Message/Session.cs

@@ -3,9 +3,7 @@ using System.Collections.Generic;
 using System.IO;
 using System.Linq;
 using System.Net;
-using System.Net.Sockets;
 using System.Threading;
-using System.Threading.Tasks;
 
 namespace ETModel
 {

+ 1 - 3
Unity/Assets/Model/Module/Numeric/NumericWatcherAttribute.cs

@@ -1,6 +1,4 @@
-using System;
-
-namespace ETModel
+namespace ETModel
 {
 	public class NumericWatcherAttribute : BaseAttribute
 	{

+ 0 - 1
Unity/Assets/Model/Module/Pathfinding/Recast/AstarMath.cs

@@ -1,4 +1,3 @@
-using PF;
 using System.Collections.Generic;
 using System;
 

+ 0 - 1
Unity/Assets/Model/Module/Pathfinding/Recast/BBTree.cs

@@ -1,7 +1,6 @@
 //#define ASTARDEBUG   //"BBTree Debug" If enables, some queries to the tree will show debug lines. Turn off multithreading when using this since DrawLine calls cannot be called from a different thread
 
 using System;
-using PF;
 
 namespace PF {
 

+ 0 - 1
Unity/Assets/Model/Module/Pathfinding/Recast/GraphNode.cs

@@ -1,4 +1,3 @@
-using PF;
 using System.Collections.Generic;
 
 namespace PF {

+ 0 - 2
Unity/Assets/Model/Module/Pathfinding/Recast/GraphTransform.cs

@@ -1,5 +1,3 @@
-using PF;
-
 namespace PF {
 	/** Transforms to and from world space to a 2D movement plane.
 	 * The transformation is guaranteed to be purely a rotation

+ 0 - 2
Unity/Assets/Model/Module/Pathfinding/Recast/Int3.cs

@@ -1,5 +1,3 @@
-using PF;
-
 namespace PF {
 	/** Holds a coordinate in integers */
 	public struct Int3 : System.IEquatable<Int3> {

+ 0 - 2
Unity/Assets/Model/Module/Pathfinding/Recast/NN.cs

@@ -1,5 +1,3 @@
-using PF;
-
 namespace PF
 {
 

+ 0 - 1
Unity/Assets/Model/Module/Pathfinding/Recast/NavmeshBase.cs

@@ -1,4 +1,3 @@
-using PF;
 using System.Collections.Generic;
 
 namespace PF {

+ 0 - 1
Unity/Assets/Model/Module/Pathfinding/Recast/Path.cs

@@ -1,6 +1,5 @@
 //#define ASTAR_POOL_DEBUG //@SHOWINEDITOR Enables debugging of path pooling. Will log warnings and info messages about paths not beeing pooled correctly.
 
-using PF;
 using System.Collections;
 using System.Collections.Generic;
 

+ 0 - 2
Unity/Assets/Model/Module/Pathfinding/Recast/PathFindHelper.cs

@@ -1,5 +1,3 @@
-using PF;
-
 namespace PF
 {
     /** What data to draw the graph debugging with */

+ 0 - 2
Unity/Assets/Model/Module/Pathfinding/Recast/PathHandler.cs

@@ -1,6 +1,4 @@
 #define DECREASE_KEY
-using System.Collections.Generic;
-
 namespace PF {
 	/** Stores temporary node data for a single pathfinding request.
 	 * Every node has one PathNode per thread used.

+ 0 - 2
Unity/Assets/Model/Module/Pathfinding/Recast/PathProcessor.cs

@@ -1,8 +1,6 @@
 using System;
 using System.Collections;
 using System.Collections.Generic;
-using System.Threading;
-using PF;
 
 namespace PF {
 #if NETFX_CORE

+ 1 - 1
Unity/Assets/Model/Module/Pathfinding/Recast/PathReturnQueue.cs

@@ -1,5 +1,5 @@
 using System.Collections.Generic;
-using ETModel;
+
 #if UNITY_5_5_OR_NEWER
 using UnityEngine.Profiling;
 #endif

+ 0 - 2
Unity/Assets/Model/Module/Pathfinding/Recast/Pathfinders/ABPath.cs

@@ -1,5 +1,3 @@
-using PF;
-
 namespace PF {
 	/** Basic path, finds the shortest path from A to B.
 	 * \ingroup paths

+ 0 - 1
Unity/Assets/Model/Module/Pathfinding/Recast/Pathfinders/ConstantPath.cs

@@ -1,6 +1,5 @@
 //#define ASTARDEBUG //Draws a ray for each node visited
 
-using PF;
 using System;
 using System.Collections.Generic;
 

+ 0 - 2
Unity/Assets/Model/Module/Pathfinding/Recast/Pathfinders/FleePath.cs

@@ -1,5 +1,3 @@
-using PF;
-
 namespace PF {
 	/** Returns a path heading away from a specified point to avoid.
 	 * The search will terminate when G \> \a length (passed to the constructor) + FleePath.spread.\n

+ 0 - 1
Unity/Assets/Model/Module/Pathfinding/Recast/Pathfinders/FloodPath.cs

@@ -1,5 +1,4 @@
 using System;
-using PF;
 using System.Collections.Generic;
 
 namespace PF {

+ 0 - 2
Unity/Assets/Model/Module/Pathfinding/Recast/Pathfinders/FloodPathTracer.cs

@@ -1,5 +1,3 @@
-using PF;
-
 namespace PF {
 	/** Restrict suitable nodes by if they have been searched by a FloodPath.
 	 *

+ 0 - 1
Unity/Assets/Model/Module/Pathfinding/Recast/Pathfinders/MultiTargetPath.cs

@@ -1,4 +1,3 @@
-using PF;
 using System.Collections.Generic;
 
 namespace PF {

+ 0 - 2
Unity/Assets/Model/Module/Pathfinding/Recast/Pathfinders/RandomPath.cs

@@ -1,5 +1,3 @@
-using PF;
-
 namespace PF {
 	/** Finds a path in a random direction from the start node.
 	 * \ingroup paths

+ 0 - 2
Unity/Assets/Model/Module/Pathfinding/Recast/Pathfinders/XPath.cs

@@ -1,5 +1,3 @@
-using PF;
-
 namespace PF {
 	/** Extended Path.
 	 * \ingroup paths

+ 0 - 2
Unity/Assets/Model/Module/Pathfinding/Recast/Serialization/JsonSerializer.cs

@@ -1,8 +1,6 @@
 using System;
 using System.IO;
 using System.Collections.Generic;
-using PF;
-
 #if ASTAR_NO_ZIP
 using Pathfinding.Serialization.Zip;
 #elif NETFX_CORE

+ 0 - 2
Unity/Assets/Model/Module/Pathfinding/Recast/Serialization/TinyJson.cs

@@ -1,7 +1,5 @@
 using System.Collections.Generic;
 using System;
-using PF;
-using Guid = PF.Guid;
 
 #if NETFX_CORE
 using System.Linq;

+ 0 - 4
Unity/Assets/Model/Module/Pathfinding/Recast/ThreadControlQueue.cs

@@ -1,7 +1,3 @@
-using System.Threading;
-using ETModel;
-using PF;
-
 namespace PF {
 	/** Queue of paths to be processed by the system */
 	class ThreadControlQueue