Просмотр исходного кода

把基本的Actor跟Location Actor分离开来:
1. ActorMessageSender跟ActorMessageSenderComponent是用来发送最简单的Actor消息,即已知actor的InstanceId,从ActorMessageSenderComponent中获取ActorMessageSender来发送
2. ActorMessageSender的Send方法只发送不需要返回,不管对面是否正常都不关心。
3. ActorMessageSender的Call方法发送等待返回
4. ActorMessageSender发送的消息不会跨协程

5. 只知道Actor的Id,那就需要查询Location,即已知actor的Id,从ActorLocationSenderComponent中获取ActorLocationSender来发送消息
6. ActorLocationSender不管Send跟Call都需要返回消息,Send发送的消息接收方可以用通用的ActorResponse来reply。实际上这两个都是通过调用ActorMessageSender的Call实现的
7. 客户端的actor消息现在改成需要继承IClientActorMessage,IClientActorRequest,IClientActorResponse接口,这三个接口对应之前的三个接口
8. ActorLocationSender发送的消息会跨协程,发送同一消息需要重新new

tanghai 7 лет назад
Родитель
Сommit
c9d4e9ab1f
43 измененных файлов с 535 добавлено и 395 удалено
  1. 1 1
      Proto/FrameMessage.proto
  2. 2 2
      Proto/HotfixMessage.proto
  3. 1 1
      Proto/InnerMessage.proto
  4. 3 0
      Server/App/Program.cs
  5. 13 214
      Server/Hotfix/Module/Actor/ActorMessageSenderSystem.cs
  6. 5 13
      Server/Hotfix/Module/Actor/GateSessionActorInterceptInterceptTypeHandler.cs
  7. 6 7
      Server/Hotfix/Module/ActorLocation/ActorLocationSenderComponentSystem.cs
  8. 204 0
      Server/Hotfix/Module/ActorLocation/ActorLocationSenderSystem.cs
  9. 0 0
      Server/Hotfix/Module/ActorLocation/LocationProxyComponentSystem.cs
  10. 0 0
      Server/Hotfix/Module/ActorLocation/ObjectAddRequestHandler.cs
  11. 0 0
      Server/Hotfix/Module/ActorLocation/ObjectGetRequestHandler.cs
  12. 0 0
      Server/Hotfix/Module/ActorLocation/ObjectLockRequestHandler.cs
  13. 0 0
      Server/Hotfix/Module/ActorLocation/ObjectRemoveRequestHandler.cs
  14. 0 0
      Server/Hotfix/Module/ActorLocation/ObjectUnLockRequestHandler.cs
  15. 15 4
      Server/Hotfix/Module/FrameSync/G2M_SessionDisconnectHandler.cs
  16. 2 2
      Server/Hotfix/Module/FrameSync/MessageHelper.cs
  17. 14 4
      Server/Hotfix/Module/FrameSync/OneFrameMessageHandler.cs
  18. 2 2
      Server/Hotfix/Module/FrameSync/SessionPlayerComponentSystem.cs
  19. 48 23
      Server/Hotfix/Module/Message/InnerMessageDispatcher.cs
  20. 40 34
      Server/Hotfix/Module/Message/OuterMessageDispatcher.cs
  21. 8 15
      Server/Model/Module/Actor/AMActorHandler.cs
  22. 3 31
      Server/Model/Module/Actor/ActorMessageSender.cs
  23. 4 20
      Server/Model/Module/Actor/ActorMessageSenderComponent.cs
  24. 6 6
      Server/Model/Module/Actor/ActorTask.cs
  25. 1 1
      Server/Model/Module/Actor/IActorInterceptTypeHandler.cs
  26. 1 1
      Server/Model/Module/Actor/IMActorHandler.cs
  27. 1 1
      Server/Model/Module/Actor/MailBoxComponent.cs
  28. 37 0
      Server/Model/Module/ActorLocation/ActorLocationSender.cs
  29. 53 0
      Server/Model/Module/ActorLocation/ActorLocationSenderComponent.cs
  30. 0 0
      Server/Model/Module/ActorLocation/Location.cs
  31. 0 0
      Server/Model/Module/ActorLocation/LocationComponent.cs
  32. 0 0
      Server/Model/Module/ActorLocation/LocationProxyComponent.cs
  33. 1 1
      Server/Model/Module/Message/InnerMessage.cs
  34. 3 0
      Server/Model/Server.Model.csproj
  35. 1 1
      Unity/Assets/Scripts/Module/FrameSync/FrameOpcode.cs
  36. 1 1
      Unity/Assets/Scripts/Module/Message/ErrorCode.cs
  37. 5 4
      Unity/Assets/Scripts/Module/Message/IActorMessage.cs
  38. 16 0
      Unity/Assets/Scripts/Module/Message/IClientActorMessage.cs
  39. 11 0
      Unity/Assets/Scripts/Module/Message/IClientActorMessage.cs.meta
  40. 2 2
      Unity/Hotfix/Module/Message/HotfixOpcode.cs
  41. 16 0
      Unity/Hotfix/Module/Message/IClientActorMessage.cs
  42. 1 0
      Unity/Hotfix/Unity.Hotfix.csproj
  43. 8 4
      Unity/Unity.csproj

+ 1 - 1
Proto/FrameMessage.proto

@@ -1,7 +1,7 @@
 syntax = "proto3";
 package ETModel;
 
-message OneFrameMessage // IActorMessage
+message OneFrameMessage // IClientActorMessage
 {
 	int32 RpcId = 90;
 	int64 ActorId = 93;

+ 2 - 2
Proto/HotfixMessage.proto

@@ -36,14 +36,14 @@ message G2C_TestHotfixMessage // IMessage
 	string Info = 1;
 }
 
-message C2M_TestActorRequest // IActorRequest
+message C2M_TestActorRequest // IClientActorRequest
 {
 	int32 RpcId = 90;
 	int64 ActorId = 91;
 	string Info = 1;
 }
 
-message M2C_TestActorResponse // IActorResponse
+message M2C_TestActorResponse // IClientActorResponse
 {
 	int32 RpcId = 90;
 	int32 Error = 91;

+ 1 - 1
Proto/InnerMessage.proto

@@ -243,7 +243,7 @@
 		int Count = 2;
 	}
 
