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

1.消息格式变化,size(2byte)+ headSize(2byte) + head + message
2.去掉消息继承结构,使用接口
为热更协议做准备,变化非常大,更新请慎重

tanghai 8 лет назад
Родитель
Сommit
0dbce9a954
51 измененных файлов с 827 добавлено и 473 удалено
  1. 1 1
      Client-Server.sln
  2. 1 1
      Client-Server.sln.DotSettings.user
  3. 1 1
      Server/Hotfix/Helper/MessageHelper.cs
  4. 1 1
      Server/Hotfix/Module/Actor/ActorComponentSystem.cs
  5. 10 27
      Server/Hotfix/Module/Network/InnerMessageDispatcher.cs
  6. 9 8
      Server/Hotfix/Module/Network/OuterMessageDispatcher.cs
  7. 12 15
      Server/Hotfix/Other/EntityActorHandler.cs
  8. 2 2
      Server/Hotfix/System/ServerFrameComponentSystem.cs
  9. 8 9
      Server/Model/Base/Message/AMActorHandler.cs
  10. 3 4
      Server/Model/Base/Message/AMRpcHandler.cs
  11. 38 0
      Server/Model/Base/Message/ActorRequestWrap.cs
  12. 1 1
      Server/Model/Base/Message/IEntityActorHandler.cs
  13. 1 1
      Server/Model/Base/Message/IMActorHandler.cs
  14. 1 1
      Server/Model/Base/Message/IMHandler.cs
  15. 129 125
      Server/Model/Entity/Message/InnerMessage.cs
  16. 1 0
      Server/Model/Module/Actor/ActorComponent.cs
  17. 2 2
      Server/Model/Module/Actor/ActorMessageDispatherComponent.cs
  18. 20 21
      Server/Model/Module/Actor/ActorProxy.cs
  19. 2 2
      Server/Model/Module/Network/AMHandler.cs
  20. 3 3
      Server/Model/Module/Network/MessageDispatherComponent.cs
  21. 2 1
      Server/Model/Server.Model.csproj
  22. 5 8
      Unity/Assets/Scripts/Base/Message/AActorMessage.cs
  23. 2 2
      Unity/Assets/Scripts/Base/Message/AMHandler.cs
  24. 30 34
      Unity/Assets/Scripts/Base/Message/AMessage.cs
  25. 6 3
      Unity/Assets/Scripts/Base/Message/ClientDispatcher.cs
  26. 1 1
      Unity/Assets/Scripts/Base/Message/IMHandler.cs
  27. 52 0
      Unity/Assets/Scripts/Base/Message/IMessage.cs
  28. 0 0
      Unity/Assets/Scripts/Base/Message/IMessage.cs.meta
  29. 1 1
      Unity/Assets/Scripts/Base/Message/IMessageDispatcher.cs
  30. 2 2
      Unity/Assets/Scripts/Base/Message/MessageInfo.cs
  31. 2 5
      Unity/Assets/Scripts/Base/Message/Opcode.cs
  32. 9 4
      Unity/Assets/Scripts/Base/Network/TNet/PacketParser.cs
  33. 2 2
      Unity/Assets/Scripts/Component/ClientFrameComponent.cs
  34. 3 3
      Unity/Assets/Scripts/Component/MessageDispatherComponent.cs
  35. 0 4
      Unity/Assets/Scripts/Entity/Message/Opcode.cs
  36. 69 71
      Unity/Assets/Scripts/Entity/Message/OuterMessage.cs
  37. 65 96
      Unity/Assets/Scripts/Entity/Session.cs
  38. 28 1
      Unity/Assets/Scripts/Helper/ILHelper.cs
  39. 6 0
      Unity/Assets/Scripts/Helper/MessageHelper.cs
  40. 12 0
      Unity/Assets/Scripts/Helper/MessageHelper.cs.meta
  41. 47 0
      Unity/Assets/Scripts/Helper/SessionHelper.cs
  42. 12 0
      Unity/Assets/Scripts/Helper/SessionHelper.cs.meta
  43. 2 2
      Unity/Hotfix/Module/HotfixMessage/AMHandler.cs
  44. 16 0
      Unity/Hotfix/Module/HotfixMessage/AMessage.cs
  45. 0 0
      Unity/Hotfix/Module/HotfixMessage/IMHandler.cs
  46. 86 0
      Unity/Hotfix/Module/HotfixMessage/MessageDispatherComponent.cs
  47. 60 0
      Unity/Hotfix/Module/HotfixMessage/OpcodeTypeComponent.cs
  48. 43 0
      Unity/Hotfix/Module/HotfixMessage/SessionWrap.cs
  49. 0 0
      Unity/Hotfix/Module/HotfixMessage/UIComponent.cs
  50. 8 3
      Unity/Hotfix/Unity.Hotfix.csproj
  51. 10 5
      Unity/Unity.csproj

+ 1 - 1
Client-Server.sln

@@ -1,7 +1,7 @@
 
 Microsoft Visual Studio Solution File, Format Version 12.00
 # Visual Studio 15
-VisualStudioVersion = 15.0.27130.2010
+VisualStudioVersion = 15.0.27130.2027
 MinimumVisualStudioVersion = 10.0.40219.1
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Plugins", "Unity\Unity.Plugins.csproj", "{D1FDB199-0FB7-099D-3771-C6A942E4E326}"
 EndProject

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

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

+ 1 - 1
Server/Hotfix/Helper/MessageHelper.cs

@@ -4,7 +4,7 @@ namespace Hotfix
 {
 	public static class MessageHelper
 	{
-		public static void Broadcast(AActorMessage message)
+		public static void Broadcast(IMessage message)
 		{
 			Unit[] units = Game.Scene.GetComponent<UnitComponent>().GetAll();
 			ActorProxyComponent actorProxyComponent = Game.Scene.GetComponent<ActorProxyComponent>();

+ 1 - 1
Server/Hotfix/Module/Actor/ActorComponentSystem.cs

@@ -104,7 +104,7 @@ namespace Hotfix
 					{
 						return;
 					}
-					await self.entityActorHandler.Handle(info.Session, self.Parent, info.Message);
+					await self.entityActorHandler.Handle(info.Session, self.Parent, info.RpcId, info.Message);
 				}
 				catch (Exception e)
 				{

+ 10 - 27
Server/Hotfix/Module/Network/InnerMessageDispatcher.cs

@@ -5,49 +5,32 @@ namespace Hotfix
 {
 	public class InnerMessageDispatcher: IMessageDispatcher
 	{
-		public void Dispatch(Session session, ushort opcode, int offset, byte[] messageBytes, AMessage message)
+		public void Dispatch(Session session, PacketInfo packetInfo)
 		{
+			Type messageType = Game.Scene.GetComponent<OpcodeTypeComponent>().GetType(packetInfo.Header.Opcode);
+			IMessage message = (IMessage)session.network.MessagePacker.DeserializeFrom(messageType, packetInfo.Bytes, packetInfo.Index, packetInfo.Length);
+
 			// 收到actor rpc request
-			if (message is ActorRpcRequest actorRpcRequest)
+			if (message is ActorRequest actorRpcRequest)
 			{
 				Entity entity = Game.Scene.GetComponent<ActorManagerComponent>().Get(actorRpcRequest.Id);
 				if (entity == null)
 				{
 					Log.Warning($"not found actor: {actorRpcRequest.Id}");
-					ActorRpcResponse response = new ActorRpcResponse
-					{
-						RpcId = actorRpcRequest.RpcId,
-						Error = ErrorCode.ERR_NotFoundActor
-					};
-					session.Reply(response);
-					return;
-				}
-				entity.GetComponent<ActorComponent>().Add(new ActorMessageInfo() { Session = session, Message = actorRpcRequest });
-				return;
-			}
-
-			// 收到actor消息分发给actor自己去处理
-			if (message is ActorRequest actorRequest)
-			{
-				Entity entity = Game.Scene.GetComponent<ActorManagerComponent>().Get(actorRequest.Id);
-				if (entity == null)
-				{
-					Log.Warning($"not found actor: {actorRequest.Id}");
 					ActorResponse response = new ActorResponse
 					{
-						RpcId = actorRequest.RpcId,
 						Error = ErrorCode.ERR_NotFoundActor
 					};
-					session.Reply(response);
+					session.Reply(packetInfo.Header.RpcId, response);
 					return;
 				}
-				entity.GetComponent<ActorComponent>().Add(new ActorMessageInfo() { Session = session, Message = actorRequest });
+				entity.GetComponent<ActorComponent>().Add(new ActorMessageInfo() { Session = session, RpcId = packetInfo.Header.RpcId, Message = actorRpcRequest });
 				return;
 			}
-
-			if (message is AMessage || message is ARequest)
+			
+			if (message is IMessage || message is IRequest)
 			{
-				Game.Scene.GetComponent<MessageDispatherComponent>().Handle(session, message);
+				Game.Scene.GetComponent<MessageDispatherComponent>().Handle(session, packetInfo.Header.RpcId, message);
 				return;
 			}
 

+ 9 - 8
Server/Hotfix/Module/Network/OuterMessageDispatcher.cs

@@ -5,10 +5,13 @@ namespace Hotfix
 {
 	public class OuterMessageDispatcher: IMessageDispatcher
 	{
-		public async void Dispatch(Session session, ushort opcode, int offset, byte[] messageBytes, AMessage message)
+		public async void Dispatch(Session session, PacketInfo packetInfo)
 		{
+			Type messageType = Game.Scene.GetComponent<OpcodeTypeComponent>().GetType(packetInfo.Header.Opcode);
+			IMessage message = (IMessage)session.network.MessagePacker.DeserializeFrom(messageType, packetInfo.Bytes, packetInfo.Index, packetInfo.Length);
+
 			// gate session收到actor消息直接转发给actor自己去处理
-			if (message is AActorMessage)
+			if (message is IActorMessage)
 			{
 				long unitId = session.GetComponent<SessionPlayerComponent>().Player.UnitId;
 				ActorProxy actorProxy = Game.Scene.GetComponent<ActorProxyComponent>().Get(unitId);
@@ -17,20 +20,18 @@ namespace Hotfix
 			}
 
 			// gate session收到actor rpc消息,先向actor 发送rpc请求,再将请求结果返回客户端
-			if (message is AActorRequest aActorRequest)
+			if (message is IActorRequest aActorRequest)
 			{
 				long unitId = session.GetComponent<SessionPlayerComponent>().Player.UnitId;
 				ActorProxy actorProxy = Game.Scene.GetComponent<ActorProxyComponent>().Get(unitId);
-				uint rpcId = aActorRequest.RpcId;
-				AResponse response = await actorProxy.Call<AResponse>(aActorRequest);
-				response.RpcId = rpcId;
-				session.Reply(response);
+				IResponse response = await actorProxy.Call(aActorRequest);
+				session.Reply(packetInfo.Header.RpcId, response);
 				return;
 			}
 
 			if (message != null)
 			{
-				Game.Scene.GetComponent<MessageDispatherComponent>().Handle(session, message);
+				Game.Scene.GetComponent<MessageDispatherComponent>().Handle(session, packetInfo.Header.RpcId, message);
 				return;
 			}
 

+ 12 - 15
Server/Hotfix/Other/EntityActorHandler.cs

@@ -9,21 +9,21 @@ namespace Hotfix
     /// </summary>
     public class GateSessionEntityActorHandler : IEntityActorHandler
     {
-        public async Task Handle(Session session, Entity entity, ActorRequest message)
+        public async Task Handle(Session session, Entity entity, uint rpcId, ActorRequest message)
         {
-	        ActorResponse response = new ActorResponse { RpcId = message.RpcId };
+	        ActorResponse response = new ActorResponse();
 
 			try
 	        {
-		        ((Session)entity).Send(message.AMessage);
-		        session.Reply(response);
+		        ((Session)entity).Send((IMessage)message.AMessage);
+		        session.Reply(rpcId, response);
 		        await Task.CompletedTask;
 	        }
 	        catch (Exception e)
 	        {
 		        response.Error = ErrorCode.ERR_SessionActorError;
 		        response.Message = $"session actor error {e}";
-				session.Reply(response);
+				session.Reply(rpcId, response);
 				throw;
 	        }
         }
@@ -31,9 +31,9 @@ namespace Hotfix
 
     public class CommonEntityActorHandler : IEntityActorHandler
     {
-        public async Task Handle(Session session, Entity entity, ActorRequest message)
+        public async Task Handle(Session session, Entity entity, uint rpcId, ActorRequest message)
         {
-            await Game.Scene.GetComponent<ActorMessageDispatherComponent>().Handle(session, entity, message);
+            await Game.Scene.GetComponent<ActorMessageDispatherComponent>().Handle(session, entity, rpcId, message);
         }
     }
 
@@ -42,21 +42,18 @@ namespace Hotfix
     /// </summary>
     public class MapUnitEntityActorHandler : IEntityActorHandler
     {
-        public async Task Handle(Session session, Entity entity, ActorRequest message)
+        public async Task Handle(Session session, Entity entity, uint rpcId, ActorRequest message)
         {
-            if (message.AMessage is AFrameMessage aFrameMessage)
+            if (message.AMessage is IFrameMessage aFrameMessage)
             {
 				// 客户端发送不需要设置Frame消息的id,在这里统一设置,防止客户端被破解发个假的id过来
 	            aFrameMessage.Id = entity.Id;
 				Game.Scene.GetComponent<ServerFrameComponent>().Add(aFrameMessage);
-	            ActorResponse response = new ActorResponse
-	            {
-		            RpcId = message.RpcId
-	            };
-	            session.Reply(response);
+	            ActorResponse response = new ActorResponse();
+	            session.Reply(rpcId, response);
 				return;
             }
-            await Game.Scene.GetComponent<ActorMessageDispatherComponent>().Handle(session, entity, message);
+            await Game.Scene.GetComponent<ActorMessageDispatherComponent>().Handle(session, entity, rpcId, message);
         }
     }
 }

+ 2 - 2
Server/Hotfix/System/ServerFrameComponentSystem.cs

@@ -41,9 +41,9 @@ namespace Hotfix
             }
         }
 
-        public static void Add(this ServerFrameComponent self, AFrameMessage message)
+        public static void Add(this ServerFrameComponent self, IFrameMessage message)
         {
-            self.FrameMessage.Messages.Add(message);
+            self.FrameMessage.Messages.Add((MessageObject)message);
         }
     }
 }

+ 8 - 9
Server/Model/Base/Message/AMActorHandler.cs

@@ -3,11 +3,11 @@ using System.Threading.Tasks;
 
 namespace Model
 {
-	public abstract class AMActorHandler<E, Message>: IMActorHandler where E: Entity where Message : AMessage
+	public abstract class AMActorHandler<E, Message>: IMActorHandler where E: Entity where Message : MessageObject
 	{
 		protected abstract Task Run(E entity, Message message);
 
-		public async Task Handle(Session session, Entity entity, ActorRequest message)
+		public async Task Handle(Session session, Entity entity, uint rpcId, ActorRequest message)
 		{
 			Message msg = message.AMessage as Message;
 			if (msg == null)
@@ -29,8 +29,8 @@ namespace Model
 			{
 				return;
 			}
-			ActorResponse response = new ActorResponse { RpcId = message.RpcId };
-			session.Reply(response);
+			ActorResponse response = new ActorResponse();
+			session.Reply(rpcId, response);
 		}
 
 		public Type GetMessageType()
@@ -39,7 +39,7 @@ namespace Model
 		}
 	}
 
-	public abstract class AMActorRpcHandler<E, Request, Response>: IMActorHandler where E: Entity where Request : AActorRequest where Response : AActorResponse
+	public abstract class AMActorRpcHandler<E, Request, Response>: IMActorHandler where E: Entity where Request : MessageObject, IActorRequest where Response : MessageObject, IActorResponse
 	{
 		protected static void ReplyError(Response response, Exception e, Action<Response> reply)
 		{
@@ -51,7 +51,7 @@ namespace Model
 
 		protected abstract Task Run(E unit, Request message, Action<Response> reply);
 
-		public async Task Handle(Session session, Entity entity, ActorRequest message)
+		public async Task Handle(Session session, Entity entity, uint rpcId, ActorRequest message)
 		{
 			try
 			{
@@ -74,12 +74,11 @@ namespace Model
 					{
 						return;
 					}
-					ActorRpcResponse actorResponse = new ActorRpcResponse
+					ActorResponse actorResponse = new ActorResponse
 					{
-						RpcId = message.RpcId,
 						AMessage = response
 					};
-					session.Reply(actorResponse);
+					session.Reply(rpcId, actorResponse);
 				});
 			}
 			catch (Exception e)

+ 3 - 4
Server/Model/Base/Message/AMRpcHandler.cs

@@ -2,7 +2,7 @@
 
 namespace Model
 {
-	public abstract class AMRpcHandler<Request, Response>: IMHandler where Request : ARequest where Response : AResponse
+	public abstract class AMRpcHandler<Request, Response>: IMHandler where Request : class, IRequest where Response : class, IResponse 
 	{
 		protected static void ReplyError(Response response, Exception e, Action<Response> reply)
 		{
@@ -14,7 +14,7 @@ namespace Model
 
 		protected abstract void Run(Session session, Request message, Action<Response> reply);
 
-		public void Handle(Session session, AMessage message)
+		public void Handle(Session session, uint rpcId, IMessage message)
 		{
 			try
 			{
@@ -30,8 +30,7 @@ namespace Model
 					{
 						return;
 					}
-					response.RpcId = request.RpcId;
-					session.Reply(response);
+					session.Reply(rpcId, response);
 				});
 			}
 			catch (Exception e)

+ 38 - 0
Server/Model/Base/Message/ActorRequestWrap.cs

@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using ProtoBuf;
+
+namespace Model
+{
+	/// <summary>
+	/// 用来包装actor消息
+	/// </summary>
+	[Message(Opcode.ActorRequest)]
+	[ProtoContract]
+	public partial class ActorRequest : IRequest
+	{
+		[ProtoMember(1, IsRequired = true)]
+		public long Id { get; set; }
+
+		[ProtoMember(2, IsRequired = true)]
+		public MessageObject AMessage { get; set; }
+	}
+
+	/// <summary>
+	/// actor RPC消息响应
+	/// </summary>
+	[Message(Opcode.ActorResponse)]
+	[ProtoContract]
+	public partial class ActorResponse : IResponse
+	{
+		[ProtoMember(1, IsRequired = true)]
+		public MessageObject AMessage;
+
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
+	}
+}

+ 1 - 1
Server/Model/Base/Message/IEntityActorHandler.cs

@@ -4,6 +4,6 @@ namespace Model
 {
 	public interface IEntityActorHandler
 	{
-		Task Handle(Session session, Entity entity, ActorRequest message);
+		Task Handle(Session session, Entity entity, uint rpcId, ActorRequest message);
 	}
 }

+ 1 - 1
Server/Model/Base/Message/IMActorHandler.cs

@@ -5,7 +5,7 @@ namespace Model
 {
 	public interface IMActorHandler
 	{
-		Task Handle(Session session, Entity entity, ActorRequest message);
+		Task Handle(Session session, Entity entity, uint rpcId, ActorRequest message);
 		Type GetMessageType();
 	}
 }

+ 1 - 1
Server/Model/Base/Message/IMHandler.cs

@@ -4,7 +4,7 @@ namespace Model
 {
 	public interface IMHandler
 	{
-		void Handle(Session session, AMessage message);
+		void Handle(Session session, uint rpcId, IMessage message);
 		Type GetMessageType();
 	}
 }

+ 129 - 125
Server/Model/Entity/Message/InnerMessage.cs

@@ -1,59 +1,16 @@
 using ProtoBuf;
 using System.Collections.Generic;
+using Model;
 using MongoDB.Bson.Serialization.Attributes;
+
 namespace Model
 {
-/// <summary>
-/// 用来包装actor消息
-/// </summary>
-	[Message(Opcode.ActorRequest)]
-	[ProtoContract]
-	public partial class ActorRequest:  ARequest
-	{
-		[ProtoMember(1, IsRequired = true)]
-		public long Id;
-
-		[ProtoMember(2, IsRequired = true)]
-		public AMessage AMessage;
-
-	}
-
-/// <summary>
-/// actor RPC消息响应
-/// </summary>
-	[Message(Opcode.ActorResponse)]
-	[ProtoContract]
-	public partial class ActorResponse:  AResponse
-	{
-	}
-
-/// <summary>
-/// 用来包装actor消息
-/// </summary>
-	[Message(Opcode.ActorRpcRequest)]
-	[ProtoContract]
-	public partial class ActorRpcRequest:  ActorRequest
-	{
-	}
-
-/// <summary>
-/// actor RPC消息响应带回应
-/// </summary>
-	[Message(Opcode.ActorRpcResponse)]
-	[ProtoContract]
-	public partial class ActorRpcResponse:  ActorResponse
-	{
-		[ProtoMember(1, IsRequired = true)]
-		public AMessage AMessage;
-
-	}
-
-/// <summary>
-/// 传送unit
-/// </summary>
+	/// <summary>
+	/// 传送unit
+	/// </summary>
 	[Message(Opcode.M2M_TrasferUnitRequest)]
 	[ProtoContract]
-	public partial class M2M_TrasferUnitRequest:  ARequest
+	public partial class M2M_TrasferUnitRequest: MessageObject, IRequest
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public Unit Unit;
@@ -62,25 +19,35 @@ namespace Model
 
 	[Message(Opcode.M2M_TrasferUnitResponse)]
 	[ProtoContract]
-	public partial class M2M_TrasferUnitResponse:  AResponse
+	public partial class M2M_TrasferUnitResponse: MessageObject, IResponse
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
 	}
 
 	[Message(Opcode.M2A_Reload)]
 	[ProtoContract]
-	public partial class M2A_Reload:  ARequest
+	public partial class M2A_Reload: MessageObject, IRequest
 	{
 	}
 
 	[Message(Opcode.A2M_Reload)]
 	[ProtoContract]
-	public partial class A2M_Reload:  AResponse
+	public partial class A2M_Reload: MessageObject, IResponse
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
 	}
 
 	[Message(Opcode.G2G_LockRequest)]
 	[ProtoContract]
-	public partial class G2G_LockRequest:  ARequest
+	public partial class G2G_LockRequest: MessageObject, IRequest
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public long Id;
@@ -92,13 +59,18 @@ namespace Model
 
 	[Message(Opcode.G2G_LockResponse)]
 	[ProtoContract]
-	public partial class G2G_LockResponse:  AResponse
+	public partial class G2G_LockResponse: MessageObject, IResponse
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
 	}
 
 	[Message(Opcode.G2G_LockReleaseRequest)]
 	[ProtoContract]
-	public partial class G2G_LockReleaseRequest:  ARequest
+	public partial class G2G_LockReleaseRequest: MessageObject, IRequest
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public long Id;
@@ -110,13 +82,18 @@ namespace Model
 
 	[Message(Opcode.G2G_LockReleaseResponse)]
 	[ProtoContract]
-	public partial class G2G_LockReleaseResponse:  AResponse
+	public partial class G2G_LockReleaseResponse: MessageObject, IResponse
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
 	}
 
 	[Message(Opcode.DBSaveRequest)]
 	[ProtoContract]
-	public partial class DBSaveRequest:  ARequest
+	public partial class DBSaveRequest: MessageObject, IRequest
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public bool NeedCache;
@@ -131,13 +108,18 @@ namespace Model
 
 	[Message(Opcode.DBSaveBatchResponse)]
 	[ProtoContract]
-	public partial class DBSaveBatchResponse:  AResponse
+	public partial class DBSaveBatchResponse: MessageObject, IResponse
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
 	}
 
 	[Message(Opcode.DBSaveBatchRequest)]
 	[ProtoContract]
-	public partial class DBSaveBatchRequest:  ARequest
+	public partial class DBSaveBatchRequest: MessageObject, IRequest
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public bool NeedCache;
@@ -152,13 +134,18 @@ namespace Model
 
 	[Message(Opcode.DBSaveResponse)]
 	[ProtoContract]
-	public partial class DBSaveResponse:  AResponse
+	public partial class DBSaveResponse: MessageObject, IResponse
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
 	}
 
 	[Message(Opcode.DBQueryRequest)]
 	[ProtoContract]
-	public partial class DBQueryRequest:  ARequest
+	public partial class DBQueryRequest: MessageObject, IRequest
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public long Id;
@@ -173,16 +160,21 @@ namespace Model
 
 	[Message(Opcode.DBQueryResponse)]
 	[ProtoContract]
-	public partial class DBQueryResponse:  AResponse
+	public partial class DBQueryResponse: MessageObject, IResponse
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public Disposer Disposer;
 
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
 	}
 
 	[Message(Opcode.DBQueryBatchRequest)]
 	[ProtoContract]
-	public partial class DBQueryBatchRequest:  ARequest
+	public partial class DBQueryBatchRequest: MessageObject, IRequest
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public string CollectionName;
@@ -197,16 +189,21 @@ namespace Model
 
 	[Message(Opcode.DBQueryBatchResponse)]
 	[ProtoContract]
-	public partial class DBQueryBatchResponse:  AResponse
+	public partial class DBQueryBatchResponse: MessageObject, IResponse
 	{
 		[ProtoMember(1)]
 		public List<Disposer> Disposers = new List<Disposer>();
 
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
 	}
 
 	[Message(Opcode.DBQueryJsonRequest)]
 	[ProtoContract]
-	public partial class DBQueryJsonRequest:  ARequest
+	public partial class DBQueryJsonRequest: MessageObject, IRequest
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public string CollectionName;
@@ -221,16 +218,21 @@ namespace Model
 
 	[Message(Opcode.DBQueryJsonResponse)]
 	[ProtoContract]
-	public partial class DBQueryJsonResponse:  AResponse
+	public partial class DBQueryJsonResponse: MessageObject, IResponse
 	{
 		[ProtoMember(1)]
 		public List<Disposer> Disposers = new List<Disposer>();
 
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
 	}
 
 	[Message(Opcode.ObjectAddRequest)]
 	[ProtoContract]
-	public partial class ObjectAddRequest:  ARequest
+	public partial class ObjectAddRequest: MessageObject, IRequest
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public long Key;
@@ -242,13 +244,18 @@ namespace Model
 
 	[Message(Opcode.ObjectAddResponse)]
 	[ProtoContract]
-	public partial class ObjectAddResponse:  AResponse
+	public partial class ObjectAddResponse: MessageObject, IResponse
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
 	}
 
 	[Message(Opcode.ObjectRemoveRequest)]
 	[ProtoContract]
-	public partial class ObjectRemoveRequest:  ARequest
+	public partial class ObjectRemoveRequest: MessageObject, IRequest
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public long Key;
@@ -257,13 +264,18 @@ namespace Model
 
 	[Message(Opcode.ObjectRemoveResponse)]
 	[ProtoContract]
-	public partial class ObjectRemoveResponse:  AResponse
+	public partial class ObjectRemoveResponse: MessageObject, IResponse
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
 	}
 
 	[Message(Opcode.ObjectLockRequest)]
 	[ProtoContract]