-	message G2M_SessionDisconnect // IActorMessage
+	message G2M_SessionDisconnect // IActorRequest
 	{
 		int32 RpcId = 90;
 		long ActorId = 94;

+ 3 - 0
Server/App/Program.cs

@@ -66,6 +66,7 @@ namespace App
 						Game.Scene.AddComponent<NetOuterComponent, string>(outerConfig.Address);
 						Game.Scene.AddComponent<LocationProxyComponent>();
 						Game.Scene.AddComponent<ActorMessageSenderComponent>();
+						Game.Scene.AddComponent<ActorLocationSenderComponent>();
 						Game.Scene.AddComponent<GateSessionKeyComponent>();
 						break;
 					case AppType.Location:
@@ -77,11 +78,13 @@ namespace App
 						Game.Scene.AddComponent<UnitComponent>();
 						Game.Scene.AddComponent<LocationProxyComponent>();
 						Game.Scene.AddComponent<ActorMessageSenderComponent>();
+						Game.Scene.AddComponent<ActorLocationSenderComponent>();
 						Game.Scene.AddComponent<ActorMessageDispatherComponent>();
 						Game.Scene.AddComponent<ServerFrameComponent>();
 						break;
 					case AppType.AllServer:
 						Game.Scene.AddComponent<ActorMessageSenderComponent>();
+						Game.Scene.AddComponent<ActorLocationSenderComponent>();
 						Game.Scene.AddComponent<PlayerComponent>();
 						Game.Scene.AddComponent<UnitComponent>();
 						Game.Scene.AddComponent<DBComponent>();

+ 13 - 214
Server/Hotfix/Module/Actor/ActorMessageSenderSystem.cs

@@ -1,234 +1,33 @@
-using System;
-using System.Collections.Generic;
-using System.Threading;
-using System.Threading.Tasks;
+using System.Threading.Tasks;
 using ETModel;
 
 namespace ETHotfix
 {
 	[ObjectSystem]
-	public class ActorMessageSenderAwakeSystem : AwakeSystem<ActorMessageSender>
-	{
-		public override void Awake(ActorMessageSender self)
-		{
-			self.LastSendTime = TimeHelper.Now();
-			self.Tcs = null;
-			self.FailTimes = 0;
-			self.MaxFailTimes = 5;
-			self.ActorId = 0;
-			self.Error = 0;
-		}
-	}
-	
-	[ObjectSystem]
-	public class ActorMessageSenderAwake2System : AwakeSystem<ActorMessageSender, long>
+	public class ActorMessageSenderAwakeSystem : AwakeSystem<ActorMessageSender, long>
 	{
 		public override void Awake(ActorMessageSender self, long actorId)
 		{
-			self.LastSendTime = TimeHelper.Now();
-			self.Tcs = null;
-			self.FailTimes = 0;
-			self.MaxFailTimes = 0;
+			self.Id = actorId;
 			self.ActorId = actorId;
-			self.Error = 0;
-		}
-	}
-
-	[ObjectSystem]
-	public class ActorMessageSenderStartSystem : StartSystem<ActorMessageSender>
-	{
-		public override async void Start(ActorMessageSender self)
-		{
-			if (self.ActorId == 0)
-			{
-				self.ActorId = await Game.Scene.GetComponent<LocationProxyComponent>().Get(self.Id);
-			}
-
-			self.Address = StartConfigComponent.Instance
-					.Get(IdGenerater.GetAppIdFromId(self.ActorId))
-					.GetComponent<InnerConfig>().IPEndPoint;
-
-			self.UpdateAsync();
+			self.Address = StartConfigComponent.Instance.Get(IdGenerater.GetAppIdFromId(self.ActorId)).GetComponent<InnerConfig>().IPEndPoint;
 		}
 	}
 	
-	[ObjectSystem]
-	public class ActorMessageSenderDestroySystem : DestroySystem<ActorMessageSender>
-	{
-		public override void Destroy(ActorMessageSender self)
-		{
-			while (self.WaitingTasks.Count > 0)
-			{
-				ActorTask actorTask = self.WaitingTasks.Dequeue();
-				actorTask.Tcs?.SetException(new RpcException(self.Error, ""));
-			}
-			
-			self.LastSendTime = 0;
-			self.Address = null;
-			self.ActorId = 0;
-			self.FailTimes = 0;
-			self.Tcs = null;
-		}
-	}
-
 	public static class ActorMessageSenderHelper
 	{
-		private static void Add(this ActorMessageSender self, ActorTask task)
-		{
-			if (self.IsDisposed)
-			{
-				throw new Exception("ActorProxy Disposed! dont hold actorproxy");
-			}
-
-			self.WaitingTasks.Enqueue(task);
-			// failtimes > 0表示正在重试,这时候不能加到正在发送队列
-			if (self.FailTimes == 0)
-			{
-				self.AllowGet();
-			}
-		}
-
-		private static void AllowGet(this ActorMessageSender self)
-		{
-			if (self.Tcs == null || self.WaitingTasks.Count <= 0)
-			{
-				return;
-			}
-
-			ActorTask task = self.WaitingTasks.Peek();
-
-			var t = self.Tcs;
-			self.Tcs = null;
-			t.SetResult(task);
-		}
-
-		private static Task<ActorTask> GetAsync(this ActorMessageSender self)
-		{
-			if (self.WaitingTasks.Count > 0)
-			{
-				ActorTask task = self.WaitingTasks.Peek();
-				return Task.FromResult(task);
-			}
-
-			self.Tcs = new TaskCompletionSource<ActorTask>();
-			return self.Tcs.Task;
-		}
-
-		public static async void UpdateAsync(this ActorMessageSender self)
-		{
-			try
-			{
-				long instanceId = self.InstanceId;
-				while (true)
-				{
-					if (self.InstanceId != instanceId)
-					{
-						return;
-					}
-					
-					ActorTask actorTask = await self.GetAsync();
-					
-					if (self.InstanceId != instanceId)
-					{
-						return;
-					}
-
-					if (actorTask.ActorMessage == null)
-					{
-						return;
-					}
-
-					await self.RunTask(actorTask);
-				}
-			}
-			catch (Exception e)
-			{
-				Log.Error(e);
-			}
-		}
-
-		private static async Task RunTask(this ActorMessageSender self, ActorTask task)
-		{
-			Session session = Game.Scene.GetComponent<NetInnerComponent>().Get(self.Address);
-
-			task.ActorMessage.ActorId = self.ActorId;
-			IResponse response = await session.Call(task.ActorMessage);
-			
-
-			// 发送成功
-			switch (response.Error)
-			{
-				case ErrorCode.ERR_NotFoundActor:
-					// 如果没找到Actor,重试
-					++self.FailTimes;
-
-					// 失败MaxFailTimes次则清空actor发送队列,返回失败
-					if (self.FailTimes > self.MaxFailTimes)
-					{
-						// 失败直接删除actorproxy
-						Log.Info($"actor send message fail, actorid: {self.Id}");
-						self.Error = response.Error;
-						self.GetParent<ActorMessageSenderComponent>().Remove(self.Id);
-						return;
-					}
-
-					// 等待1s再发送
-					await Game.Scene.GetComponent<TimerComponent>().WaitAsync(1000);
-					self.ActorId = await Game.Scene.GetComponent<LocationProxyComponent>().Get(self.Id);
-					self.Address = StartConfigComponent.Instance
-							.Get(IdGenerater.GetAppIdFromId(self.ActorId))
-							.GetComponent<InnerConfig>().IPEndPoint;
-					self.AllowGet();
-					return;
-				
-				case ErrorCode.ERR_ActorNoMailBoxComponent:
-					self.Error = response.Error;
-					self.GetParent<ActorMessageSenderComponent>().Remove(self.Id);
-					return;
-				
-				default:
-					self.LastSendTime = TimeHelper.Now();
-					self.FailTimes = 0;
-
-					self.WaitingTasks.Dequeue();
-					
-					task.Tcs?.SetResult(response);
-					
-					return;
-			}
-		}
-
 		public static void Send(this ActorMessageSender self, IActorMessage message)
-		{
-			if (message == null)
-			{
-				throw new Exception($"actor send message is null");
-			}
-			ActorTask task = new ActorTask(message);
-			self.Add(task);
-		}
-
-		public static Task<IResponse> Call(this ActorMessageSender self, IActorRequest request)
-		{
-			if (request == null)
-			{
-				throw new Exception($"actor call message is null");
-			}
-			TaskCompletionSource<IResponse> tcs = new TaskCompletionSource<IResponse>();
-			ActorTask task = new ActorTask(request, tcs);
-			self.Add(task);
-			return task.Tcs.Task;
+		{   
+			Session session = Game.Scene.GetComponent<NetInnerComponent>().Get(self.Address);
+			message.ActorId = self.ActorId;
+			session.Send(message);
 		}
-
-		public static string DebugQueue(this ActorMessageSender self, Queue<ActorTask> tasks)
+		
+		public static async Task<IActorResponse> Call(this ActorMessageSender self, IActorRequest message)
 		{
-			string s = "";
-			foreach (ActorTask task in tasks)
-			{
-				s += $" {task.ActorMessage.GetType().Name}";
-			}
-
-			return s;
+			Session session = Game.Scene.GetComponent<NetInnerComponent>().Get(self.Address);
+			message.ActorId = self.ActorId;
+			return (IActorResponse)await session.Call(message);
 		}
 	}
 }

+ 5 - 13
Server/Hotfix/Module/Actor/GateSessionActorInterceptInterceptTypeHandler.cs

@@ -10,28 +10,20 @@ namespace ETHotfix
 	[ActorInterceptTypeHandler(AppType.Gate, ActorInterceptType.GateSession)]
 	public class GateSessionActorInterceptInterceptTypeHandler : IActorInterceptTypeHandler
 	{
-		public async Task Handle(Session session, Entity entity, IActorMessage actorMessage)
+		public async Task Handle(Session session, Entity entity, object actorMessage)
 		{
-			ActorResponse actorResponse = new ActorResponse
-			{
-				RpcId = actorMessage.RpcId
-			};
 			try
 			{
+				IActorMessage iActorMessage = actorMessage as IActorMessage;
 				// 发送给客户端
 				Session clientSession = entity as Session;
-				actorMessage.ActorId = 0;
-				clientSession.Send(actorMessage);
-
-				session.Reply(actorResponse);
+				iActorMessage.ActorId = 0;
+				clientSession.Send(iActorMessage);
 				await Task.CompletedTask;
 			}
 			catch (Exception e)
 			{
-				actorResponse.Error = ErrorCode.ERR_SessionActorError;
-				actorResponse.Message = $"session actor error {e}";
-				session.Reply(actorResponse);
-				throw;
+				Log.Error(e);
 			}
 		}
 	}

+ 6 - 7
Server/Hotfix/Module/Actor/ActorMessageSenderComponentSystem.cs → Server/Hotfix/Module/ActorLocation/ActorLocationSenderComponentSystem.cs

@@ -4,10 +4,10 @@ using ETModel;
 namespace ETHotfix
 {
     [ObjectSystem]
-    public class ActorMessageSenderComponentSystem : StartSystem<ActorMessageSenderComponent>
+    public class ActorLocationSenderComponentSystem : StartSystem<ActorLocationSenderComponent>
     {
         // 每10s扫描一次过期的actorproxy进行回收,过期时间是1分钟
-        public override async void Start(ActorMessageSenderComponent self)
+        public override async void Start(ActorLocationSenderComponent self)
         {
             List<long> timeoutActorProxyIds = new List<long>();
 
@@ -23,20 +23,19 @@ namespace ETHotfix
                 timeoutActorProxyIds.Clear();
 
                 long timeNow = TimeHelper.Now();
-                foreach (long id in self.ActorMessageSenders.Keys)
+                foreach (long id in self.ActorLocationSenders.Keys)
                 {
-                    ActorMessageSender actorMessageSender = self.Get(id);
-                    if (actorMessageSender == null)
+                    ActorLocationSender actorLocationMessageSender = self.ActorLocationSenders[id];
+                    if (actorLocationMessageSender == null)
                     {
                         continue;
                     }
 
-                    if (timeNow < actorMessageSender.LastSendTime + 60 * 1000)
+                    if (timeNow < actorLocationMessageSender.LastSendTime + 60 * 1000)
                     {
                         continue;
                     }
 
-                    actorMessageSender.Error = ErrorCode.ERR_ActorTimeOut;
                     timeoutActorProxyIds.Add(id);
                 }
 

+ 204 - 0
Server/Hotfix/Module/ActorLocation/ActorLocationSenderSystem.cs

@@ -0,0 +1,204 @@
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using ETModel;
+
+namespace ETHotfix
+{
+    [ObjectSystem]
+    public class ActorLocationSenderAwakeSystem : AwakeSystem<ActorLocationSender, long>
+    {
+        public override void Awake(ActorLocationSender self, long id)
+        {
+            self.LastSendTime = TimeHelper.Now();
+	        self.Id = id;
+            self.Tcs = null;
+            self.FailTimes = 0;
+            self.ActorId = 0;
+        }
+    }
+
+    [ObjectSystem]
+    public class ActorLocationSenderStartSystem : StartSystem<ActorLocationSender>
+    {
+        public override async void Start(ActorLocationSender self)
+        {
+            self.ActorId = await Game.Scene.GetComponent<LocationProxyComponent>().Get(self.Id);
+
+            self.Address = StartConfigComponent.Instance
+                    .Get(IdGenerater.GetAppIdFromId(self.ActorId))
+                    .GetComponent<InnerConfig>().IPEndPoint;
+
+            self.UpdateAsync();
+        }
+    }
+	
+    [ObjectSystem]
+    public class ActorLocationSenderDestroySystem : DestroySystem<ActorLocationSender>
+    {
+        public override void Destroy(ActorLocationSender self)
+        {
+	        self.RunError(ErrorCode.ERR_ActorRemove);
+	        
+            self.Id = 0;
+            self.LastSendTime = 0;
+            self.Address = null;
+            self.ActorId = 0;
+            self.FailTimes = 0;
+            self.Tcs = null;
+        }
+    }
+    
+    public static class ActorLocationSenderHelper
+    {
+    	private static void Add(this ActorLocationSender self, ActorTask task)
+		{
+			if (self.IsDisposed)
+			{
+				throw new Exception("ActorLocationSender Disposed! dont hold ActorMessageSender");
+			}
+
+			self.WaitingTasks.Enqueue(task);
+			// failtimes > 0表示正在重试,这时候不能加到正在发送队列
+			if (self.FailTimes == 0)
+			{
+				self.AllowGet();
+			}
+		}
+
+	    public static void RunError(this ActorLocationSender self, int errorCode)
+	    {
+		    while (self.WaitingTasks.Count > 0)
+		    {
+			    ActorTask actorTask = self.WaitingTasks.Dequeue();
+			    actorTask.Tcs?.SetException(new RpcException(errorCode, ""));
+		    }
+		    self.WaitingTasks.Clear();
+	    }
+
+		private static void AllowGet(this ActorLocationSender self)
+		{
+			if (self.Tcs == null || self.WaitingTasks.Count <= 0)
+			{
+				return;
+			}
+
+			ActorTask task = self.WaitingTasks.Peek();
+
+			var t = self.Tcs;
+			self.Tcs = null;
+			t.SetResult(task);
+		}
+
+		private static Task<ActorTask> GetAsync(this ActorLocationSender self)
+		{
+			if (self.WaitingTasks.Count > 0)
+			{
+				ActorTask task = self.WaitingTasks.Peek();
+				return Task.FromResult(task);
+			}
+
+			self.Tcs = new TaskCompletionSource<ActorTask>();
+			return self.Tcs.Task;
+		}
+
+		public static async void UpdateAsync(this ActorLocationSender self)
+		{
+			try
+			{
+				long instanceId = self.InstanceId;
+				while (true)
+				{
+					if (self.InstanceId != instanceId)
+					{
+						return;
+					}
+					ActorTask actorTask = await self.GetAsync();
+					
+					if (self.InstanceId != instanceId)
+					{
+						return;
+					}
+					if (actorTask.ActorRequest == null)
+					{
+						return;
+					}
+
+					await self.RunTask(actorTask);
+				}
+			}
+			catch (Exception e)
+			{
+				Log.Error(e);
+			}
+		}
+
+		private static async Task RunTask(this ActorLocationSender self, ActorTask task)
+		{
+			ActorMessageSender actorMessageSender = Game.Scene.GetComponent<ActorMessageSenderComponent>().Get(self.ActorId);
+			IActorResponse response = await actorMessageSender.Call(task.ActorRequest);
+			
+			// 发送成功
+			switch (response.Error)
+			{
+				case ErrorCode.ERR_NotFoundActor:
+					// 如果没找到Actor,重试
+					++self.FailTimes;
+
+					// 失败MaxFailTimes次则清空actor发送队列,返回失败
+					if (self.FailTimes > ActorLocationSender.MaxFailTimes)
+					{
+						// 失败直接删除actorproxy
+						Log.Info($"actor send message fail, actorid: {self.Id}");
+						self.RunError(response.Error);
+						self.GetParent<ActorLocationSenderComponent>().Remove(self.Id);
+						return;
+					}
+
+					// 等待0.5s再发送
+					await Game.Scene.GetComponent<TimerComponent>().WaitAsync(500);
+					self.ActorId = await Game.Scene.GetComponent<LocationProxyComponent>().Get(self.Id);
+					self.Address = StartConfigComponent.Instance
+							.Get(IdGenerater.GetAppIdFromId(self.ActorId))
+							.GetComponent<InnerConfig>().IPEndPoint;
+					self.AllowGet();
+					return;
+				
+				case ErrorCode.ERR_ActorNoMailBoxComponent:
+					self.RunError(response.Error);
+					self.GetParent<ActorLocationSenderComponent>().Remove(self.Id);
+					return;
+				
+				default:
+					self.LastSendTime = TimeHelper.Now();
+					self.FailTimes = 0;
+					self.WaitingTasks.Dequeue();
+					task.Tcs?.SetResult(response);
+					return;
+			}
+		}
+
+	    public static void Send(this ActorLocationSender self, IActorRequest request)
+	    {
+		    if (request == null)
+		    {
+			    throw new Exception($"actor send message is null");
+		    }
+		    ActorTask task = new ActorTask(request);
+		    self.Add(task);
+	    }
+
+		public static Task<IActorResponse> Call(this ActorLocationSender self, IActorRequest request)
+		{
+			if (request == null)
+			{
+				throw new Exception($"actor call message is null");
+			}
+			TaskCompletionSource<IActorResponse> tcs = new TaskCompletionSource<IActorResponse>();
+			ActorTask task = new ActorTask(request, tcs);
+			self.Add(task);
+			return task.Tcs.Task;
+		}
+    }
+}

+ 0 - 0
Server/Hotfix/Module/Location/LocationProxyComponentSystem.cs → Server/Hotfix/Module/ActorLocation/LocationProxyComponentSystem.cs


+ 0 - 0
Server/Hotfix/Module/Location/ObjectAddRequestHandler.cs → Server/Hotfix/Module/ActorLocation/ObjectAddRequestHandler.cs


+ 0 - 0
Server/Hotfix/Module/Location/ObjectGetRequestHandler.cs → Server/Hotfix/Module/ActorLocation/ObjectGetRequestHandler.cs


+ 0 - 0
Server/Hotfix/Module/Location/ObjectLockRequestHandler.cs → Server/Hotfix/Module/ActorLocation/ObjectLockRequestHandler.cs


+ 0 - 0
Server/Hotfix/Module/Location/ObjectRemoveRequestHandler.cs → Server/Hotfix/Module/ActorLocation/ObjectRemoveRequestHandler.cs


+ 0 - 0
Server/Hotfix/Module/Location/ObjectUnLockRequestHandler.cs → Server/Hotfix/Module/ActorLocation/ObjectUnLockRequestHandler.cs


+ 15 - 4
Server/Hotfix/Module/FrameSync/G2M_SessionDisconnectHandler.cs

@@ -1,14 +1,25 @@
-using System.Threading.Tasks;
+using System;
+using System.Threading.Tasks;
 using ETModel;
 
 namespace ETHotfix
 {
 	[ActorMessageHandler(AppType.Map)]
-	public class G2M_SessionDisconnectHandler : AMActorHandler<Unit, G2M_SessionDisconnect>
+	public class G2M_SessionDisconnectHandler : AMActorRpcHandler<Unit, G2M_SessionDisconnect, ActorResponse>
 	{
-		protected override async Task Run(Unit unit, G2M_SessionDisconnect message)
+		protected override async Task Run(Unit unit, G2M_SessionDisconnect message, Action<ActorResponse> reply)
 		{
-			unit.GetComponent<UnitGateComponent>().IsDisconnect = true;
+			ActorResponse actorResponse = new ActorResponse();
+			try
+			{
+				unit.GetComponent<UnitGateComponent>().IsDisconnect = true;
+				reply(actorResponse);
+			}
+			catch (Exception e)
+			{
+				ReplyError(actorResponse, e, reply);
+			}
+			
 			await Task.CompletedTask;
 		}
 	}

+ 2 - 2
Server/Hotfix/Module/FrameSync/MessageHelper.cs

@@ -7,7 +7,7 @@ namespace ETHotfix
 		public static void Broadcast(IActorMessage message)
 		{
 			Unit[] units = Game.Scene.GetComponent<UnitComponent>().GetAll();
-			ActorMessageSenderComponent actorMessageSenderComponent = Game.Scene.GetComponent<ActorMessageSenderComponent>();
+			ActorMessageSenderComponent actorLocationSenderComponent = Game.Scene.GetComponent<ActorMessageSenderComponent>();
 			foreach (Unit unit in units)
 			{
 				UnitGateComponent unitGateComponent = unit.GetComponent<UnitGateComponent>();
@@ -16,7 +16,7 @@ namespace ETHotfix
 					continue;
 				}
 				
-				actorMessageSenderComponent.GetWithActorId(unitGateComponent.GateSessionActorId).Send(message);
+				actorLocationSenderComponent.Get(unitGateComponent.GateSessionActorId).Send(message);
 			}
 		}
 	}

+ 14 - 4
Server/Hotfix/Module/FrameSync/OneFrameMessageHandler.cs

@@ -1,14 +1,24 @@
-using System.Threading.Tasks;
+using System;
+using System.Threading.Tasks;
 using ETModel;
 
 namespace ETHotfix
 {
 	[ActorMessageHandler(AppType.Map)]
-	public class OneFrameMessageHandler: AMActorHandler<Unit, OneFrameMessage>
+	public class OneFrameMessageHandler: AMActorRpcHandler<Unit, OneFrameMessage, ActorResponse>
     {
-	    protected override async Task Run(Unit entity, OneFrameMessage message)
+	    protected override async Task Run(Unit unit, OneFrameMessage message, Action<ActorResponse> reply)
 	    {
-		    Game.Scene.GetComponent<ServerFrameComponent>().Add(message);
+		    ActorResponse actorResponse = new ActorResponse();
+		    try
+		    {
+			    Game.Scene.GetComponent<ServerFrameComponent>().Add(message);
+			    reply(actorResponse);
+		    }
+		    catch (Exception e)
+		    {
+			    ReplyError(actorResponse, e, reply);
+		    }
 		    await Task.CompletedTask;
 	    }
     }

+ 2 - 2
Server/Hotfix/Module/FrameSync/SessionPlayerComponentSystem.cs

@@ -8,8 +8,8 @@ namespace ETHotfix
 		public override void Destroy(SessionPlayerComponent self)
 		{
 			// 发送断线消息
-			ActorMessageSender actorMessageSender = Game.Scene.GetComponent<ActorMessageSenderComponent>().Get(self.Player.UnitId);
-			actorMessageSender.Send(new G2M_SessionDisconnect());
+			ActorLocationSender actorLocationSender = Game.Scene.GetComponent<ActorLocationSenderComponent>().Get(self.Player.UnitId);
+			actorLocationSender.Send(new G2M_SessionDisconnect());
 			Game.Scene.GetComponent<PlayerComponent>()?.Remove(self.Player.Id);
 		}
 	}

+ 48 - 23
Server/Hotfix/Module/Message/InnerMessageDispatcher.cs

@@ -8,39 +8,64 @@ namespace ETHotfix
 		public void Dispatch(Session session, ushort opcode, object message)
 		{
 			// 收到actor消息,放入actor队列
-			if (message is IActorMessage iActorMessage)
+			switch (message)
 			{
-				Entity entity = (Entity)Game.EventSystem.Get(iActorMessage.ActorId);
-				if (entity == null)
+				case IActorRequest iActorRequest:
 				{
-					Log.Warning($"not found actor: {iActorMessage.ActorId}");
-					ActorResponse response = new ActorResponse
+					Entity entity = (Entity)Game.EventSystem.Get(iActorRequest.ActorId);
+					if (entity == null)
 					{
-						Error = ErrorCode.ERR_NotFoundActor,
-						RpcId = iActorMessage.RpcId
-					};
-					session.Reply(response);
+						Log.Warning($"not found actor: {iActorRequest.ActorId}");
+						ActorResponse response = new ActorResponse
+						{
+							Error = ErrorCode.ERR_NotFoundActor,
+							RpcId = iActorRequest.RpcId
+						};
+						session.Reply(response);
+						return;
+					}
+	
+					MailBoxComponent mailBoxComponent = entity.GetComponent<MailBoxComponent>();
+					if (mailBoxComponent == null)
+					{
+						ActorResponse response = new ActorResponse
+						{
+							Error = ErrorCode.ERR_ActorNoMailBoxComponent,
+							RpcId = iActorRequest.RpcId
+						};
+						session.Reply(response);
+						Log.Error($"actor没有挂载MailBoxComponent组件: {entity.GetType().Name} {entity.Id}");
+						return;
+					}
+				
+					mailBoxComponent.Add(new ActorMessageInfo() { Session = session, Message = iActorRequest });
 					return;
 				}
-	
-				MailBoxComponent mailBoxComponent = entity.GetComponent<MailBoxComponent>();
-				if (mailBoxComponent == null)
+				case IActorMessage iactorMessage:
 				{
-					ActorResponse response = new ActorResponse
+					Entity entity = (Entity)Game.EventSystem.Get(iactorMessage.ActorId);
+					if (entity == null)
+					{
+						Log.Error($"not found actor: {iactorMessage.ActorId}");
+						return;
+					}
+	
+					MailBoxComponent mailBoxComponent = entity.GetComponent<MailBoxComponent>();
+					if (mailBoxComponent == null)
 					{
-						Error = ErrorCode.ERR_ActorNoMailBoxComponent,
-						RpcId = iActorMessage.RpcId
-					};
-					session.Reply(response);
-					Log.Error($"actor没有挂载MailBoxComponent组件: {entity.GetType().Name} {entity.Id}");
+						Log.Error($"actor not add MailBoxComponent: {iactorMessage.ActorId}");
+						return;
+					}
+				
+					mailBoxComponent.Add(new ActorMessageInfo() { Session = session, Message = iactorMessage });
 					return;
 				}
-				
-				mailBoxComponent.Add(new ActorMessageInfo() { Session = session, Message = iActorMessage });
-				return;
+				default:
+				{
+					Game.Scene.GetComponent<MessageDispatherComponent>().Handle(session, new MessageInfo(opcode, message));
+					break;
+				}
 			}
-			
-			Game.Scene.GetComponent<MessageDispatherComponent>().Handle(session, new MessageInfo(opcode, message));
 		}
 	}
 }