-	public partial class ObjectLockRequest:  ARequest
+	public partial class ObjectLockRequest: MessageObject, IRequest
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public long Key;
@@ -278,13 +290,18 @@ namespace Model
 
 	[Message(Opcode.ObjectLockResponse)]
 	[ProtoContract]
-	public partial class ObjectLockResponse:  AResponse
+	public partial class ObjectLockResponse: MessageObject, IResponse
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
 	}
 
 	[Message(Opcode.ObjectUnLockRequest)]
 	[ProtoContract]
-	public partial class ObjectUnLockRequest:  ARequest
+	public partial class ObjectUnLockRequest: MessageObject, IRequest
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public long Key;
@@ -299,31 +316,46 @@ namespace Model
 
 	[Message(Opcode.ObjectUnLockResponse)]
 	[ProtoContract]
-	public partial class ObjectUnLockResponse:  AResponse
+	public partial class ObjectUnLockResponse: MessageObject, IResponse
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
 	}
 
 	[Message(Opcode.ObjectGetRequest)]
 	[ProtoContract]
-	public partial class ObjectGetRequest:  ARequest
+	public partial class ObjectGetRequest: MessageObject, IRequest
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public long Key;
 
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
 	}
 
 	[Message(Opcode.ObjectGetResponse)]
 	[ProtoContract]
-	public partial class ObjectGetResponse:  AResponse
+	public partial class ObjectGetResponse: MessageObject, IResponse
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public int AppId;
 
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
 	}
 
 	[Message(Opcode.R2G_GetLoginKey)]
 	[ProtoContract]
-	public partial class R2G_GetLoginKey:  ARequest
+	public partial class R2G_GetLoginKey: MessageObject, IRequest
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public string Account;
@@ -332,16 +364,21 @@ namespace Model
 
 	[Message(Opcode.G2R_GetLoginKey)]
 	[ProtoContract]
-	public partial class G2R_GetLoginKey:  AResponse
+	public partial class G2R_GetLoginKey: MessageObject, IResponse
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public long Key;
 
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
 	}
 
 	[Message(Opcode.G2M_CreateUnit)]
 	[ProtoContract]
-	public partial class G2M_CreateUnit:  ARequest
+	public partial class G2M_CreateUnit: MessageObject, IRequest
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public long PlayerId;
@@ -353,7 +390,7 @@ namespace Model
 
 	[Message(Opcode.M2G_CreateUnit)]
 	[ProtoContract]
-	public partial class M2G_CreateUnit:  AResponse
+	public partial class M2G_CreateUnit: MessageObject, IResponse
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public long UnitId;
@@ -361,50 +398,17 @@ namespace Model
 		[ProtoMember(2, IsRequired = true)]
 		public int Count;
 
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
 	}
 
-	[BsonKnownTypes(typeof(ActorRpcRequest))]
-	public partial class  ActorRequest {}
-
-	[BsonKnownTypes(typeof(ActorRpcResponse))]
-	public partial class  ActorResponse {}
-
-	[BsonKnownTypes(typeof(ActorRequest))]
-	[BsonKnownTypes(typeof(M2M_TrasferUnitRequest))]
-	[BsonKnownTypes(typeof(M2A_Reload))]
-	[BsonKnownTypes(typeof(G2G_LockRequest))]
-	[BsonKnownTypes(typeof(G2G_LockReleaseRequest))]
-	[BsonKnownTypes(typeof(DBSaveRequest))]
-	[BsonKnownTypes(typeof(DBSaveBatchRequest))]
-	[BsonKnownTypes(typeof(DBQueryRequest))]
-	[BsonKnownTypes(typeof(DBQueryBatchRequest))]
-	[BsonKnownTypes(typeof(DBQueryJsonRequest))]
-	[BsonKnownTypes(typeof(ObjectAddRequest))]
-	[BsonKnownTypes(typeof(ObjectRemoveRequest))]
-	[BsonKnownTypes(typeof(ObjectLockRequest))]
-	[BsonKnownTypes(typeof(ObjectUnLockRequest))]
-	[BsonKnownTypes(typeof(ObjectGetRequest))]
-	[BsonKnownTypes(typeof(R2G_GetLoginKey))]
-	[BsonKnownTypes(typeof(G2M_CreateUnit))]
-	public partial class  ARequest {}
-
-	[BsonKnownTypes(typeof(ActorResponse))]
-	[BsonKnownTypes(typeof(M2M_TrasferUnitResponse))]
-	[BsonKnownTypes(typeof(A2M_Reload))]
-	[BsonKnownTypes(typeof(G2G_LockResponse))]
-	[BsonKnownTypes(typeof(G2G_LockReleaseResponse))]
-	[BsonKnownTypes(typeof(DBSaveBatchResponse))]
-	[BsonKnownTypes(typeof(DBSaveResponse))]
-	[BsonKnownTypes(typeof(DBQueryResponse))]
-	[BsonKnownTypes(typeof(DBQueryBatchResponse))]
-	[BsonKnownTypes(typeof(DBQueryJsonResponse))]
-	[BsonKnownTypes(typeof(ObjectAddResponse))]
-	[BsonKnownTypes(typeof(ObjectRemoveResponse))]
-	[BsonKnownTypes(typeof(ObjectLockResponse))]
-	[BsonKnownTypes(typeof(ObjectUnLockResponse))]
-	[BsonKnownTypes(typeof(ObjectGetResponse))]
-	[BsonKnownTypes(typeof(G2R_GetLoginKey))]
-	[BsonKnownTypes(typeof(M2G_CreateUnit))]
-	public partial class  AResponse {}
-
-}
+	[BsonKnownTypes(typeof(FrameMessage))]
+	[BsonKnownTypes(typeof(Actor_CreateUnits))]
+	[BsonKnownTypes(typeof(Actor_TransferRequest))]
+	public partial class MessageObject
+	{
+	}
+}

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

@@ -7,6 +7,7 @@ namespace Model
 	public class ActorMessageInfo
 	{
 		public Session Session;
+		public uint RpcId;
 		public ActorRequest Message;
 	}
 

+ 2 - 2
Server/Model/Module/Actor/ActorMessageDispatherComponent.cs

@@ -71,14 +71,14 @@ namespace Model
 			return actorHandler;
 		}
 
-		public async Task Handle(Session session, Entity entity, ActorRequest message)
+		public async Task Handle(Session session, Entity entity, uint rpcId, ActorRequest message)
 		{
 			if (!this.handlers.TryGetValue(message.AMessage.GetType(), out IMActorHandler handler))
 			{
 				throw new Exception($"not found message handler: {MongoHelper.ToJson(message)}");
 			}
 			
-			await handler.Handle(session, entity, message);
+			await handler.Handle(session, entity, rpcId, message);
 		}
 
 		public override void Dispose()

+ 20 - 21
Server/Model/Module/Actor/ActorProxy.cs

@@ -13,9 +13,9 @@ namespace Model
 		public ActorProxy proxy;
 
 		[BsonElement]
-		public AMessage message;
+		public MessageObject message;
 
-		public abstract Task<AResponse> Run();
+		public abstract Task<IResponse> Run();
 
 		public abstract void RunFail(int error);
 	}
@@ -25,16 +25,16 @@ namespace Model
 	/// </summary>
 	public class ActorMessageTask: ActorTask
 	{
-		public ActorMessageTask(ActorProxy proxy, AMessage message)
+		public ActorMessageTask(ActorProxy proxy, IMessage message)
 		{
 			this.proxy = proxy;
-			this.message = message;
+			this.message = (MessageObject)message;
 		}
 
-		public override async Task<AResponse> Run()
+		public override async Task<IResponse> Run()
 		{
 			ActorRequest request = new ActorRequest() { Id = this.proxy.Id, AMessage = this.message };
-			ActorResponse response = await this.proxy.RealCall<ActorResponse>(request, this.proxy.CancellationTokenSource.Token);
+			ActorResponse response = (ActorResponse)await this.proxy.RealCall(request, this.proxy.CancellationTokenSource.Token);
 			return response;
 		}
 
@@ -46,25 +46,24 @@ namespace Model
 	/// <summary>
 	/// Rpc消息,需要等待返回
 	/// </summary>
-	/// <typeparam name="Response"></typeparam>
-	public class ActorRpcTask<Response> : ActorTask where Response: AResponse
+	public class ActorRpcTask : ActorTask
 	{
 		[BsonIgnore]
-		public readonly TaskCompletionSource<Response> Tcs = new TaskCompletionSource<Response>();
+		public readonly TaskCompletionSource<IResponse> Tcs = new TaskCompletionSource<IResponse>();
 
-		public ActorRpcTask(ActorProxy proxy, ARequest message)
+		public ActorRpcTask(ActorProxy proxy, IMessage message)
 		{
 			this.proxy = proxy;
-			this.message = message;
+			this.message = (MessageObject)message;
 		}
 
-		public override async Task<AResponse> Run()
+		public override async Task<IResponse> Run()
 		{
-			ActorRpcRequest request = new ActorRpcRequest() { Id = this.proxy.Id, AMessage = this.message };
-			ActorRpcResponse response = await this.proxy.RealCall<ActorRpcResponse>(request, this.proxy.CancellationTokenSource.Token);
+			ActorRequest request = new ActorRequest() { Id = this.proxy.Id, AMessage = this.message };
+			ActorResponse response = (ActorResponse)await this.proxy.RealCall(request, this.proxy.CancellationTokenSource.Token);
 			if (response.Error != ErrorCode.ERR_NotFoundActor)
 			{
-				this.Tcs.SetResult((Response)response.AMessage);
+				this.Tcs.SetResult((IResponse)response.AMessage);
 			}
 			return response;
 		}
@@ -229,7 +228,7 @@ namespace Model
 		{
 			try
 			{
-				AResponse response = await task.Run();
+				IResponse response = await task.Run();
 
 				// 如果没找到Actor,发送窗口减少为1,重试
 				if (response.Error == ErrorCode.ERR_NotFoundActor)
@@ -282,27 +281,27 @@ namespace Model
 			}
 		}
 
-		public void Send(AMessage message)
+		public void Send(IMessage message)
 		{
 			ActorMessageTask task = new ActorMessageTask(this, message);
 			this.Add(task);
 		}
 
-		public Task<Response> Call<Response>(ARequest request)where Response : AResponse
+		public Task<IResponse> Call(IRequest request)
 		{
-			ActorRpcTask<Response> task = new ActorRpcTask<Response>(this, request);
+			ActorRpcTask task = new ActorRpcTask(this, (IMessage)request);
 			this.Add(task);
 			return task.Tcs.Task;
 		}
 
-		public async Task<Response> RealCall<Response>(ActorRequest request, CancellationToken cancellationToken) where Response: AResponse
+		public async Task<IResponse> RealCall(ActorRequest request, CancellationToken cancellationToken)
 		{
 			try
 			{
 				//Log.Debug($"realcall {MongoHelper.ToJson(request)} {this.Address}");
 				request.Id = this.Id;
 				Session session = Game.Scene.GetComponent<NetInnerComponent>().Get(this.Address);
-				Response response = (Response)await session.Call(request, cancellationToken);
+				IResponse response = await session.Call(request, cancellationToken);
 				return response;
 			}
 			catch (RpcException e)

+ 2 - 2
Server/Model/Module/Network/AMHandler.cs

@@ -2,11 +2,11 @@
 
 namespace Model
 {
-	public abstract class AMHandler<Message> : IMHandler where Message : AMessage
+	public abstract class AMHandler<Message> : IMHandler where Message : MessageObject
 	{
 		protected abstract void Run(Session session, Message message);
 
-		public void Handle(Session session, AMessage msg)
+		public void Handle(Session session, uint rpcId, IMessage msg)
 		{
 			Message message = msg as Message;
 			if (message == null)

+ 3 - 3
Server/Model/Module/Network/MessageDispatherComponent.cs

@@ -49,7 +49,7 @@ namespace Model
 				{
 					continue;
 				}
-
+				
 				object obj = Activator.CreateInstance(type);
 
 				IMHandler imHandler = obj as IMHandler;
@@ -68,7 +68,7 @@ namespace Model
 			}
 		}
 
-		public void Handle(Session session, AMessage message)
+		public void Handle(Session session, uint rpcId, IMessage message)
 		{
 			if (!this.handlers.TryGetValue(message.GetType(), out List<IMHandler> actions))
 			{
@@ -80,7 +80,7 @@ namespace Model
 			{
 				try
 				{
-					ev.Handle(session, message);
+					ev.Handle(session, rpcId, message);
 				}
 				catch (Exception e)
 				{

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

@@ -37,9 +37,9 @@
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Helper\TimeHelper.cs" Link="Base\Helper\TimeHelper.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Helper\ZipHelper.cs" Link="Base\Helper\ZipHelper.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Message\AActorMessage.cs" Link="Base\Message\AActorMessage.cs" />
-    <Compile Include="..\..\Unity\Assets\Scripts\Base\Message\AMessage.cs" Link="Base\Message\AMessage.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Message\AppType.cs" Link="Other\AppType.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Message\ErrorCode.cs" Link="Base\Message\ErrorCode.cs" />
+    <Compile Include="..\..\Unity\Assets\Scripts\Base\Message\IMessage.cs" Link="Base\Message\IMessage.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Message\IMessageDispatcher.cs" Link="Module\Network\IMessageDispatcher.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Message\IMessagePacker.cs" Link="Module\Network\IMessagePacker.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Message\MessageInfo.cs" Link="Base\Message\MessageInfo.cs" />
@@ -85,6 +85,7 @@
     <Compile Include="..\..\Unity\Assets\Scripts\Entity\Message\Opcode.cs" Link="Entity\Message\Opcode.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Entity\Message\OuterMessage.cs" Link="Entity\Message\OuterMessage.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Entity\Session.cs" Link="Module\Network\Session.cs" />
+    <Compile Include="..\..\Unity\Assets\Scripts\Helper\SessionHelper.cs" Link="Base\Helper\SessionHelper.cs" />
   </ItemGroup>
 
   <ItemGroup>

+ 5 - 8
Unity/Assets/Scripts/Base/Message/AActorMessage.cs

@@ -4,26 +4,23 @@ using ProtoBuf;
 // 不要在这个文件加[ProtoInclude]跟[BsonKnowType]标签,加到InnerMessage.cs或者OuterMessage.cs里面去
 namespace Model
 {
-	[ProtoContract]
-	[BsonKnownTypes(typeof(AFrameMessage))]
-	public abstract partial class AActorMessage : AMessage
+	public interface IActorMessage: IMessage
 	{
 	}
 
 	[ProtoContract]
-	public abstract partial class AActorRequest : ARequest
+	public interface IActorRequest : IRequest
 	{
 	}
 
 	[ProtoContract]
-	public abstract partial class AActorResponse : AResponse
+	public interface IActorResponse : IResponse
 	{
 	}
 
 	[ProtoContract]
-	public abstract partial class AFrameMessage : AActorMessage
+	public interface IFrameMessage : IActorMessage
 	{
-		[ProtoMember(90)]
-		public long Id;
+		long Id { get; set; }
 	}
 }

+ 2 - 2
Unity/Assets/Scripts/Base/Message/AMHandler.cs

@@ -2,11 +2,11 @@
 
 namespace Model
 {
-	public abstract class AMHandler<Message> : IMHandler where Message : AMessage
+	public abstract class AMHandler<Message> : IMHandler where Message : MessageObject
 	{
 		protected abstract void Run(Session session, Message message);
 
-		public void Handle(Session session, AMessage msg)
+		public void Handle(Session session, IMessage msg)
 		{
 			Message message = msg as Message;
 			if (message == null)

+ 30 - 34
Unity/Assets/Scripts/Base/Message/AMessage.cs

@@ -4,53 +4,49 @@ using ProtoBuf;
 // 不要在这个文件加[ProtoInclude]跟[BsonKnowType]标签,加到InnerMessage.cs或者OuterMessage.cs里面去
 namespace Model
 {
-	[ProtoContract]
-	[ProtoInclude(Opcode.AActorMessage, typeof(AActorMessage))]
-	[ProtoInclude(Opcode.ARequest, typeof(ARequest))]
-	[ProtoInclude(Opcode.AResponse, typeof(AResponse))]
-	[BsonKnownTypes(typeof(AActorMessage))]
-	[BsonKnownTypes(typeof(ARequest))]
-	[BsonKnownTypes(typeof(AResponse))]
-	public abstract partial class AMessage
+	public struct PacketInfo
 	{
-		public override string ToString()
-		{
-			return MongoHelper.ToJson(this);
-		}
+		public Header Header;
+	
+		public byte[] Bytes;
+		public ushort Index;
+		public ushort Length;
 	}
 
+	[BsonIgnoreExtraElements]
 	[ProtoContract]
-	[ProtoInclude(Opcode.AActorRequest, typeof(AActorRequest))]
-	[BsonKnownTypes(typeof(AActorRequest))]
-	public abstract partial class ARequest : AMessage
+	public class Header
 	{
+		[BsonElement("a")]
 		[ProtoMember(1)]
-		[BsonIgnoreIfDefault]
-		public uint RpcId;
-	}
-
-	/// <summary>
-	/// 服务端回的RPC消息需要继承这个抽象类
-	/// </summary>
-	[ProtoContract]
-	[ProtoInclude(Opcode.AActorResponse, typeof(AActorResponse))]
-	[BsonKnownTypes(typeof(AActorResponse))]
-	[BsonKnownTypes(typeof(ErrorResponse))]
-	public abstract partial class AResponse : AMessage
-	{
-		[ProtoMember(1)]
-		public uint RpcId;
+		public byte Flag;
 
+		[BsonElement("b")]
 		[ProtoMember(2)]
-		public int Error = 0;
+		public ushort Opcode;
 
+		[BsonElement("c")]
+		[BsonIgnoreIfDefault]
 		[ProtoMember(3)]
-		public string Message = "";
+		public uint RpcId;
 	}
 
 	[ProtoContract]
-	public class ErrorResponse: AResponse
+	public partial class MessageObject
+	{
+	}
+	
+	public interface AMessage
+	{
+	}
+	
+	public interface ARequest: AMessage
+	{
+	}
+	
+	public interface AResponse: AMessage
 	{
-		
+		int Error { get; set; }
+		string Message { get; set; }
 	}
 }

+ 6 - 3
Unity/Assets/Scripts/Base/Message/ClientDispatcher.cs

@@ -4,8 +4,11 @@ namespace Model
 {
 	public class ClientDispatcher: IMessageDispatcher
 	{
-		public void Dispatch(Session session, ushort opcode, int offset, byte[] messageBytes, AMessage message)
+		public void Dispatch(Session session, PacketInfo packetInfo)
 		{
+			Type messageType = Game.Scene.GetComponent<OpcodeTypeComponent>().GetType(packetInfo.Header.Opcode);
+			IMessage message = (IMessage)session.network.MessagePacker.DeserializeFrom(messageType, packetInfo.Bytes, packetInfo.Index, packetInfo.Length);
+
 			// 如果是帧同步消息,交给ClientFrameComponent处理
 			FrameMessage frameMessage = message as FrameMessage;
 			if (frameMessage != null)
@@ -15,9 +18,9 @@ namespace Model
 			}
 
 			// 普通消息或者是Rpc请求消息
-			if (message is AMessage || message is ARequest)
+			if (message is IMessage || message is IRequest)
 			{
-				MessageInfo messageInfo = new MessageInfo(opcode, message);
+				MessageInfo messageInfo = new MessageInfo(packetInfo.Header.Opcode, message);
 				Game.Scene.GetComponent<MessageDispatherComponent>().Handle(session, messageInfo);
 				return;
 			}

+ 1 - 1
Unity/Assets/Scripts/Base/Message/IMHandler.cs

@@ -4,7 +4,7 @@ namespace Model
 {
 	public interface IMHandler
 	{
-		void Handle(Session session, AMessage message);
+		void Handle(Session session, IMessage message);
 		Type GetMessageType();
 	}
 }

+ 52 - 0
Unity/Assets/Scripts/Base/Message/IMessage.cs

@@ -0,0 +1,52 @@
+using MongoDB.Bson.Serialization.Attributes;
+using ProtoBuf;
+
+// 不要在这个文件加[ProtoInclude]跟[BsonKnowType]标签,加到InnerMessage.cs或者OuterMessage.cs里面去
+namespace Model
+{
+	public struct PacketInfo
+	{
+		public Header Header;
+	
+		public byte[] Bytes;
+		public ushort Index;
+		public ushort Length;
+	}
+
+	[BsonIgnoreExtraElements]
+	[ProtoContract]
+	public class Header
+	{
+		[BsonElement("a")]
+		[ProtoMember(1)]
+		public byte Flag;
+
+		[BsonElement("b")]
+		[ProtoMember(2)]
+		public ushort Opcode;
+
+		[BsonElement("c")]
+		[BsonIgnoreIfDefault]
+		[ProtoMember(3)]
+		public uint RpcId;
+	}
+
+	[ProtoContract]
+	public partial class MessageObject
+	{
+	}
+	
+	public interface IMessage
+	{
+	}
+	
+	public interface IRequest: IMessage
+	{
+	}
+	
+	public interface IResponse: IMessage
+	{
+		int Error { get; set; }
+		string Message { get; set; }
+	}
+}

+ 0 - 0
Unity/Assets/Scripts/Base/Message/AMessage.cs.meta → Unity/Assets/Scripts/Base/Message/IMessage.cs.meta


+ 1 - 1
Unity/Assets/Scripts/Base/Message/IMessageDispatcher.cs

@@ -2,6 +2,6 @@
 {
 	public interface IMessageDispatcher
 	{
-		void Dispatch(Session session, ushort opcode, int offset, byte[] messageBytes, AMessage message);
+		void Dispatch(Session session, PacketInfo packetInfo);
 	}
 }

+ 2 - 2
Unity/Assets/Scripts/Base/Message/MessageInfo.cs

@@ -3,9 +3,9 @@
 	public struct MessageInfo
 	{
 		public ushort Opcode { get; set; }
-		public AMessage Message { get; set; }
+		public IMessage Message { get; set; }
 
-		public MessageInfo(ushort opcode, AMessage message)
+		public MessageInfo(ushort opcode, IMessage message)
 		{
 			this.Opcode = opcode;
 			this.Message = message;

+ 2 - 5
Unity/Assets/Scripts/Base/Message/Opcode.cs

@@ -2,10 +2,7 @@ namespace Model
 {
 	public static partial class Opcode
 	{
-		public const ushort ARequest = 1;
-		public const ushort AResponse = 2;
-		public const ushort AActorMessage = 3;
-		public const ushort AActorRequest = 4;
-		public const ushort AActorResponse = 5;
+		public const ushort ActorRequest = 1;
+		public const ushort ActorResponse = 2;
 	}
 }

+ 9 - 4
Unity/Assets/Scripts/Base/Network/TNet/PacketParser.cs

@@ -7,11 +7,16 @@ namespace Model
 		PacketSize,
 		PacketBody
 	}
-
+	
 	public struct Packet
 	{
-		public byte[] Bytes { get; set; }
-		public int Length { get; set; }
+		public const int MinSize = 2;
+
+		/// <summary>
+		/// 只读,不允许修改
+		/// </summary>
+		public byte[] Bytes { get; }
+		public ushort Length { get; set; }
 
 		public Packet(int length)
 		{
@@ -22,7 +27,7 @@ namespace Model
 		public Packet(byte[] bytes)
 		{
 			this.Bytes = bytes;
-			this.Length = bytes.Length;
+			this.Length = (ushort)bytes.Length;
 		}
 	}
 

+ 2 - 2
Unity/Assets/Scripts/Component/ClientFrameComponent.cs

@@ -78,9 +78,9 @@ namespace Model
 
             for (int i = 0; i < sessionFrameMessage.FrameMessage.Messages.Count; ++i)
             {
-	            AFrameMessage message = sessionFrameMessage.FrameMessage.Messages[i];
+	            IFrameMessage message = (IFrameMessage)sessionFrameMessage.FrameMessage.Messages[i];
 	            ushort opcode = Game.Scene.GetComponent<OpcodeTypeComponent>().GetOpcode(message.GetType());
-                Game.Scene.GetComponent<MessageDispatherComponent>().Handle(sessionFrameMessage.Session, new MessageInfo() { Opcode= opcode, Message = message });
+                Game.Scene.GetComponent<MessageDispatherComponent>().Handle(sessionFrameMessage.Session, new MessageInfo() { Opcode= opcode, Message = (IMessage)message });
             }
         }
     }

+ 3 - 3
Unity/Assets/Scripts/Component/MessageDispatherComponent.cs

@@ -11,7 +11,7 @@ namespace Model
 	/// </summary>
 	public interface IMessageMethod
 	{
-		void Run(Session session, AMessage a);
+		void Run(Session session, IMessage a);
 	}
 
 	public class IMessageMonoMethod : IMessageMethod
@@ -23,7 +23,7 @@ namespace Model
 			this.iMHandler = iMHandler;
 		}
 
-		public void Run(Session session, AMessage a)
+		public void Run(Session session, IMessage a)
 		{
 			this.iMHandler.Handle(session, a);
 		}
@@ -45,7 +45,7 @@ namespace Model
 			this.param = new object[n];
 		}
 
-		public void Run(Session session, AMessage a)
+		public void Run(Session session, IMessage a)
 		{
 			this.param[0] = a;
 			this.appDomain.Invoke(this.method, this.instance, param);

+ 0 - 4
Unity/Assets/Scripts/Entity/Message/Opcode.cs

@@ -22,10 +22,6 @@ namespace Model
 		 public const ushort M2C_Reload = 118;
 		 public const ushort C2R_Ping = 119;
 		 public const ushort R2C_Ping = 120;
-		 public const ushort ActorRequest = 1001;
-		 public const ushort ActorResponse = 1002;
-		 public const ushort ActorRpcRequest = 1003;
-		 public const ushort ActorRpcResponse = 1004;
 		 public const ushort M2M_TrasferUnitRequest = 1005;
 		 public const ushort M2M_TrasferUnitResponse = 1006;
 		 public const ushort M2A_Reload = 1007;

+ 69 - 71
Unity/Assets/Scripts/Entity/Message/OuterMessage.cs

@@ -1,23 +1,23 @@
 using ProtoBuf;
 using System.Collections.Generic;
+using Model;
 using MongoDB.Bson.Serialization.Attributes;
 namespace Model
 {
 	[Message(Opcode.C2R_Login)]
 	[ProtoContract]
-	public partial class C2R_Login:  ARequest
+	public partial class C2R_Login: MessageObject, IRequest
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public string Account;
 
 		[ProtoMember(2, IsRequired = true)]
 		public string Password;
-
 	}
 
 	[Message(Opcode.R2C_Login)]
 	[ProtoContract]
-	public partial class R2C_Login:  AResponse
+	public partial class R2C_Login : MessageObject, IResponse
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public string Address;
@@ -25,11 +25,16 @@ namespace Model
 		[ProtoMember(2, IsRequired = true)]
 		public long Key;
 
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
 	}
 
 	[Message(Opcode.C2G_LoginGate)]
 	[ProtoContract]
-	public partial class C2G_LoginGate:  ARequest
+	public partial class C2G_LoginGate : MessageObject, IRequest
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public long Key;
@@ -38,43 +43,57 @@ namespace Model
 
 	[Message(Opcode.G2C_LoginGate)]
 	[ProtoContract]
-	public partial class G2C_LoginGate:  AResponse
+	public partial class G2C_LoginGate : MessageObject, IResponse
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public long PlayerId;
 
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
 	}
 
 	[Message(Opcode.Actor_Test)]
 	[ProtoContract]
-	public partial class Actor_Test:  AActorMessage
+	public partial class Actor_Test : MessageObject, IActorMessage
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public string Info;
 
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
 	}
 
 	[Message(Opcode.Actor_TestRequest)]
 	[ProtoContract]
-	public partial class Actor_TestRequest:  AActorRequest
+	public partial class Actor_TestRequest : MessageObject, IActorRequest
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public string request;
-
 	}
 
 	[Message(Opcode.Actor_TestResponse)]
 	[ProtoContract]
-	public partial class Actor_TestResponse:  AActorResponse
+	public partial class Actor_TestResponse : MessageObject, IActorResponse
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public string response;
 
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
 	}
 
 	[Message(Opcode.Actor_TransferRequest)]
 	[ProtoContract]
-	public partial class Actor_TransferRequest:  AActorRequest
+	public partial class Actor_TransferRequest : MessageObject, IActorRequest
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public int MapIndex;
@@ -83,19 +102,24 @@ namespace Model
 
 	[Message(Opcode.Actor_TransferResponse)]
 	[ProtoContract]
-	public partial class Actor_TransferResponse:  AActorResponse
+	public partial class Actor_TransferResponse : MessageObject, IActorResponse
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
 	}
 
 	[Message(Opcode.C2G_EnterMap)]
 	[ProtoContract]
-	public partial class C2G_EnterMap:  ARequest
+	public partial class C2G_EnterMap : MessageObject, IRequest
 	{
 	}
 
 	[Message(Opcode.G2C_EnterMap)]
 	[ProtoContract]
-	public partial class G2C_EnterMap:  AResponse
+	public partial class G2C_EnterMap : MessageObject, IResponse
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public long UnitId;
@@ -103,6 +127,11 @@ namespace Model
 		[ProtoMember(2, IsRequired = true)]
 		public int Count;
 
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
 	}
 
 	[Message(Opcode.UnitInfo)]
@@ -122,7 +151,7 @@ namespace Model
 
 	[Message(Opcode.Actor_CreateUnits)]
 	[ProtoContract]
-	public partial class Actor_CreateUnits:  AActorMessage
+	public partial class Actor_CreateUnits : MessageObject, IActorMessage
 	{
 		[ProtoMember(1)]
 		public List<UnitInfo> Units = new List<UnitInfo>();
@@ -137,25 +166,25 @@ namespace Model
 		public long Id;
 
 		[ProtoMember(2, IsRequired = true)]
-		public AMessage Message;
+		public IMessage Message;
 
 	}
 
 	[Message(Opcode.FrameMessage)]
 	[ProtoContract]
-	public partial class FrameMessage:  AActorMessage
+	public partial class FrameMessage : MessageObject, IActorMessage
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public int Frame;
 
 		[ProtoMember(2)]
-		public List<AFrameMessage> Messages = new List<AFrameMessage>();
+		public List<MessageObject> Messages = new List<MessageObject>();
 
 	}
 
 	[Message(Opcode.Frame_ClickMap)]
 	[ProtoContract]
-	public partial class Frame_ClickMap:  AFrameMessage
+	public partial class Frame_ClickMap : MessageObject, IFrameMessage
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public int X;
@@ -163,11 +192,13 @@ namespace Model
 		[ProtoMember(2, IsRequired = true)]
 		public int Z;
 
+		[ProtoMember(90)]
+		public long Id { get; set; }
 	}
 
 	[Message(Opcode.C2M_Reload)]
 	[ProtoContract]
-	public partial class C2M_Reload:  ARequest
+	public partial class C2M_Reload : MessageObject, IRequest
 	{
 		[ProtoMember(1, IsRequired = true)]
 		public AppType AppType;
@@ -176,68 +207,35 @@ namespace Model
 
 	[Message(Opcode.M2C_Reload)]
 	[ProtoContract]
-	public partial class M2C_Reload:  AResponse
+	public partial class M2C_Reload : MessageObject, IResponse
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
 	}
 
 	[Message(Opcode.C2R_Ping)]
 	[ProtoContract]
-	public partial class C2R_Ping:  ARequest
+	public partial class C2R_Ping : MessageObject, IRequest
 	{
 	}
 
 	[Message(Opcode.R2C_Ping)]
 	[ProtoContract]
-	public partial class R2C_Ping:  AResponse
+	public partial class R2C_Ping : MessageObject, IResponse
 	{
-	}
-
-	[ProtoInclude((int)Opcode.Actor_Test, typeof(Actor_Test))]
-	[ProtoInclude((int)Opcode.Actor_CreateUnits, typeof(Actor_CreateUnits))]
-	[ProtoInclude((int)Opcode.FrameMessage, typeof(FrameMessage))]
-	[BsonKnownTypes(typeof(Actor_Test))]
-	[BsonKnownTypes(typeof(Actor_CreateUnits))]
-	[BsonKnownTypes(typeof(FrameMessage))]
-	public partial class  AActorMessage {}
-
-	[ProtoInclude((int)Opcode.Actor_TestRequest, typeof(Actor_TestRequest))]
-	[ProtoInclude((int)Opcode.Actor_TransferRequest, typeof(Actor_TransferRequest))]
-	[BsonKnownTypes(typeof(Actor_TestRequest))]
-	[BsonKnownTypes(typeof(Actor_TransferRequest))]
-	public partial class  AActorRequest {}
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
 
-	[ProtoInclude((int)Opcode.Actor_TestResponse, typeof(Actor_TestResponse))]
-	[ProtoInclude((int)Opcode.Actor_TransferResponse, typeof(Actor_TransferResponse))]
-	[BsonKnownTypes(typeof(Actor_TestResponse))]
-	[BsonKnownTypes(typeof(Actor_TransferResponse))]
-	public partial class  AActorResponse {}
-
-	[ProtoInclude((int)Opcode.Frame_ClickMap, typeof(Frame_ClickMap))]
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
+	}
+	
+	[ProtoInclude(Opcode.Frame_ClickMap, typeof(Frame_ClickMap))]
 	[BsonKnownTypes(typeof(Frame_ClickMap))]
-	public partial class  AFrameMessage {}
-
-	[ProtoInclude((int)Opcode.C2R_Login, typeof(C2R_Login))]
-	[ProtoInclude((int)Opcode.C2G_LoginGate, typeof(C2G_LoginGate))]
-	[ProtoInclude((int)Opcode.C2G_EnterMap, typeof(C2G_EnterMap))]
-	[ProtoInclude((int)Opcode.C2M_Reload, typeof(C2M_Reload))]
-	[ProtoInclude((int)Opcode.C2R_Ping, typeof(C2R_Ping))]
-	[BsonKnownTypes(typeof(C2R_Login))]
-	[BsonKnownTypes(typeof(C2G_LoginGate))]
-	[BsonKnownTypes(typeof(C2G_EnterMap))]
-	[BsonKnownTypes(typeof(C2M_Reload))]
-	[BsonKnownTypes(typeof(C2R_Ping))]
-	public partial class  ARequest {}
-
-	[ProtoInclude((int)Opcode.R2C_Login, typeof(R2C_Login))]
-	[ProtoInclude((int)Opcode.G2C_LoginGate, typeof(G2C_LoginGate))]
-	[ProtoInclude((int)Opcode.G2C_EnterMap, typeof(G2C_EnterMap))]
-	[ProtoInclude((int)Opcode.M2C_Reload, typeof(M2C_Reload))]
-	[ProtoInclude((int)Opcode.R2C_Ping, typeof(R2C_Ping))]
-	[BsonKnownTypes(typeof(R2C_Login))]
-	[BsonKnownTypes(typeof(G2C_LoginGate))]
-	[BsonKnownTypes(typeof(G2C_EnterMap))]
-	[BsonKnownTypes(typeof(M2C_Reload))]
-	[BsonKnownTypes(typeof(R2C_Ping))]
-	public partial class  AResponse {}
-
-}
+	public partial class MessageObject
+	{
+	}
+}