+ 40 - 34
Server/Hotfix/Module/Message/OuterMessageDispatcher.cs

@@ -8,46 +8,52 @@ namespace ETHotfix
 	{
 		public async void Dispatch(Session session, ushort opcode, object message)
 		{
-			switch (message)
+			try
 			{
-				case IFrameMessage iFrameMessage: // 如果是帧消息,构造成OneFrameMessage发给对应的unit
+				switch (message)
 				{
-					long unitId = session.GetComponent<SessionPlayerComponent>().Player.UnitId;
-					ActorMessageSender actorMessageSender = Game.Scene.GetComponent<ActorMessageSenderComponent>().Get(unitId);
-	
-					// 这里设置了帧消息的id,防止客户端伪造
-					iFrameMessage.Id = unitId;
+					case IFrameMessage iFrameMessage: // 如果是帧消息,构造成OneFrameMessage发给对应的unit
+					{
+						long unitId = session.GetComponent<SessionPlayerComponent>().Player.UnitId;
+						ActorLocationSender actorLocationSender = Game.Scene.GetComponent<ActorLocationSenderComponent>().Get(unitId);
+
+						// 这里设置了帧消息的id,防止客户端伪造
+						iFrameMessage.Id = unitId;
 
-					OneFrameMessage oneFrameMessage = new OneFrameMessage
+						OneFrameMessage oneFrameMessage = new OneFrameMessage
+						{
+							Op = opcode, AMessage = ByteString.CopyFrom(session.Network.MessagePacker.SerializeTo(iFrameMessage))
+						};
+						actorLocationSender.Send(oneFrameMessage);
+						return;
+					}
+					case IClientActorMessage clientActorMessage:
 					{
-						Op = opcode,
-						AMessage = ByteString.CopyFrom(session.Network.MessagePacker.SerializeTo(iFrameMessage))
-					};
-					actorMessageSender.Send(oneFrameMessage);
-					return;
-				}
-				case IActorRequest iActorRequest: // gate session收到actor rpc消息,先向actor 发送rpc请求,再将请求结果返回客户端
-				{
-					long unitId = session.GetComponent<SessionPlayerComponent>().Player.UnitId;
-					ActorMessageSender actorMessageSender = Game.Scene.GetComponent<ActorMessageSenderComponent>().Get(unitId);
-	
-					int rpcId = iActorRequest.RpcId; // 这里要保存客户端的rpcId
-					IResponse response = await actorMessageSender.Call(iActorRequest);
-					response.RpcId = rpcId;
-	
-					session.Reply(response);
-					return;
-				}
-				case IActorMessage iActorMessage: // gate session收到actor消息直接转发给actor自己去处理
-				{
-					long unitId = session.GetComponent<SessionPlayerComponent>().Player.UnitId;
-					ActorMessageSender actorMessageSender = Game.Scene.GetComponent<ActorMessageSenderComponent>().Get(unitId);
-					actorMessageSender.Send(iActorMessage);
-					return;
+						long unitId = session.GetComponent<SessionPlayerComponent>().Player.UnitId;
+						ActorLocationSender actorLocationSender = Game.Scene.GetComponent<ActorLocationSenderComponent>().Get(unitId);
+						actorLocationSender.Send(clientActorMessage);
+						return;
+					}
+					case IClientActorRequest clientActorRequest: // gate session收到actor rpc消息,先向actor 发送rpc请求,再将请求结果返回客户端
+					{
+						long unitId = session.GetComponent<SessionPlayerComponent>().Player.UnitId;
+						ActorLocationSender actorLocationSender = Game.Scene.GetComponent<ActorLocationSenderComponent>().Get(unitId);
+
+						int rpcId = clientActorRequest.RpcId; // 这里要保存客户端的rpcId
+						IResponse response = await actorLocationSender.Call(clientActorRequest);
+						response.RpcId = rpcId;
+
+						session.Reply(response);
+						return;
+					}
 				}
+
+				Game.Scene.GetComponent<MessageDispatherComponent>().Handle(session, new MessageInfo(opcode, message));
+			}
+			catch (Exception e)
+			{
+				Log.Error(e);
 			}
-	
-			Game.Scene.GetComponent<MessageDispatherComponent>().Handle(session, new MessageInfo(opcode, message));
 		}
 	}
 }