+ 65 - 96
Unity/Assets/Scripts/Entity/Session.cs

@@ -24,12 +24,13 @@ namespace Model
 	public sealed class Session : Entity
 	{
 		private static uint RpcId { get; set; }
-		private NetworkComponent network;
+		public NetworkComponent network;
 		private AChannel channel;
-
-		private readonly Dictionary<uint, Action<object>> requestCallback = new Dictionary<uint, Action<object>>();
-		private readonly List<byte[]> byteses = new List<byte[]>() {new byte[0], new byte[0]};
 		
+		private readonly Dictionary<uint, Action<PacketInfo>> requestCallback = new Dictionary<uint, Action<PacketInfo>>();
+		
+		private readonly List<byte[]> byteses = new List<byte[]>() {new byte[0], new byte[0], new byte[0]};
+
 		public void Awake(NetworkComponent net, AChannel c)
 		{
 			this.network = net;
@@ -53,9 +54,9 @@ namespace Model
 
 			base.Dispose();
 
-			foreach (Action<object> action in this.requestCallback.Values.ToArray())
+			foreach (Action<PacketInfo> action in this.requestCallback.Values.ToArray())
 			{
-				action.Invoke(new ErrorResponse() { Error = ErrorCode.ERR_SocketDisconnected });
+				action.Invoke(new PacketInfo());
 			}
 
 			this.channel.Dispose();
@@ -102,18 +103,10 @@ namespace Model
 					Log.Error(e.ToString());
 					continue;
 				}
-
-				if (packet.Length < 2)
-				{
-					Log.Error($"message error length < 2, ip: {this.RemoteAddress}");
-					this.network.Remove(this.Id);
-					return;
-				}
-
-				ushort opcode = BitConverter.ToUInt16(packet.Bytes, 0);
+				
 				try
 				{
-					this.RunDecompressedBytes(opcode, packet.Bytes, 2, packet.Length);
+					this.Run(packet);
 				}
 				catch (Exception e)
 				{
@@ -122,147 +115,123 @@ namespace Model
 			}
 		}
 
-		private void RunDecompressedBytes(ushort opcode, byte[] messageBytes, int offset, int count)
+		private void Run(Packet packet)
 		{
-			object message;
-
-			try
-			{
-				Type messageType = this.network.Parent.GetComponent<OpcodeTypeComponent>().GetType(opcode);
-				message = this.network.MessagePacker.DeserializeFrom(messageType, messageBytes, offset, count - offset);
-			}
-			catch (Exception e)
+			if (packet.Length < Packet.MinSize)
 			{
-				Log.Error($"message deserialize error, ip: {this.RemoteAddress} {opcode} {e}");
+				Log.Error($"message error length < {Packet.MinSize}, ip: {this.RemoteAddress}");
 				this.network.Remove(this.Id);
 				return;
 			}
 
-			//Log.Debug($"recv: {MongoHelper.ToJson(message)}");
+			ushort headerSize = BitConverter.ToUInt16(packet.Bytes, 0);
+			Header header = this.network.MessagePacker.DeserializeFrom<Header>(packet.Bytes, 2, headerSize);
+			byte flag = header.Flag;
+			PacketInfo packetInfo = new PacketInfo
+			{
+				Header = header,
+				Index = (ushort)(headerSize + 2),
+				Bytes = packet.Bytes,
+				Length = (ushort)(packet.Length - 2 - headerSize)
+			};
 
-			AResponse response = message as AResponse;
-			if (response != null)
+			// flag第2位表示这是rpc返回消息
+			if ((flag & 0x40) > 0)
 			{
-				// rpcFlag>0 表示这是一个rpc响应消息
-				// Rpc回调有找不着的可能,因为client可能取消Rpc调用
-				Action<object> action;
-				if (!this.requestCallback.TryGetValue(response.RpcId, out action))
+				uint rpcId = header.RpcId;
+				Action<PacketInfo> action;
+				if (!this.requestCallback.TryGetValue(rpcId, out action))
 				{
 					return;
 				}
-				this.requestCallback.Remove(response.RpcId);
-				action(message);
+				this.requestCallback.Remove(rpcId);
+				action(packetInfo);
 				return;
 			}
 
-			this.network.MessageDispatcher.Dispatch(this, opcode, offset, messageBytes, (AMessage)message);
+			this.network.MessageDispatcher.Dispatch(this, packetInfo);
 		}
 