+ 8 - 15
Server/Model/Module/Actor/AMActorHandler.cs

@@ -3,16 +3,16 @@ using System.Threading.Tasks;
 
 namespace ETModel
 {
-	public abstract class AMActorHandler<E, Message>: IMActorHandler where E: Entity where Message : class 
+	public abstract class AMActorHandler<E, Message>: IMActorHandler where E: Entity where Message : class, IActorMessage
 	{
 		protected abstract Task Run(E entity, Message message);
 
-		public async Task Handle(Session session, Entity entity, IActorMessage actorRequest)
+		public async Task Handle(Session session, Entity entity, object actorMessage)
 		{
-			Message msg = actorRequest as Message;
+			Message msg = actorMessage as Message;
 			if (msg == null)
 			{
-				Log.Error($"消息类型转换错误: {actorRequest.GetType().FullName} to {typeof (Message).Name}");
+				Log.Error($"消息类型转换错误: {actorMessage.GetType().FullName} to {typeof (Message).Name}");
 				return;
 			}
 			E e = entity as E;
@@ -22,13 +22,6 @@ namespace ETModel
 				return;
 			}
 
-			int rpcId = actorRequest.RpcId;
-			ActorResponse response = new ActorResponse
-			{
-				RpcId = rpcId
-			};
-			session.Reply(response);
-
 			await this.Run(e, msg);
 		}
 
@@ -50,14 +43,14 @@ namespace ETModel
 
 		protected abstract Task Run(E unit, Request message, Action<Response> reply);
 
-		public async Task Handle(Session session, Entity entity, IActorMessage actorRequest)
+		public async Task Handle(Session session, Entity entity, object actorMessage)
 		{
 			try
 			{
-				Request request = actorRequest as Request;
+				Request request = actorMessage as Request;
 				if (request == null)
 				{
-					Log.Error($"消息类型转换错误: {actorRequest.GetType().FullName} to {typeof (Request).Name}");
+					Log.Error($"消息类型转换错误: {actorMessage.GetType().FullName} to {typeof (Request).Name}");
 					return;
 				}
 				E e = entity as E;
@@ -85,7 +78,7 @@ namespace ETModel
 			}
 			catch (Exception e)
 			{
-				throw new Exception($"解释消息失败: {actorRequest.GetType().FullName}", e);
+				throw new Exception($"解释消息失败: {actorMessage.GetType().FullName}", e);
 			}
 		}
 

+ 3 - 31
Server/Model/Module/Actor/ActorMessageSender.cs

@@ -1,41 +1,13 @@
-using System.Collections.Generic;
-using System.Net;
-using System.Threading;
-using System.Threading.Tasks;
+using System.Net;
 
 namespace ETModel
 {
-	public sealed class ActorMessageSender : Entity
+	// 知道对方的instanceId,使用这个类发actor消息
+	public class ActorMessageSender : ComponentWithId
 	{
 		// actor的地址
 		public IPEndPoint Address;
 
 		public long ActorId;
-		
-		// 还没发送的消息
-		public Queue<ActorTask> WaitingTasks = new Queue<ActorTask>();
-		
-		// 最近发送消息的时间
-		public long LastSendTime;
-
-		public TaskCompletionSource<ActorTask> Tcs;
-
-		public int FailTimes;
-
-		public int MaxFailTimes;
-
-		public int Error;
-
-		public override void Dispose()
-		{
-			if (this.IsDisposed)
-			{
-				return;
-			}
-			
-			base.Dispose();
-
-			this.Error = 0;
-		}
 	}
 }

+ 4 - 20
Server/Model/Module/Actor/ActorMessageSenderComponent.cs

@@ -13,32 +13,17 @@ namespace ETModel
 			{
 				return;
 			}
+			
 			base.Dispose();
+			
 			foreach (ActorMessageSender actorMessageSender in this.ActorMessageSenders.Values)
 			{
 				actorMessageSender.Dispose();
 			}
 			this.ActorMessageSenders.Clear();
 		}