-		/// <summary>
-		/// Rpc调用,发送一个消息,等待返回一个消息
-		/// </summary>
-		public Task<AResponse> Call(ARequest request)
+		public Task<PacketInfo> Call(ushort opcode, byte[] bytes)
 		{
-			request.RpcId = ++RpcId;
-
-			var tcs = new TaskCompletionSource<AResponse>();
-			this.requestCallback[request.RpcId] = (message) =>
+			uint rpcId = ++RpcId;
+			var tcs = new TaskCompletionSource<PacketInfo>();
+			this.requestCallback[rpcId] = (packetInfo) =>
 			{
 				try
 				{
-					AResponse response = (AResponse)message;
-					if (response.Error > 100)
-					{
-						tcs.SetException(new RpcException(response.Error, response.Message));
-						return;
-					}
-					//Log.Debug($"recv: {MongoHelper.ToJson(response)}");
-					tcs.SetResult(response);
+					tcs.SetResult(packetInfo);
 				}
 				catch (Exception e)
 				{
-					tcs.SetException(new Exception($"Rpc Error: {message.GetType().FullName}", e));
+					tcs.SetException(new Exception($"Rpc Error: {opcode}", e));
 				}
 			};
 
-			this.SendMessage(request);
+			const byte flag = 0x80;
+			this.SendMessage(flag, opcode, rpcId, bytes);
 			return tcs.Task;
 		}
 
-		/// <summary>
-		/// Rpc调用
-		/// </summary>
-		public Task<AResponse> Call(ARequest request, CancellationToken cancellationToken)
+		public Task<PacketInfo> Call(ushort opcode, byte[] bytes, CancellationToken cancellationToken)
 		{
-			request.RpcId = ++RpcId;
-			
-			var tcs = new TaskCompletionSource<AResponse>();
-
-			this.requestCallback[request.RpcId] = (message) =>
+			uint rpcId = ++RpcId;
+			var tcs = new TaskCompletionSource<PacketInfo>();
+			this.requestCallback[rpcId] = (packetInfo) =>
 			{
 				try
 				{
-					AResponse response = (AResponse)message;
-					if (response.Error > 100)
-					{
-						tcs.SetException(new RpcException(response.Error, response.Message));
-						return;
-					}
-					//Log.Debug($"recv: {MongoHelper.ToJson(response)}");
-					tcs.SetResult(response);
+					tcs.SetResult(packetInfo);
 				}
 				catch (Exception e)
 				{
-					tcs.SetException(new Exception($"Rpc Error: {message.GetType().FullName}", e));
+					tcs.SetException(new Exception($"Rpc Error: {opcode}", e));
 				}
 			};
 
-			cancellationToken.Register(() => { this.requestCallback.Remove(request.RpcId); });
-
-			this.SendMessage(request);
+			cancellationToken.Register(() => { this.requestCallback.Remove(rpcId); });
 
+			const byte flag = 0x80;
+			this.SendMessage(flag, opcode, rpcId, bytes);
 			return tcs.Task;
 		}
 
-		public void Send(AMessage message)
+		public void Send(ushort opcode, byte[] bytes)
 		{
 			if (this.Id == 0)
 			{
 				throw new Exception("session已经被Dispose了");
 			}
-			this.SendMessage(message);
+			const byte flag = 0x00;
+			this.SendMessage(flag, opcode, 0, bytes);
 		}
 
-		public void Reply<Response>(Response message) where Response : AResponse
+		public void Reply(ushort opcode, uint rpcId, byte[] bytes)
 		{
 			if (this.Id == 0)
 			{
 				throw new Exception("session已经被Dispose了");
 			}
-			this.SendMessage(message);
+
+			const byte flag = 0x40;
+			this.SendMessage(flag, opcode, rpcId, bytes);
 		}
 
-		private void SendMessage(object message)
+		private void SendMessage(byte flag, ushort opcode, uint rpcId, byte[] bytes)
 		{
-			//Log.Debug($"send: {MongoHelper.ToJson(message)}");
-			ushort opcode = this.network.Parent.GetComponent<OpcodeTypeComponent>().GetOpcode(message.GetType());
-			byte[] messageBytes = this.network.MessagePacker.SerializeToByteArray(message);
-
-#if SERVER
-			// 如果是allserver,内部消息不走网络,直接转给session,方便调试时看到整体堆栈
-			if (this.network.AppType == AppType.AllServer)
+			Header header = new Header
 			{
-				Session session = this.network.Parent.GetComponent<NetInnerComponent>().Get(this.RemoteAddress);
-				session.RunDecompressedBytes(opcode, messageBytes, 0, messageBytes.Length);
-				return;
-			}
-#endif
+				Opcode = opcode,
+				RpcId = rpcId,
+				Flag = flag
+			};
 
-			byte[] opcodeBytes = BitConverter.GetBytes(opcode);
-			
-			this.byteses[0] = opcodeBytes;
-			this.byteses[1] = messageBytes;
+			byte[] headerBytes = this.network.MessagePacker.SerializeToByteArray(header);
+			byte[] headerLength = BitConverter.GetBytes((ushort)headerBytes.Length);
 
+			this.byteses[0] = headerLength;
+			this.byteses[1] = headerBytes;
+			this.byteses[2] = bytes;
 			channel.Send(this.byteses);
 		}
 	}

+ 28 - 1
Unity/Assets/Scripts/Helper/ILHelper.cs

@@ -1,6 +1,8 @@
 using System;
 using System.Reflection;
+using ILRuntime.CLR.Method;
 using ILRuntime.Runtime.Enviorment;
+using ILRuntime.Runtime.Intepreter;
 using UnityEngine;
 
 namespace Model
@@ -22,7 +24,7 @@ namespace Model
 			// 注册委托
 			Init.Instance.AppDomain.DelegateManager.RegisterMethodDelegate<AChannel, System.Net.Sockets.SocketError>();
 			Init.Instance.AppDomain.DelegateManager.RegisterMethodDelegate<byte[], int, int>();
-			Init.Instance.AppDomain.DelegateManager.RegisterMethodDelegate<AResponse>();
+			Init.Instance.AppDomain.DelegateManager.RegisterMethodDelegate<IResponse>();
 
 
 			// 注册适配器
@@ -42,11 +44,36 @@ namespace Model
 				}
 				Init.Instance.AppDomain.RegisterCrossBindingAdaptor(adaptor);
 			}
+
+			// 初始化ILRuntime的protobuf
+			InitializeILRuntimeProtobuf();
 		}
 
 		public static void AvoidAot(GameObject gameObject)
 		{
 			Input input = gameObject.Get<Input>("11");
 		}
+
+		public static void InitializeILRuntimeProtobuf()
+		{
+			ProtoBuf.PType.RegisterFunctionCreateInstance(PType_CreateInstance);
+			ProtoBuf.PType.RegisterFunctionGetRealType(PType_GetRealType);
+		}
+
+		private static object PType_CreateInstance(string typeName)
+		{
+			return Init.Instance.AppDomain.Instantiate(typeName);
+		}
+
+		private static Type PType_GetRealType(object o)
+		{
+			Type type = o.GetType();
+			if (type.FullName == "ILRuntime.Runtime.Intepreter.ILTypeInstance")
+			{
+				ILTypeInstance ilo = o as ILTypeInstance;
+				type = ProtoBuf.PType.FindType(ilo.Type.FullName);
+			}
+			return type;
+		}
 	}
 }

+ 6 - 0
Unity/Assets/Scripts/Helper/MessageHelper.cs

@@ -0,0 +1,6 @@
+using System;
+
+namespace Model
+{
+
+}

+ 12 - 0
Unity/Assets/Scripts/Helper/MessageHelper.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: f8758a6b16e89d74d8c8994247dc95cf
+timeCreated: 1517811152
+licenseType: Free
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 47 - 0
Unity/Assets/Scripts/Helper/SessionHelper.cs

@@ -0,0 +1,47 @@
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Model
+{
+	public static class SessionHelper
+	{
+		public static async Task<IResponse> Call(this Session session, IRequest request)
+		{
+			OpcodeTypeComponent opcodeTypeComponent = Game.Scene.GetComponent<OpcodeTypeComponent>();
+			ushort opcode = opcodeTypeComponent.GetOpcode(request.GetType());
+			byte[] bytes = session.network.MessagePacker.SerializeToByteArray(request);
+			PacketInfo packetInfo = await session.Call(opcode, bytes);
+			Type responseType = opcodeTypeComponent.GetType(packetInfo.Header.Opcode);
+			object message = session.network.MessagePacker.DeserializeFrom(responseType, packetInfo.Bytes, packetInfo.Index, packetInfo.Length);
+			return (IResponse) message;
+		}
+
+		public static async Task<IResponse> Call(this Session session, IRequest request, CancellationToken cancellationToken)
+		{
+			OpcodeTypeComponent opcodeTypeComponent = Game.Scene.GetComponent<OpcodeTypeComponent>();
+			ushort opcode = opcodeTypeComponent.GetOpcode(request.GetType());
+			byte[] bytes = session.network.MessagePacker.SerializeToByteArray(request);
+			PacketInfo packetInfo = await session.Call(opcode, bytes, cancellationToken);
+			Type responseType = opcodeTypeComponent.GetType(packetInfo.Header.Opcode);
+			object message = session.network.MessagePacker.DeserializeFrom(responseType, packetInfo.Bytes, packetInfo.Index, packetInfo.Length);
+			return (IResponse)message;
+		}
+
+		public static void Send(this Session session, IMessage message)
+		{
+			OpcodeTypeComponent opcodeTypeComponent = Game.Scene.GetComponent<OpcodeTypeComponent>();
+			ushort opcode = opcodeTypeComponent.GetOpcode(message.GetType());
+			byte[] bytes = session.network.MessagePacker.SerializeToByteArray(message);
+			session.Send(opcode, bytes);
+		}
+
+		public static void Reply(this Session session, uint rpcId, IResponse message)
+		{
+			OpcodeTypeComponent opcodeTypeComponent = Game.Scene.GetComponent<OpcodeTypeComponent>();
+			ushort opcode = opcodeTypeComponent.GetOpcode(message.GetType());
+			byte[] bytes = session.network.MessagePacker.SerializeToByteArray(message);
+			session.Reply(opcode, rpcId, bytes);
+		}
+	}
+}

+ 12 - 0
Unity/Assets/Scripts/Helper/SessionHelper.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: cbd2f6105a7b0aa4392635282d1c0b8b
+timeCreated: 1517811152
+licenseType: Free
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 2 - 2
Unity/Hotfix/Base/Message/AMHandler.cs → Unity/Hotfix/Module/HotfixMessage/AMHandler.cs

@@ -3,11 +3,11 @@ using Model;
 
 namespace Hotfix
 {
-	public abstract class AMHandler<Message> : IMHandler where Message: AMessage 
+	public abstract class AMHandler<Message> : IMHandler where Message: MessageObject
 	{
 		protected abstract void Run(Session session, Message message);
 
-		public void Handle(Session session, AMessage msg)
+		public void Handle(Session session, IMessage msg)
 		{
 			Message message = msg as Message;
 			if (message == null)

+ 16 - 0
Unity/Hotfix/Module/HotfixMessage/AMessage.cs

@@ -0,0 +1,16 @@
+namespace Hotfix
+{
+#if ILRuntime
+	public abstract partial class AMessage
+	{
+	}
+	
+	public abstract partial class ARequest
+	{
+	}
+	
+	public abstract partial class AResponse
+	{
+	}
+#endif
+}

+ 0 - 0
Unity/Hotfix/Base/Message/IMHandler.cs → Unity/Hotfix/Module/HotfixMessage/IMHandler.cs


+ 86 - 0
Unity/Hotfix/Module/HotfixMessage/MessageDispatherComponent.cs

@@ -0,0 +1,86 @@
+using System;
+using System.Collections.Generic;
+using Model;
+
+namespace Hotfix
+{
+	[ObjectSystem]
+	public class MessageDispatherComponentSystem : ObjectSystem<MessageDispatherComponent>, IAwake, ILoad
+	{
+		public void Awake()
+		{
+			this.Get().Awake();
+		}
+
+		public void Load()
+		{
+			this.Get().Load();
+		}
+	}
+
+	/// <summary>
+	/// 消息分发组件
+	/// </summary>
+	public class MessageDispatherComponent : Component
+	{
+		private Dictionary<ushort, List<IMHandler>> handlers;
+
+		public void Awake()
+		{
+			this.Load();
+		}
+
+		public void Load()
+		{
+			this.handlers = new Dictionary<ushort, List<IMHandler>>();
+			
+			Type[] types = DllHelper.GetHotfixTypes();
+			foreach (Type type in types)
+			{
+				object[] attrs = type.GetCustomAttributes(typeof(MessageHandlerAttribute), false);
+				if (attrs.Length == 0)
+				{
+					continue;
+				}
+				MessageHandlerAttribute messageHandlerAttribute = (MessageHandlerAttribute)attrs[0];
+				IMHandler iMHandler = (IMHandler)Activator.CreateInstance(type);
+				if (!this.handlers.ContainsKey(messageHandlerAttribute.Opcode))
+				{
+					this.handlers.Add(messageHandlerAttribute.Opcode, new List<IMHandler>());
+				}
+				this.handlers[messageHandlerAttribute.Opcode].Add(iMHandler);
+			}
+		}
+
+		public void Handle(Session session, ushort opcode, IMessage message)
+		{
+			if (!this.handlers.TryGetValue(opcode, out List<IMHandler> actions))
+			{
+				Log.Error($"消息 {message.GetType().FullName} 没有处理");
+				return;
+			}
+			
+			foreach (IMHandler ev in actions)
+			{
+				try
+				{
+					ev.Handle(null, message);
+				}
+				catch (Exception e)
+				{
+					Log.Error(e.ToString());
+				}
+			}
+		}
+
+		public override void Dispose()
+		{
+			if (this.Id == 0)
+			{
+				return;
+			}
+
+			base.Dispose();
+		}
+	}
+}

+ 60 - 0
Unity/Hotfix/Module/HotfixMessage/OpcodeTypeComponent.cs

@@ -0,0 +1,60 @@
+using System;
+using Model;
+
+namespace Hotfix
+{
+	[ObjectSystem]
+	public class OpcodeTypeComponentSystem : ObjectSystem<OpcodeTypeComponent>, IAwake
+	{
+		public void Awake()
+		{
+			this.Get().Awake();
+		}
+	}
+
+	public class OpcodeTypeComponent : Component
+	{
+		private readonly DoubleMap<ushort, Type> opcodeTypes = new DoubleMap<ushort, Type>();
+
+		public void Awake()
+		{
+			Type[] monoTypes = DllHelper.GetHotfixTypes();
+			foreach (Type monoType in monoTypes)
+			{
+				object[] attrs = monoType.GetCustomAttributes(typeof(MessageAttribute), false);
+				if (attrs.Length == 0)
+				{
+					continue;
+				}
+
+				MessageAttribute messageAttribute = attrs[0] as MessageAttribute;
+				if (messageAttribute == null)
+				{
+					continue;
+				}
+
+				this.opcodeTypes.Add(messageAttribute.Opcode, monoType);
+			}
+		}
+
+		public ushort GetOpcode(Type type)
+		{
+			return this.opcodeTypes.GetKeyByValue(type);
+		}
+
+		public Type GetType(ushort opcode)
+		{
+			return this.opcodeTypes.GetValueByKey(opcode);
+		}
+
+		public override void Dispose()
+		{
+			if (this.Id == 0)
+			{
+				return;
+			}
+
+			base.Dispose();
+		}
+	}
+}

+ 43 - 0
Unity/Hotfix/Module/HotfixMessage/SessionWrap.cs

@@ -0,0 +1,43 @@
+using System;
+using System.Threading.Tasks;
+using Model;
+
+namespace Hotfix
+{
+	public class SessionWrap
+	{
+		public Session session;
+
+		public void Send(IMessage message)
+		{
+#if !ILRuntime
+			ushort opcode = Hotfix.Scene.GetComponent<OpcodeTypeComponent>().GetOpcode(message.GetType());
+			byte[] bytes = ProtobufHelper.ToBytes(message);
+			this.session.Send(opcode, bytes);
+#else
+			this.session.Send(message);
+#endif
+		}
+
+		public async Task<IResponse> Call(IRequest request)
+		{
+#if !ILRuntime
+			byte[] bytes = ProtobufHelper.ToBytes(request);
+			ushort opcode = Hotfix.Scene.GetComponent<OpcodeTypeComponent>().GetOpcode(request.GetType());
+			PacketInfo packetInfo = await this.session.Call(opcode, bytes);
+			ushort responseOpcode = BitConverter.ToUInt16(packetInfo.Bytes, 0);
+			Type t = GetType(responseOpcode);
+			IResponse response = (IResponse)ProtobufHelper.FromBytes(t, packetInfo.Bytes, packetInfo.Index, packetInfo.Length);
+			return response;
+#else
+			AResponse response = await this.session.Call(request);
+			return response;
+#endif
+		}
+
+		public static Type GetType(ushort opcode)
+		{
+			return null;
+		}
+	}
+}

+ 0 - 0
Unity/Hotfix/Component/UIComponent.cs → Unity/Hotfix/Module/HotfixMessage/UIComponent.cs


+ 8 - 3
Unity/Hotfix/Unity.Hotfix.csproj

@@ -54,8 +54,9 @@
     <Compile Include="Base\Helper\ArrayHelper.cs" />
     <Compile Include="Base\Helper\AssetBundleHelper.cs" />
     <Compile Include="Base\Helper\ExceptionHelper.cs" />
-    <Compile Include="Base\Message\AMHandler.cs" />
-    <Compile Include="Base\Message\IMHandler.cs" />
+    <Compile Include="Module\HotfixMessage\AMessage.cs" />
+    <Compile Include="Module\HotfixMessage\AMHandler.cs" />
+    <Compile Include="Module\HotfixMessage\IMHandler.cs" />
     <Compile Include="Base\Object\Component.cs" />
     <Compile Include="Base\Object\ComponentFactory.cs" />
     <Compile Include="Base\Object\Disposer.cs" />
@@ -71,9 +72,12 @@
     <Compile Include="Base\Object\EventSystem.cs" />
     <Compile Include="Base\Object\ObjectPool.cs" />
     <Compile Include="Base\Other\IUIFactory.cs" />
-    <Compile Include="Component\UIComponent.cs" />
+    <Compile Include="Module\HotfixMessage\MessageDispatherComponent.cs" />
+    <Compile Include="Module\HotfixMessage\OpcodeTypeComponent.cs" />
+    <Compile Include="Module\HotfixMessage\UIComponent.cs" />
     <Compile Include="Entity\Hotfix.cs" />
     <Compile Include="Entity\Scene.cs" />
+    <Compile Include="Module\HotfixMessage\SessionWrap.cs" />
     <Compile Include="Entity\UI.cs" />
     <Compile Include="Init.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
@@ -84,6 +88,7 @@
     <Compile Include="UI\UILogin\Factory\UILoginFactory.cs" />
   </ItemGroup>
   <ItemGroup>
+    <Folder Include="Component\" />
     <Folder Include="Event\" />
     <Folder Include="Handler\" />
   </ItemGroup>

+ 10 - 5
Unity/Unity.csproj

@@ -12,12 +12,15 @@
     <ProjectTypeGuids>{E097FAD1-6243-4DAD-9C02-E9B9EFC3FFC1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
     <TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
     <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
-    <TargetFrameworkProfile></TargetFrameworkProfile>
-    <CompilerResponseFile></CompilerResponseFile>
+    <TargetFrameworkProfile>
+    </TargetFrameworkProfile>
+    <CompilerResponseFile>
+    </CompilerResponseFile>
     <UnityProjectType>Game:1</UnityProjectType>
     <UnityBuildTarget>StandaloneWindows64:19</UnityBuildTarget>
     <UnityVersion>2017.1.1p4</UnityVersion>
-    <RootNamespace></RootNamespace>
+    <RootNamespace>
+    </RootNamespace>
     <LangVersion>6</LangVersion>
   </PropertyGroup>
   <PropertyGroup>
@@ -209,7 +212,7 @@
     <Compile Include="Assets\Scripts\Base\Math\VLine.cs" />
     <Compile Include="Assets\Scripts\Base\Math\VRect.cs" />
     <Compile Include="Assets\Scripts\Base\Message\AActorMessage.cs" />
-    <Compile Include="Assets\Scripts\Base\Message\AMessage.cs" />
+    <Compile Include="Assets\Scripts\Base\Message\IMessage.cs" />
     <Compile Include="Assets\Scripts\Base\Message\AMHandler.cs" />
     <Compile Include="Assets\Scripts\Base\Message\AppType.cs" />
     <Compile Include="Assets\Scripts\Base\Message\ClientDispatcher.cs" />
@@ -324,10 +327,12 @@
     <Compile Include="Assets\Scripts\Helper\DllHelper.cs" />
     <Compile Include="Assets\Scripts\Helper\GameObjectHelper.cs" />
     <Compile Include="Assets\Scripts\Helper\ILHelper.cs" />
+    <Compile Include="Assets\Scripts\Helper\MessageHelper.cs" />
     <Compile Include="Assets\Scripts\Helper\PathHelper.cs" />
     <Compile Include="Assets\Scripts\Helper\PositionHelper.cs" />
     <Compile Include="Assets\Scripts\Helper\ResourceHelper.cs" />
     <Compile Include="Assets\Scripts\Helper\ResourcesHelper.cs" />
+    <Compile Include="Assets\Scripts\Helper\SessionHelper.cs" />
     <Compile Include="Assets\Scripts\Init.cs" />
     <Compile Include="Assets\Scripts\MonoConfig\CanvasConfig.cs" />
     <Compile Include="Assets\Scripts\Other\Define.cs" />
@@ -674,4 +679,4 @@
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Target Name="GenerateTargetFrameworkMonikerAttribute" />
-</Project>
+</Project>