-
-		public ActorMessageSender Get(long id)
-		{
-			if (id == 0)
-			{
-				throw new Exception($"actor id is 0");
-			}
-			if (this.ActorMessageSenders.TryGetValue(id, out ActorMessageSender actorMessageSender))
-			{
-				return actorMessageSender;
-			}
-			
-			actorMessageSender = ComponentFactory.CreateWithId<ActorMessageSender>(id);
-			actorMessageSender.Parent = this;
-			this.ActorMessageSenders[id] = actorMessageSender;
-			return actorMessageSender;
-		}
 		
-		public ActorMessageSender GetWithActorId(long actorId)
+		public ActorMessageSender Get(long actorId)
 		{
 			if (actorId == 0)
 			{
@@ -57,8 +42,7 @@ namespace ETModel
 
 		public void Remove(long id)
 		{
-			ActorMessageSender actorMessageSender;
-			if (!this.ActorMessageSenders.TryGetValue(id, out actorMessageSender))
+			if (!this.ActorMessageSenders.TryGetValue(id, out ActorMessageSender actorMessageSender))
 			{
 				return;
 			}

+ 6 - 6
Server/Model/Module/Actor/ActorTask.cs

@@ -4,19 +4,19 @@ namespace ETModel
 {
 	public struct ActorTask
 	{
-		public IActorMessage ActorMessage;
+		public IActorRequest ActorRequest;
 		
-		public TaskCompletionSource<IResponse> Tcs;
+		public TaskCompletionSource<IActorResponse> Tcs;
 
-		public ActorTask(IActorMessage actorMessage)
+		public ActorTask(IActorRequest actorRequest)
 		{
-			this.ActorMessage = actorMessage;
+			this.ActorRequest = actorRequest;
 			this.Tcs = null;
 		}
 		
-		public ActorTask(IActorMessage actorMessage, TaskCompletionSource<IResponse> tcs)
+		public ActorTask(IActorRequest actorRequest, TaskCompletionSource<IActorResponse> tcs)
 		{
-			this.ActorMessage = actorMessage;
+			this.ActorRequest = actorRequest;
 			this.Tcs = tcs;
 		}
 	}

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

@@ -4,6 +4,6 @@ namespace ETModel
 {
 	public interface IActorInterceptTypeHandler
 	{
-		Task Handle(Session session, Entity entity, IActorMessage actorMessage);
+		Task Handle(Session session, Entity entity, object actorMessage);
 	}
 }

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

@@ -5,7 +5,7 @@ namespace ETModel
 {
 	public interface IMActorHandler
 	{
-		Task Handle(Session session, Entity entity, IActorMessage actorRequest);
+		Task Handle(Session session, Entity entity, object actorMessage);
 		Type GetMessageType();
 	}
 }

+ 1 - 1
Server/Model/Module/Actor/MailBoxComponent.cs

@@ -6,7 +6,7 @@ namespace ETModel
 	public struct ActorMessageInfo
 	{
 		public Session Session;
-		public IActorMessage Message;
+		public object Message;
 	}
 
 	/// <summary>

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

@@ -0,0 +1,37 @@
+using System.Collections.Generic;
+using System.Net;
+using System.Threading.Tasks;
+
+namespace ETModel
+{
+	// 知道对方的Id,使用这个类发actor消息
+	public class ActorLocationSender : ComponentWithId
+	{
+		// actor的地址
+		public IPEndPoint Address;
+
+		public long ActorId;
+		
+		// 还没发送的消息
+		public Queue<ActorTask> WaitingTasks = new Queue<ActorTask>();
+
+		// 最近发送消息的时间
+		public long LastSendTime;
+		
+		public int FailTimes;
+
+		public const int MaxFailTimes = 5;
+		
+		public TaskCompletionSource<ActorTask> Tcs;
+
+		public override void Dispose()
+		{
+			if (this.IsDisposed)
+			{
+				return;
+			}
+			
+			base.Dispose();
+		}
+	}
+}

+ 53 - 0
Server/Model/Module/ActorLocation/ActorLocationSenderComponent.cs

@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+
+namespace ETModel
+{
+	public class ActorLocationSenderComponent: Component
+	{
+		public readonly Dictionary<long, ActorLocationSender> ActorLocationSenders = new Dictionary<long, ActorLocationSender>();
+
+		public override void Dispose()
+		{
+			if (this.IsDisposed)
+			{
+				return;
+			}
+			
+			base.Dispose();
+			
+			foreach (ActorLocationSender actorLocationSender in this.ActorLocationSenders.Values)
+			{
+				actorLocationSender.Dispose();
+			}
+			this.ActorLocationSenders.Clear();
+		}
+
+		public ActorLocationSender Get(long id)
+		{
+			if (id == 0)
+			{
+				throw new Exception($"actor id is 0");
+			}
+			if (this.ActorLocationSenders.TryGetValue(id, out ActorLocationSender actorLocationSender))
+			{
+				return actorLocationSender;
+			}
+			
+			actorLocationSender = ComponentFactory.CreateWithId<ActorLocationSender>(id);
+			actorLocationSender.Parent = this;
+			this.ActorLocationSenders[id] = actorLocationSender;
+			return actorLocationSender;
+		}
+		
+		public void Remove(long id)
+		{
+			if (!this.ActorLocationSenders.TryGetValue(id, out ActorLocationSender actorMessageSender))
+			{
+				return;
+			}
+			this.ActorLocationSenders.Remove(id);
+			actorMessageSender.Dispose();
+		}
+	}
+}

+ 0 - 0
Server/Model/Module/Location/Location.cs → Server/Model/Module/ActorLocation/Location.cs


+ 0 - 0
Server/Model/Module/Location/LocationComponent.cs → Server/Model/Module/ActorLocation/LocationComponent.cs


+ 0 - 0
Server/Model/Module/Location/LocationProxyComponent.cs → Server/Model/Module/ActorLocation/LocationProxyComponent.cs


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

@@ -374,7 +374,7 @@ namespace ETModel
 	}
 
 	[Message(InnerOpcode.G2M_SessionDisconnect)]
-	public partial class G2M_SessionDisconnect: IActorMessage
+	public partial class G2M_SessionDisconnect: IActorRequest
 	{
 		public int RpcId { get; set; }
 

+ 3 - 0
Server/Model/Server.Model.csproj

@@ -17,6 +17,9 @@
   </PropertyGroup>
   <ItemGroup>
     <Compile Remove="Libs\**" />
+    <Compile Include="..\..\Unity\Assets\Scripts\Module\Message\IClientActorMessage.cs">
+      <Link>Module\Message\IClientActorMessage.cs</Link>
+    </Compile>
     <Compile Include="..\..\Unity\Assets\Scripts\Module\Message\MessagePool.cs">
       <Link>Module\Message\MessagePool\ETModel\MessagePool.cs</Link>
     </Compile>

+ 1 - 1
Unity/Assets/Scripts/Module/FrameSync/FrameOpcode.cs

@@ -2,7 +2,7 @@ using ETModel;
 namespace ETModel
 {
 	[Message(FrameOpcode.OneFrameMessage)]
-	public partial class OneFrameMessage : IActorMessage {}
+	public partial class OneFrameMessage : IClientActorMessage {}
 
 	[Message(FrameOpcode.FrameMessage)]
 	public partial class FrameMessage : IActorMessage {}

+ 1 - 1
Unity/Assets/Scripts/Module/Message/ErrorCode.cs

@@ -15,7 +15,7 @@ namespace ETModel
 		
 		public const int ERR_NotFoundActor = 200002;
 		public const int ERR_ActorNoMailBoxComponent = 200003;
-		public const int ERR_ActorTimeOut = 200004;
+		public const int ERR_ActorRemove = 200004;
 		public const int ERR_PacketParserError = 200005;
 
 		public const int ERR_AccountOrPasswordError = 200102;

+ 5 - 4
Unity/Assets/Scripts/Module/Message/IActorMessage.cs

@@ -1,13 +1,14 @@
-// 不要在这个文件加[ProtoInclude]跟[BsonKnowType]标签,加到InnerMessage.cs或者OuterMessage.cs里面去
-namespace ETModel
+namespace ETModel
 {
-	public interface IActorMessage: IRequest
+	// 不需要返回消息
+	public interface IActorMessage: IMessage
 	{
 		long ActorId { get; set; }
 	}
 
-	public interface IActorRequest : IActorMessage
+	public interface IActorRequest : IRequest
 	{
+		long ActorId { get; set; }
 	}
 
 	public interface IActorResponse : IResponse

+ 16 - 0
Unity/Assets/Scripts/Module/Message/IClientActorMessage.cs

@@ -0,0 +1,16 @@
+namespace ETModel
+{
+	// 客户端发送actor消息
+	public interface IClientActorMessage : IActorRequest
+	{
+	}
+
+	// 客户端发送actor rpc消息
+	public interface IClientActorRequest : IActorRequest
+	{
+	}
+	
+	public interface IClientActorResponse : IActorResponse
+	{
+	}
+}

+ 11 - 0
Unity/Assets/Scripts/Module/Message/IClientActorMessage.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 7dacefeae8503564bb3b4afb823d9c79
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 2 - 2
Unity/Hotfix/Module/Message/HotfixOpcode.cs

@@ -17,10 +17,10 @@ namespace ETHotfix
 	public partial class G2C_TestHotfixMessage : IMessage {}
 
 	[Message(HotfixOpcode.C2M_TestActorRequest)]
-	public partial class C2M_TestActorRequest : IActorRequest {}
+	public partial class C2M_TestActorRequest : IClientActorRequest {}
 
 	[Message(HotfixOpcode.M2C_TestActorResponse)]
-	public partial class M2C_TestActorResponse : IActorResponse {}
+	public partial class M2C_TestActorResponse : IClientActorResponse {}
 
 	[Message(HotfixOpcode.PlayerInfo)]
 	public partial class PlayerInfo : IMessage {}

+ 16 - 0
Unity/Hotfix/Module/Message/IClientActorMessage.cs

@@ -0,0 +1,16 @@
+namespace ETHotfix
+{
+	// 客户端发送actor消息
+	public interface IClientActorMessage : IActorRequest
+	{
+	}
+
+	// 客户端发送actor rpc消息
+	public interface IClientActorRequest : IActorRequest
+	{
+	}
+	
+	public interface IClientActorResponse : IActorResponse
+	{
+	}
+}

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

@@ -77,6 +77,7 @@
     <Compile Include="Module\Config\ConfigHelper.cs" />
     <Compile Include="Module\Message\IActorMessage.cs" />
     <Compile Include="Module\Message\HotfixMessageDispatcher.cs" />
+    <Compile Include="Module\Message\IClientActorMessage.cs" />
     <Compile Include="Module\Message\IMessage.cs" />
     <Compile Include="Module\Message\AMHandler.cs" />
     <Compile Include="Module\Message\IMHandler.cs" />

+ 8 - 4
Unity/Unity.csproj

@@ -12,13 +12,16 @@
     <ProjectTypeGuids>{E097FAD1-6243-4DAD-9C02-E9B9EFC3FFC1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
     <TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
     <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
-    <TargetFrameworkProfile></TargetFrameworkProfile>
-    <CompilerResponseFile></CompilerResponseFile>
+    <TargetFrameworkProfile>
+    </TargetFrameworkProfile>
+    <CompilerResponseFile>
+    </CompilerResponseFile>
     <UnityProjectGenerator>VSTU</UnityProjectGenerator>
     <UnityProjectType>Game:1</UnityProjectType>
     <UnityBuildTarget>StandaloneWindows64:19</UnityBuildTarget>
     <UnityVersion>2017.4.9f1</UnityVersion>
-    <RootNamespace></RootNamespace>
+    <RootNamespace>
+    </RootNamespace>
     <LangVersion>6</LangVersion>
   </PropertyGroup>
   <PropertyGroup>
@@ -380,6 +383,7 @@
     <Compile Include="Assets\Scripts\Module\Message\AMHandler.cs" />
     <Compile Include="Assets\Scripts\Module\Message\ErrorCode.cs" />
     <Compile Include="Assets\Scripts\Module\Message\IActorMessage.cs" />
+    <Compile Include="Assets\Scripts\Module\Message\IClientActorMessage.cs" />
     <Compile Include="Assets\Scripts\Module\Message\IMessage.cs" />
     <Compile Include="Assets\Scripts\Module\Message\IMessageDispatcher.cs" />
     <Compile Include="Assets\Scripts\Module\Message\IMessagePacker.cs" />
@@ -1149,4 +1153,4 @@
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Target Name="GenerateTargetFrameworkMonikerAttribute" />
-</Project>
+</Project>