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

消息到热更层要new个数组,感觉不太合适,还是想办法把它去掉。去掉消息协议中的rpcid,rpcid还是可以放到消息中,根据opcode来确定消息是否需要抛到热更层,在有热更层进行分发。这样hotfix层消息接收时可以减少new一块内存,减少gc

tanghai 7 лет назад
Родитель
Сommit
0cfb48b4e6
67 измененных файлов с 1111 добавлено и 989 удалено
  1. 1 1
      Server/Hotfix/Module/Actor/ActorComponentSystem.cs
  2. 11 10
      Server/Hotfix/Module/Actor/EntityActorHandler.cs
  3. 7 6
      Server/Hotfix/Module/Message/InnerMessageDispatcher.cs
  4. 11 5
      Server/Hotfix/Module/Message/OuterMessageDispatcher.cs
  5. 6 4
      Server/Model/Module/Actor/AMActorHandler.cs
  6. 1 1
      Server/Model/Module/Actor/ActorComponent.cs
  7. 2 2
      Server/Model/Module/Actor/ActorMessageDispatherComponent.cs
  8. 9 3
      Server/Model/Module/Actor/ActorRequestWrap.cs
  9. 1 1
      Server/Model/Module/Actor/IEntityActorHandler.cs
  10. 1 1
      Server/Model/Module/Actor/IMActorHandler.cs
  11. 5 2
      Server/Model/Module/Message/AMRpcHandler.cs
  12. 16 5
      Server/Model/Module/Message/HotfixMessage.cs
  13. 64 6
      Server/Model/Module/Message/InnerMessage.cs
  14. 0 25
      Server/Model/Module/Message/OpcodeHelper.cs
  15. 20 0
      Server/Model/Module/Message/OuterMessage.cs
  16. 1 0
      Server/Model/Server.Model.csproj
  17. 45 13
      Unity/Assets/Editor/Proto2CsEditor/Proto2CSEditor.cs
  18. 1 1
      Unity/Assets/Scripts/Module/FrameSync/ClientFrameComponent.cs
  19. 1 1
      Unity/Assets/Scripts/Module/Message/AMHandler.cs
  20. 9 10
      Unity/Assets/Scripts/Module/Message/ClientDispatcher.cs
  21. 1 1
      Unity/Assets/Scripts/Module/Message/IMHandler.cs
  22. 2 0
      Unity/Assets/Scripts/Module/Message/IMessage.cs
  23. 1 1
      Unity/Assets/Scripts/Module/Message/IMessageDispatcher.cs
  24. 1 1
      Unity/Assets/Scripts/Module/Message/MessageDispatherComponent.cs
  25. 1 3
      Unity/Assets/Scripts/Module/Message/MessageInfo.cs
  26. 4 4
      Unity/Assets/Scripts/Module/Message/MessageProxy.cs
  27. 1 2
      Unity/Assets/Scripts/Module/Message/NetOuterComponent.cs
  28. 3 7
      Unity/Assets/Scripts/Module/Message/Network/TCP/PacketParser.cs
  29. 32 0
      Unity/Assets/Scripts/Module/Message/OuterMessage.cs
  30. 57 160
      Unity/Assets/Scripts/Module/Message/Session.cs
  31. 10 0
      Unity/Assets/Scripts/Module/Message/SessionCallbackComponent.cs
  32. 2 2
      Unity/Assets/Scripts/Module/Message/SessionCallbackComponent.cs.meta
  33. 9 8
      Unity/Assets/ThirdParty/ILRuntime/Generated/CLRBindings.cs
  34. 44 10
      Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_Entity_Binding.cs
  35. 3 27
      Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_MessageInfo_Binding.cs
  36. 2 2
      Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_MessageProxy_Binding.cs
  37. 2 23
      Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_NetworkComponent_Binding.cs
  38. 62 18
      Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_Packet_Binding.cs
  39. 2 2
      Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_Packet_Binding.cs.meta
  40. 11 19
      Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_RpcException_Binding.cs
  41. 2 2
      Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_RpcException_Binding.cs.meta
  42. 57 0
      Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_SessionCallbackComponent_Binding.cs
  43. 2 2
      Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_SessionCallbackComponent_Binding.cs.meta
  44. 6 32
      Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_Session_Binding.cs
  45. 171 0
      Unity/Assets/ThirdParty/ILRuntime/Generated/System_Collections_Generic_Dictionary_2_Int32_Action_1_ILTypeI_t.cs
  46. 12 0
      Unity/Assets/ThirdParty/ILRuntime/Generated/System_Collections_Generic_Dictionary_2_Int32_Action_1_ILTypeI_t.cs.meta
  47. 0 435
      Unity/Assets/ThirdParty/ILRuntime/Generated/System_Runtime_CompilerServices_AsyncTaskMethodBuilder_1_ILTyp_t.cs
  48. 28 5
      Unity/Assets/ThirdParty/ILRuntime/Generated/System_Threading_CancellationToken_Binding.cs
  49. 12 0
      Unity/Assets/ThirdParty/ILRuntime/Generated/System_Threading_CancellationToken_Binding.cs.meta
  50. 112 0
      Unity/Assets/ThirdParty/ILRuntime/Generated/System_Threading_Tasks_TaskCompletionSource_1_ILTypeInstance_B_t.cs
  51. 12 0
      Unity/Assets/ThirdParty/ILRuntime/Generated/System_Threading_Tasks_TaskCompletionSource_1_ILTypeInstance_B_t.cs.meta
  52. 0 51
      Unity/Assets/ThirdParty/ILRuntime/Generated/System_Threading_Tasks_Task_1_PacketInfo_Binding.cs
  53. 0 12
      Unity/Assets/ThirdParty/ILRuntime/Generated/System_Threading_Tasks_Task_1_PacketInfo_Binding.cs.meta
  54. 1 8
      Unity/Hotfix/Init.cs
  55. 2 2
      Unity/Hotfix/Module/FrameSync/OperaComponent.cs
  56. 1 1
      Unity/Hotfix/Module/Message/AMHandler.cs
  57. 23 0
      Unity/Hotfix/Module/Message/HotfixMessage.cs
  58. 1 7
      Unity/Hotfix/Module/Message/HotfixMessageDispatcher.cs
  59. 1 1
      Unity/Hotfix/Module/Message/IMHandler.cs
  60. 3 1
      Unity/Hotfix/Module/Message/IMessage.cs
  61. 2 2
      Unity/Hotfix/Module/Message/MessageDispatherComponent.cs
  62. 0 29
      Unity/Hotfix/Module/Message/SessionHelper.cs
  63. 145 0
      Unity/Hotfix/Module/Message/SessionWrap.cs
  64. 39 0
      Unity/Hotfix/Module/Message/SessionWrapComponent.cs
  65. 8 6
      Unity/Hotfix/UI/UILogin/Component/UILoginComponent.cs
  66. 2 1
      Unity/Hotfix/Unity.Hotfix.csproj
  67. 7 5
      Unity/Unity.csproj

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

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

+ 11 - 10
Server/Hotfix/Module/Actor/EntityActorHandler.cs

@@ -9,21 +9,21 @@ namespace ETHotfix
     /// </summary>
     public class GateSessionEntityActorHandler : IEntityActorHandler
     {
-        public async Task Handle(Session session, Entity entity, uint rpcId, ActorRequest message)
+        public async Task Handle(Session session, Entity entity, ActorRequest message)
         {
-	        ActorResponse response = new ActorResponse();
-
+			ActorResponse response = new ActorResponse();
 			try
 	        {
 		        ((Session)entity).Send((IMessage)message.AMessage);
-		        session.Reply(rpcId, response);
+		        response.RpcId = message.RpcId;
+		        session.Reply(response);
 		        await Task.CompletedTask;
 	        }
 	        catch (Exception e)
 	        {
 		        response.Error = ErrorCode.ERR_SessionActorError;
 		        response.Message = $"session actor error {e}";
-				session.Reply(rpcId, response);
+				session.Reply(response);
 				throw;
 	        }
         }
@@ -31,9 +31,9 @@ namespace ETHotfix
 
     public class CommonEntityActorHandler : IEntityActorHandler
     {
-        public async Task Handle(Session session, Entity entity, uint rpcId, ActorRequest message)
+        public async Task Handle(Session session, Entity entity, ActorRequest message)
         {
-            await Game.Scene.GetComponent<ActorMessageDispatherComponent>().Handle(session, entity, rpcId, message);
+            await Game.Scene.GetComponent<ActorMessageDispatherComponent>().Handle(session, entity, message);
         }
     }
 
@@ -42,7 +42,7 @@ namespace ETHotfix
     /// </summary>
     public class MapUnitEntityActorHandler : IEntityActorHandler
     {
-        public async Task Handle(Session session, Entity entity, uint rpcId, ActorRequest message)
+        public async Task Handle(Session session, Entity entity, ActorRequest message)
         {
             if (message.AMessage is IFrameMessage aFrameMessage)
             {
@@ -50,10 +50,11 @@ namespace ETHotfix
 	            aFrameMessage.Id = entity.Id;
 				Game.Scene.GetComponent<ServerFrameComponent>().Add(aFrameMessage);
 	            ActorResponse response = new ActorResponse();
-	            session.Reply(rpcId, response);
+	            response.RpcId = message.RpcId;
+	            session.Reply(response);
 				return;
             }
-            await Game.Scene.GetComponent<ActorMessageDispatherComponent>().Handle(session, entity, rpcId, message);
+            await Game.Scene.GetComponent<ActorMessageDispatherComponent>().Handle(session, entity, message);
         }
     }
 }

+ 7 - 6
Server/Hotfix/Module/Message/InnerMessageDispatcher.cs

@@ -5,10 +5,11 @@ namespace ETHotfix
 {
 	public class InnerMessageDispatcher: IMessageDispatcher
 	{
-		public void Dispatch(Session session, PacketInfo packetInfo)
+		public void Dispatch(Session session, Packet packet)
 		{
-			Type messageType = Game.Scene.GetComponent<OpcodeTypeComponent>().GetType(packetInfo.Opcode);
-			IMessage message = (IMessage)session.Network.MessagePacker.DeserializeFrom(messageType, packetInfo.Bytes, packetInfo.Index, packetInfo.Length);
+			ushort opcode = packet.Opcode();
+			Type messageType = Game.Scene.GetComponent<OpcodeTypeComponent>().GetType(opcode);
+			IMessage message = (IMessage)session.Network.MessagePacker.DeserializeFrom(messageType, packet.Bytes, Packet.Index, packet.Length - Packet.Index);
 			// 收到actor rpc request
 			if (message is ActorRequest actorRpcRequest)
 			{
@@ -20,15 +21,15 @@ namespace ETHotfix
 					{
 						Error = ErrorCode.ERR_NotFoundActor
 					};
-					session.Reply(packetInfo.RpcId, response);
+					session.Reply(response);
 					return;
 				}
 				
-				entity.GetComponent<ActorComponent>().Add(new ActorMessageInfo() { Session = session, RpcId = packetInfo.RpcId, Message = actorRpcRequest });
+				entity.GetComponent<ActorComponent>().Add(new ActorMessageInfo() { Session = session, RpcId = actorRpcRequest.RpcId, Message = actorRpcRequest });
 				return;
 			}
 			
-			Game.Scene.GetComponent<MessageDispatherComponent>().Handle(session, new MessageInfo(packetInfo.RpcId, packetInfo.Opcode, message));
+			Game.Scene.GetComponent<MessageDispatherComponent>().Handle(session, new MessageInfo(opcode, message));
 		}
 	}
 }

+ 11 - 5
Server/Hotfix/Module/Message/OuterMessageDispatcher.cs

@@ -5,10 +5,11 @@ namespace ETHotfix
 {
 	public class OuterMessageDispatcher: IMessageDispatcher
 	{
-		public async void Dispatch(Session session, PacketInfo packetInfo)
+		public async void Dispatch(Session session, Packet packet)
 		{
-			Type messageType = Game.Scene.GetComponent<OpcodeTypeComponent>().GetType(packetInfo.Opcode);
-			object message = session.Network.MessagePacker.DeserializeFrom(messageType, packetInfo.Bytes, packetInfo.Index, packetInfo.Length);
+			ushort opcode = packet.Opcode();
+			Type messageType = Game.Scene.GetComponent<OpcodeTypeComponent>().GetType(opcode);
+			object message = session.Network.MessagePacker.DeserializeFrom(messageType, packet.Bytes, Packet.Index, packet.Length - Packet.Index);
 
 			// gate session收到actor消息直接转发给actor自己去处理
 			if (message is IActorMessage)
@@ -25,17 +26,22 @@ namespace ETHotfix
 				long unitId = session.GetComponent<SessionPlayerComponent>().Player.UnitId;
 				ActorProxy actorProxy = Game.Scene.GetComponent<ActorProxyComponent>().Get(unitId);
 				IResponse response = await actorProxy.Call(aActorRequest);
-				session.Reply(packetInfo.RpcId, response);
+				session.Reply(response);
 				return;
 			}
 
 			if (message != null)
 			{
-				Game.Scene.GetComponent<MessageDispatherComponent>().Handle(session, new MessageInfo(packetInfo.RpcId, packetInfo.Opcode, message));
+				Game.Scene.GetComponent<MessageDispatherComponent>().Handle(session, new MessageInfo(opcode, message));
 				return;
 			}
 
 			throw new Exception($"message type error: {message.GetType().FullName}");
 		}
+
+		public void Dispatch(Session session, ushort opcode, object message)
+		{
+			throw new NotImplementedException();
+		}
 	}
 }

+ 6 - 4
Server/Model/Module/Actor/AMActorHandler.cs

@@ -7,7 +7,7 @@ namespace ETModel
 	{
 		protected abstract Task Run(E entity, Message message);
 
-		public async Task Handle(Session session, Entity entity, uint rpcId, ActorRequest message)
+		public async Task Handle(Session session, Entity entity, ActorRequest message)
 		{
 			Message msg = message.AMessage as Message;
 			if (msg == null)
@@ -30,7 +30,7 @@ namespace ETModel
 				return;
 			}
 			ActorResponse response = new ActorResponse();
-			session.Reply(rpcId, response);
+			session.Reply(response);
 		}
 
 		public Type GetMessageType()
@@ -51,7 +51,7 @@ namespace ETModel
 
 		protected abstract Task Run(E unit, Request message, Action<Response> reply);
 
-		public async Task Handle(Session session, Entity entity, uint rpcId, ActorRequest message)
+		public async Task Handle(Session session, Entity entity, ActorRequest message)
 		{
 			try
 			{
@@ -78,7 +78,9 @@ namespace ETModel
 					{
 						AMessage = response
 					};
-					session.Reply(rpcId, actorResponse);
+					int rpcId = message.RpcId;
+					actorResponse.RpcId = rpcId;
+					session.Reply(actorResponse);
 				});
 			}
 			catch (Exception e)

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

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

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

@@ -75,14 +75,14 @@ namespace ETModel
 			return actorHandler;
 		}
 
-		public async Task Handle(Session session, Entity entity, uint rpcId, ActorRequest message)
+		public async Task Handle(Session session, Entity entity, 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, rpcId, message);
+			await handler.Handle(session, entity, message);
 		}
 
 		public override void Dispose()

+ 9 - 3
Server/Model/Module/Actor/ActorRequestWrap.cs

@@ -12,6 +12,9 @@ namespace ETModel
 	[ProtoContract]
 	public partial class ActorRequest : IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
+
 		[ProtoMember(1, IsRequired = true)]
 		public long Id { get; set; }
 
@@ -26,13 +29,16 @@ namespace ETModel
 	[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; }
+
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
+
+		[ProtoMember(1, IsRequired = true)]
+		public MessageObject AMessage;
 	}
 }

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

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

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

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

+ 5 - 2
Server/Model/Module/Message/AMRpcHandler.cs

@@ -14,7 +14,7 @@ namespace ETModel
 
 		protected abstract void Run(Session session, Request message, Action<Response> reply);
 
-		public void Handle(Session session, uint rpcId, object message)
+		public void Handle(Session session, object message)
 		{
 			try
 			{
@@ -30,7 +30,10 @@ namespace ETModel
 					{
 						return;
 					}
-					session.Reply(rpcId, response);
+
+					int rpcId = request.RpcId;
+					response.RpcId = rpcId;
+					session.Reply(response);
 				});
 			}
 			catch (Exception e)

+ 16 - 5
Server/Model/Module/Message/HotfixMessage.cs

@@ -8,6 +8,8 @@ namespace ETModel
 	[ProtoContract]
 	public partial class C2R_Login: IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public string Account;
 
@@ -24,6 +26,8 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public string Address;
 
@@ -36,6 +40,8 @@ namespace ETModel
 	[ProtoContract]
 	public partial class C2G_LoginGate: IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public long Key;
 
@@ -49,6 +55,8 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public long PlayerId;
 
@@ -67,6 +75,8 @@ namespace ETModel
 	[ProtoContract]
 	public partial class C2M_TestActorRequest: MessageObject, IActorRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public string Info;
 
@@ -80,6 +90,8 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public string Info;
 
@@ -95,6 +107,8 @@ namespace ETModel
 	[ProtoContract]
 	public partial class C2G_PlayerInfo: IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 	}
 
 	[Message(HotfixOpcode.G2C_PlayerInfo)]
@@ -105,6 +119,8 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1)]
 		public List<PlayerInfo> PlayerInfos = new List<PlayerInfo>();
 
@@ -118,8 +134,3 @@ namespace ETModel
 	public partial class MessageObject {}
 
 }
-namespace ETModel
-{
-	public partial class MessageObject {}
-
-}

+ 64 - 6
Server/Model/Module/Message/InnerMessage.cs

@@ -11,6 +11,8 @@ namespace ETModel
 	[ProtoContract]
 	public partial class M2M_TrasferUnitRequest: IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public Unit Unit;
 
@@ -24,12 +26,16 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 	}
 
 	[Message(InnerOpcode.M2A_Reload)]
 	[ProtoContract]
 	public partial class M2A_Reload: IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 	}
 
 	[Message(InnerOpcode.A2M_Reload)]
@@ -40,12 +46,16 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 	}
 
 	[Message(InnerOpcode.G2G_LockRequest)]
 	[ProtoContract]
 	public partial class G2G_LockRequest: IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public long Id;
 
@@ -62,12 +72,16 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 	}
 
 	[Message(InnerOpcode.G2G_LockReleaseRequest)]
 	[ProtoContract]
 	public partial class G2G_LockReleaseRequest: IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public long Id;
 
@@ -84,12 +98,16 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 	}
 
 	[Message(InnerOpcode.DBSaveRequest)]
 	[ProtoContract]
 	public partial class DBSaveRequest: IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public bool NeedCache;
 
@@ -109,12 +127,16 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 	}
 
 	[Message(InnerOpcode.DBSaveBatchRequest)]
 	[ProtoContract]
 	public partial class DBSaveBatchRequest: IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public bool NeedCache;
 
@@ -134,12 +156,16 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 	}
 
 	[Message(InnerOpcode.DBQueryRequest)]
 	[ProtoContract]
 	public partial class DBQueryRequest: IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public long Id;
 
@@ -159,6 +185,8 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public Component Disposer;
 
@@ -168,6 +196,8 @@ namespace ETModel
 	[ProtoContract]
 	public partial class DBQueryBatchRequest: IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public string CollectionName;
 
@@ -187,6 +217,8 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1)]
 		public List<Component> Disposers = new List<Component>();
 
@@ -196,6 +228,8 @@ namespace ETModel
 	[ProtoContract]
 	public partial class DBQueryJsonRequest: IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public string CollectionName;
 
@@ -215,6 +249,8 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1)]
 		public List<Component> Disposers = new List<Component>();
 
@@ -224,6 +260,8 @@ namespace ETModel
 	[ProtoContract]
 	public partial class ObjectAddRequest: IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public long Key;
 
@@ -240,12 +278,16 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 	}
 
 	[Message(InnerOpcode.ObjectRemoveRequest)]
 	[ProtoContract]
 	public partial class ObjectRemoveRequest: IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public long Key;
 
@@ -259,12 +301,16 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 	}
 
 	[Message(InnerOpcode.ObjectLockRequest)]
 	[ProtoContract]
 	public partial class ObjectLockRequest: IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public long Key;
 
@@ -284,12 +330,16 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 	}
 
 	[Message(InnerOpcode.ObjectUnLockRequest)]
 	[ProtoContract]
 	public partial class ObjectUnLockRequest: IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public long Key;
 
@@ -309,12 +359,16 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 	}
 
 	[Message(InnerOpcode.ObjectGetRequest)]
 	[ProtoContract]
 	public partial class ObjectGetRequest: IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public long Key;
 
@@ -328,6 +382,8 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public int AppId;
 
@@ -337,6 +393,8 @@ namespace ETModel
 	[ProtoContract]
 	public partial class R2G_GetLoginKey: IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public string Account;
 
@@ -350,6 +408,8 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public long Key;
 
@@ -359,6 +419,8 @@ namespace ETModel
 	[ProtoContract]
 	public partial class G2M_CreateUnit: IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public long PlayerId;
 
@@ -375,6 +437,8 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public long UnitId;
 
@@ -384,9 +448,3 @@ namespace ETModel
 	}
 
 }
-namespace ETModel
-{
-}
-namespace ETModel
-{
-}

+ 0 - 25
Server/Model/Module/Message/OpcodeHelper.cs

@@ -1,25 +0,0 @@
-using System.Collections.Generic;
-
-namespace ETModel
-{
-	public static class OpcodeHelper
-	{
-		private static readonly HashSet<ushort> needDebugLogMessageSet = new HashSet<ushort> { 1 };
-
-		public static bool IsNeedDebugLogMessage(ushort opcode)
-		{
-			//return true;
-			if (opcode > 1000)
-			{
-				return true;
-			}
-
-			if (needDebugLogMessageSet.Contains(opcode))
-			{
-				return true;
-			}
-
-			return false;
-		}
-	}
-}

+ 20 - 0
Server/Model/Module/Message/OuterMessage.cs

@@ -17,6 +17,8 @@ namespace ETModel
 	[ProtoContract]
 	public partial class Actor_TestRequest: MessageObject, IActorRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public string request;
 
@@ -30,6 +32,8 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public string response;
 
@@ -39,6 +43,8 @@ namespace ETModel
 	[ProtoContract]
 	public partial class Actor_TransferRequest: MessageObject, IActorRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public int MapIndex;
 
@@ -52,12 +58,16 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 	}
 
 	[Message(OuterOpcode.C2G_EnterMap)]
 	[ProtoContract]
 	public partial class C2G_EnterMap: IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 	}
 
 	[Message(OuterOpcode.G2C_EnterMap)]
@@ -68,6 +78,8 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public long UnitId;
 
@@ -130,6 +142,8 @@ namespace ETModel
 	[ProtoContract]
 	public partial class C2M_Reload: IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public AppType AppType;
 
@@ -143,12 +157,16 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 	}
 
 	[Message(OuterOpcode.C2R_Ping)]
 	[ProtoContract]
 	public partial class C2R_Ping: IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 	}
 
 	[Message(OuterOpcode.R2C_Ping)]
@@ -159,6 +177,8 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 	}
 
 }

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

@@ -93,6 +93,7 @@
     <Compile Include="..\..\Unity\Assets\Scripts\Module\Message\Network\TCP\TChannel.cs" Link="Module\Message\Network\TCP\TChannel.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Module\Message\Network\TCP\TService.cs" Link="Module\Message\Network\TCP\TService.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Module\Message\Opcode.cs" Link="Module\Message\Opcode.cs" />
+    <Compile Include="..\..\Unity\Assets\Scripts\Module\Message\OpcodeHelper.cs" Link="Module\Message\OpcodeHelper.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Module\Message\OpcodeTypeComponent.cs" Link="Module\Message\OpcodeTypeComponent.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Module\Message\ProtobufPacker.cs" Link="Module\Message\ProtobufPacker.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Module\Message\RpcException.cs" Link="Module\Message\RpcException.cs" />

+ 45 - 13
Unity/Assets/Editor/Proto2CsEditor/Proto2CSEditor.cs

@@ -34,14 +34,14 @@ namespace MyEditor
 		public static void AllProto2CS()
 		{
 			msgOpcode.Clear();
-			Proto2CS("ETModel", "OuterMessage.proto", clientMessagePath, "OuterOpcode", 100, HeadFlag.Proto | HeadFlag.Bson);
+			Proto2CS("ETModel", "OuterMessage.proto", clientMessagePath, "OuterOpcode", 100, HeadFlag.Proto);
 			GenerateOpcode("OuterOpcode", clientMessagePath);
 
 			Proto2CS("ETModel", "OuterMessage.proto", serverMessagePath, "OuterOpcode", 100, HeadFlag.Proto | HeadFlag.Bson, false);
 			GenerateOpcode("OuterOpcode", serverMessagePath);
 
 			msgOpcode.Clear();
-			Proto2CS("ETHotfix", "HotfixMessage.proto", hotfixMessagePath, "HotfixOpcode", 10000, HeadFlag.Bson);
+			Proto2CS("ETHotfix", "HotfixMessage.proto", hotfixMessagePath, "HotfixOpcode", 10000, HeadFlag.Proto);
 			GenerateOpcode("HotfixOpcode", hotfixMessagePath);
 
 			msgOpcode.Clear();
@@ -124,12 +124,20 @@ namespace MyEditor
 				{
 					sb.Append("\t{\n");
 
+					if (parentClass == "IRequest" || parentClass == "IActorRequest")
+					{
+						sb.AppendLine("\t\t[ProtoMember(90, IsRequired = true)]");
+						sb.AppendLine("\t\tpublic int RpcId { get; set; }");
+					}
+
 					if (parentClass == "IResponse" || parentClass == "IActorResponse")
 					{
 						sb.AppendLine("\t\t[ProtoMember(90, IsRequired = true)]");
 						sb.AppendLine("\t\tpublic int Error { get; set; }");
 						sb.AppendLine("\t\t[ProtoMember(91, IsRequired = true)]");
 						sb.AppendLine("\t\tpublic string Message { get; set; }");
+						sb.AppendLine("\t\t[ProtoMember(92, IsRequired = true)]");
+						sb.AppendLine("\t\tpublic int RpcId { get; set; }");
 					}
 
 					if (parentClass == "IFrameMessage")
@@ -163,32 +171,56 @@ namespace MyEditor
 			}
 			sb.Append("}\n");
 
-			if (!isClient)
-			{
+			//if (!isClient)
+			//{
 				GenerateHead(sb, ns, flag, opcodeClassName);
-			}
+			//}
 
 			File.WriteAllText(csPath, sb.ToString());
 		}
 
 		private static void GenerateHead(StringBuilder sb, string ns, HeadFlag flag, string opcodeClassName)
 		{
-			sb.AppendLine($"namespace {ns}");
-			sb.AppendLine("{");
-			foreach (string parentClass in parentMsg.GetDictionary().Keys)
+			if ((flag & HeadFlag.Bson) != 0)
 			{
-				if ((flag & HeadFlag.Bson) != 0)
+				if (parentMsg.Count > 0)
 				{
-					foreach (string s in parentMsg.GetAll(parentClass))
+					sb.AppendLine($"namespace {ns}");
+					sb.AppendLine("{");
+					foreach (string parentClass in parentMsg.GetDictionary().Keys)
 					{
-						sb.Append($"\t[BsonKnownTypes(typeof({s}))]\n");
+						foreach (string s in parentMsg.GetAll(parentClass))
+						{
+							sb.Append($"\t[BsonKnownTypes(typeof({s}))]\n");
+						}
+
+						sb.Append($"\tpublic partial class {parentClass} {{}}\n\n");
 					}
+
+					sb.AppendLine("}");
 				}
+			}
+
+			if ((flag & HeadFlag.Proto) != 0)
+			{
+				if (parentMsg.Count > 0)
+				{
+					sb.AppendLine($"namespace {ns}");
+					sb.AppendLine("{");
+					foreach (string parentClass in parentMsg.GetDictionary().Keys)
+					{
 
+						foreach (string s in parentMsg.GetAll(parentClass))
+						{
+							sb.Append($"\t[ProtoInclude({opcodeClassName}.{s}, typeof({s}))]\n");
+						}
 
-				sb.Append($"\tpublic partial class {parentClass} {{}}\n\n");
+						sb.Append($"\tpublic partial class {parentClass} {{}}\n\n");
+					}
+
+					sb.AppendLine("}");
+				}
 			}
-			sb.AppendLine("}");
 		}
 		
 		private static void GenerateOpcode(string outputFileName, string outputPath)

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

@@ -79,7 +79,7 @@ namespace ETModel
             {
 	            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(0, opcode, message));
+                Game.Scene.GetComponent<MessageDispatherComponent>().Handle(sessionFrameMessage.Session, new MessageInfo(opcode, message));
             }
         }
     }

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

@@ -6,7 +6,7 @@ namespace ETModel
 	{
 		protected abstract void Run(Session session, Message message);
 
-		public void Handle(Session session, uint rpcId, object msg)
+		public void Handle(Session session, object msg)
 		{
 			Message message = msg as Message;
 			if (message == null)

+ 9 - 10
Unity/Assets/Scripts/Module/Message/ClientDispatcher.cs

@@ -4,20 +4,19 @@ namespace ETModel
 {
 	public class ClientDispatcher: IMessageDispatcher
 	{
-		// 热更层消息回调
-		public Action<Session, PacketInfo> HotfixCallback;
-
-		public void Dispatch(Session session, PacketInfo packetInfo)
+		public void Dispatch(Session session, Packet packet)
 		{
-			if (OpcodeHelper.IsClientHotfixMessage(packetInfo.Opcode))
+			ushort opcode = packet.Opcode();
+
+			if (OpcodeHelper.IsClientHotfixMessage(opcode))
 			{
-				HotfixCallback.Invoke(session, packetInfo);
+				session.GetComponent<SessionCallbackComponent>().MessageCallback.Invoke(session, packet);
 				return;
 			}
 
-			Type messageType = Game.Scene.GetComponent<OpcodeTypeComponent>().GetType(packetInfo.Opcode);
-			IMessage message = (IMessage)session.Network.MessagePacker.DeserializeFrom(messageType, packetInfo.Bytes, packetInfo.Index, packetInfo.Length);
-
+			OpcodeTypeComponent opcodeTypeComponent = session.Network.Entity.GetComponent<OpcodeTypeComponent>();
+			Type responseType = opcodeTypeComponent.GetType(opcode);
+			object message = session.Network.MessagePacker.DeserializeFrom(responseType, packet.Bytes, Packet.Index, packet.Length - Packet.Index);
 			// 如果是帧同步消息,交给ClientFrameComponent处理
 			FrameMessage frameMessage = message as FrameMessage;
 			if (frameMessage != null)
@@ -27,7 +26,7 @@ namespace ETModel
 			}
 
 			// 普通消息或者是Rpc请求消息
-			MessageInfo messageInfo = new MessageInfo(packetInfo.RpcId, packetInfo.Opcode, message);
+			MessageInfo messageInfo = new MessageInfo(opcode, message);
 			Game.Scene.GetComponent<MessageDispatherComponent>().Handle(session, messageInfo);
 		}
 	}

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

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

+ 2 - 0
Unity/Assets/Scripts/Module/Message/IMessage.cs

@@ -23,11 +23,13 @@ namespace ETModel
 	
 	public interface IRequest: IMessage
 	{
+		int RpcId { get; set; }
 	}
 	
 	public interface IResponse: IMessage
 	{
 		int Error { get; set; }
 		string Message { get; set; }
+		int RpcId { get; set; }
 	}
 }

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

@@ -2,6 +2,6 @@
 {
 	public interface IMessageDispatcher
 	{
-		void Dispatch(Session session, PacketInfo packetInfo);
+		void Dispatch(Session session, Packet packet);
 	}
 }

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

@@ -88,7 +88,7 @@ namespace ETModel
 			{
 				try
 				{
-					ev.Handle(session, messageInfo.RpcId, messageInfo.Message);
+					ev.Handle(session, messageInfo.Message);
 				}
 				catch (Exception e)
 				{

+ 1 - 3
Unity/Assets/Scripts/Module/Message/MessageInfo.cs

@@ -2,13 +2,11 @@
 {
 	public struct MessageInfo
 	{
-		public uint RpcId { get; }
 		public ushort Opcode { get; }
 		public object Message { get; }
 
-		public MessageInfo(uint rpcId, ushort opcode, object message)
+		public MessageInfo(ushort opcode, object message)
 		{
-			this.RpcId = rpcId;
 			this.Opcode = opcode;
 			this.Message = message;
 		}

+ 4 - 4
Unity/Assets/Scripts/Module/Message/MessageProxy.cs

@@ -5,17 +5,17 @@ namespace ETModel
 	public class MessageProxy: IMHandler
 	{
 		private readonly Type type;
-		private readonly Action<Session, uint, object> action;
+		private readonly Action<Session, object> action;
 
-		public MessageProxy(Type type, Action<Session, uint, object> action)
+		public MessageProxy(Type type, Action<Session, object> action)
 		{
 			this.type = type;
 			this.action = action;
 		}
 		
-		public void Handle(Session session, uint rpcId, object message)
+		public void Handle(Session session, object message)
 		{
-			this.action.Invoke(session, rpcId, message);
+			this.action.Invoke(session, message);
 		}
 
 		public Type GetMessageType()

+ 1 - 2
Unity/Assets/Scripts/Module/Message/NetOuterComponent.cs

@@ -24,8 +24,7 @@
 		{
 			this.Awake(NetworkProtocol.TCP);
 			this.MessagePacker = new ProtobufPacker();
-			// 由hotfix中设置
-			//this.MessageDispatcher = new ClientDispatcher();
+			this.MessageDispatcher = new ClientDispatcher();
 		}
 
 		public new void Update()

+ 3 - 7
Unity/Assets/Scripts/Module/Message/Network/TCP/PacketParser.cs

@@ -11,8 +11,9 @@ namespace ETModel
 	public struct Packet
 	{
 		public const int MinSize = 2;
+		public const int FlagIndex = 0;
 		public const int OpcodeIndex = 1;
-		public const int RpcIdIndex = 3;
+		public const int Index = 3;
 
 		/// <summary>
 		/// 只读,不允许修改
@@ -36,16 +37,11 @@ namespace ETModel
 		{
 			return this.Bytes[0];
 		}
-
+		
 		public ushort Opcode()
 		{
 			return BitConverter.ToUInt16(this.Bytes, OpcodeIndex);
 		}
-
-		public uint RpcId()
-		{
-			return BitConverter.ToUInt32(this.Bytes, RpcIdIndex);
-		}
 	}
 
 	internal class PacketParser

+ 32 - 0
Unity/Assets/Scripts/Module/Message/OuterMessage.cs

@@ -17,6 +17,8 @@ namespace ETModel
 	[ProtoContract]
 	public partial class Actor_TestRequest: MessageObject, IActorRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public string request;
 
@@ -30,6 +32,8 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public string response;
 
@@ -39,6 +43,8 @@ namespace ETModel
 	[ProtoContract]
 	public partial class Actor_TransferRequest: MessageObject, IActorRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public int MapIndex;
 
@@ -52,12 +58,16 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 	}
 
 	[Message(OuterOpcode.C2G_EnterMap)]
 	[ProtoContract]
 	public partial class C2G_EnterMap: IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 	}
 
 	[Message(OuterOpcode.G2C_EnterMap)]
@@ -68,6 +78,8 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public long UnitId;
 
@@ -130,6 +142,8 @@ namespace ETModel
 	[ProtoContract]
 	public partial class C2M_Reload: IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public AppType AppType;
 
@@ -143,12 +157,16 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 	}
 
 	[Message(OuterOpcode.C2R_Ping)]
 	[ProtoContract]
 	public partial class C2R_Ping: IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 	}
 
 	[Message(OuterOpcode.R2C_Ping)]
@@ -159,6 +177,20 @@ namespace ETModel
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 	}
 
 }
+namespace ETModel
+{
+	[ProtoInclude(OuterOpcode.Actor_Test, typeof(Actor_Test))]
+	[ProtoInclude(OuterOpcode.Actor_TestRequest, typeof(Actor_TestRequest))]
+	[ProtoInclude(OuterOpcode.Actor_TestResponse, typeof(Actor_TestResponse))]
+	[ProtoInclude(OuterOpcode.Actor_TransferRequest, typeof(Actor_TransferRequest))]
+	[ProtoInclude(OuterOpcode.Actor_TransferResponse, typeof(Actor_TransferResponse))]
+	[ProtoInclude(OuterOpcode.Actor_CreateUnits, typeof(Actor_CreateUnits))]
+	[ProtoInclude(OuterOpcode.Frame_ClickMap, typeof(Frame_ClickMap))]
+	public partial class MessageObject {}
+
+}

+ 57 - 160
Unity/Assets/Scripts/Module/Message/Session.cs

@@ -27,14 +27,11 @@ namespace ETModel
 
 	public sealed class Session : Entity
 	{
-		private static uint RpcId { get; set; }
+		private static int RpcId { get; set; }
 		private AChannel channel;
 
-		private readonly Dictionary<uint, Action<PacketInfo>> requestCallback = new Dictionary<uint, Action<PacketInfo>>();
-
-		private readonly byte[] flagBytes = new byte[1];
-		private readonly List<byte[]> byteses = new List<byte[]>() {new byte[0], new byte[0], new byte[0]};
-		private readonly List<byte[]> rpcByteses = new List<byte[]>() { new byte[0], new byte[0], new byte[0], new byte[0] };
+		private readonly Dictionary<int, Action<IResponse>> requestCallback = new Dictionary<int, Action<IResponse>>();
+		private readonly List<byte[]> byteses = new List<byte[]>() { new byte[1], new byte[0], new byte[0]};
 
 		public NetworkComponent Network
 		{
@@ -66,9 +63,9 @@ namespace ETModel
 
 			base.Dispose();
 
-			foreach (Action<PacketInfo> action in this.requestCallback.Values.ToArray())
+			foreach (Action<IResponse> action in this.requestCallback.Values.ToArray())
 			{
-				action.Invoke(new PacketInfo());
+				action.Invoke(null);
 			}
 
 			this.channel.Dispose();
@@ -139,63 +136,52 @@ namespace ETModel
 
 			byte flag = packet.Flag();
 			ushort opcode = packet.Opcode();
-			PacketInfo packetInfo = new PacketInfo
+			
+			if (OpcodeHelper.IsClientHotfixMessage(opcode))
 			{
-				Opcode = opcode,
-				Bytes = packet.Bytes
-			};
+				this.Network.MessageDispatcher.Dispatch(this, packet);
+				return;
+			}
 			
-			if ((flag & 0xC0) > 0)
+			// flag第一位为1表示这是rpc返回消息
+			if ((flag & 0x01) > 0)
 			{
-				uint rpcId = packet.RpcId();
-				packetInfo.RpcId = rpcId;
-				packetInfo.Index = Packet.RpcIdIndex + 4;
-				packetInfo.Length = (ushort)(packet.Length - packetInfo.Index);
-				
-				// flag第2位表示这是rpc返回消息
-				if ((flag & 0x40) > 0)
-				{
-					Action<PacketInfo> action;
-					if (!this.requestCallback.TryGetValue(rpcId, out action))
-					{
-						return;
-					}
-					this.requestCallback.Remove(rpcId);
+				OpcodeTypeComponent opcodeTypeComponent = this.Network.Entity.GetComponent<OpcodeTypeComponent>();
+				Type responseType = opcodeTypeComponent.GetType(opcode);
+				object message = this.Network.MessagePacker.DeserializeFrom(responseType, packet.Bytes, Packet.Index, packet.Length - Packet.Index);
 
-					action(packetInfo);
+				IResponse response = message as IResponse;
+				if (response == null)
+				{
+					throw new Exception($"flag is response, but message is not! {opcode}");
+				}
+				Action<IResponse> action;
+				if (!this.requestCallback.TryGetValue(response.RpcId, out action))
+				{
 					return;
 				}
-			}
-			else
-			{
-				packetInfo.RpcId = 0;
-				packetInfo.Index = Packet.RpcIdIndex;
-				packetInfo.Length = (ushort)(packet.Length - packetInfo.Index);
+				this.requestCallback.Remove(response.RpcId);
+
+				action(response);
+				return;
 			}
 			
-			this.Network.MessageDispatcher.Dispatch(this, packetInfo);
+			this.Network.MessageDispatcher.Dispatch(this, packet);
 		}
 
 		public Task<IResponse> Call(IRequest request)
 		{
-			uint rpcId = ++RpcId;
+			int rpcId = ++RpcId;
 			var tcs = new TaskCompletionSource<IResponse>();
 
-			OpcodeTypeComponent opcodeTypeComponent = this.Network.Entity.GetComponent<OpcodeTypeComponent>();
-			ushort opcode = opcodeTypeComponent.GetOpcode(request.GetType());
-			byte[] bytes = this.Network.MessagePacker.SerializeToByteArray(request);
-
-			this.requestCallback[rpcId] = (packetInfo) =>
+			this.requestCallback[rpcId] = (response) =>
 			{
 				try
 				{
-					if (packetInfo.RpcId != rpcId)
+					if (response.RpcId != rpcId)
 					{
 						return;
 					}
-					Type responseType = opcodeTypeComponent.GetType(packetInfo.Opcode);
-					object message = this.Network.MessagePacker.DeserializeFrom(responseType, packetInfo.Bytes, packetInfo.Index, packetInfo.Length);
-					IResponse response = (IResponse)message;
 					if (response.Error > ErrorCode.ERR_Exception)
 					{
 						throw new RpcException(response.Error, response.Message);
@@ -205,35 +191,28 @@ namespace ETModel
 				}
 				catch (Exception e)
 				{
-					tcs.SetException(new Exception($"Rpc Error: {packetInfo.Opcode}", e));
+					tcs.SetException(new Exception($"Rpc Error: {request.GetType().FullName}", e));
 				}
 			};
 
-			const byte flag = 0x80;
-			this.SendMessage(flag, opcode, rpcId, bytes);
+			request.RpcId = rpcId;
+			this.Send(0x00, request);
 			return tcs.Task;
 		}
 
 		public Task<IResponse> Call(IRequest request, CancellationToken cancellationToken)
 		{
-			uint rpcId = ++RpcId;
+			int rpcId = ++RpcId;
 			var tcs = new TaskCompletionSource<IResponse>();
 
-			OpcodeTypeComponent opcodeTypeComponent = this.Network.Entity.GetComponent<OpcodeTypeComponent>();
-			ushort opcode = opcodeTypeComponent.GetOpcode(request.GetType());
-			byte[] bytes = this.Network.MessagePacker.SerializeToByteArray(request);
-
-			this.requestCallback[rpcId] = (packetInfo) =>
+			this.requestCallback[rpcId] = (response) =>
 			{
 				try
 				{
-					if (packetInfo.RpcId != rpcId)
+					if (response.RpcId != rpcId)
 					{
 						return;
 					}
-					Type responseType = opcodeTypeComponent.GetType(packetInfo.Opcode);
-					object message = this.Network.MessagePacker.DeserializeFrom(responseType, packetInfo.Bytes, packetInfo.Index, packetInfo.Length);
-					IResponse response = (IResponse)message;
 					if (response.Error > ErrorCode.ERR_Exception)
 					{
 						throw new RpcException(response.Error, response.Message);
@@ -243,129 +222,47 @@ namespace ETModel
 				}
 				catch (Exception e)
 				{
-					tcs.SetException(new Exception($"Rpc Error: {packetInfo.Opcode}", e));
-				}
-			};
-
-			cancellationToken.Register(()=>this.requestCallback.Remove(rpcId));
-
-			const byte flag = 0x80;
-			this.SendMessage(flag, opcode, rpcId, bytes);
-			return tcs.Task;
-		}
-
-		public Task<PacketInfo> Call(ushort opcode, byte[] bytes)
-		{
-			uint rpcId = ++RpcId;
-			var tcs = new TaskCompletionSource<PacketInfo>();
-			this.requestCallback[rpcId] = (packetInfo) =>
-			{
-				try
-				{
-					if (packetInfo.RpcId != rpcId)
-					{
-						return;
-					}
-					// 抛到外层不能再使用之前的byte[],因为那是Packet所有的,为了减少gc一直传到这个位置
-					byte[] newBytes = new byte[packetInfo.Length + packetInfo.Index];
-					Array.Copy(packetInfo.Bytes, 0, newBytes, 0, newBytes.Length);
-					packetInfo.Bytes = newBytes;
-					tcs.SetResult(packetInfo);
-				}
-				catch (Exception e)
-				{
-					tcs.SetException(new Exception($"Rpc Error: {opcode}", e));
-				}
-			};
-
-			const byte flag = 0x80;
-			this.SendMessage(flag, opcode, rpcId, bytes);
-			return tcs.Task;
-		}
-
-		public Task<PacketInfo> Call(ushort opcode, byte[] bytes, CancellationToken cancellationToken)
-		{
-			uint rpcId = ++RpcId;
-			var tcs = new TaskCompletionSource<PacketInfo>();
-			this.requestCallback[rpcId] = (packetInfo) =>
-			{
-				try
-				{
-					if (packetInfo.RpcId != rpcId)
-					{
-						return;
-					}
-					// 抛到外层不能再使用之前的byte[],因为那是Packet所有的,为了减少gc一直传到这个位置
-					byte[] newBytes = new byte[packetInfo.Length + packetInfo.Index];
-					Array.Copy(packetInfo.Bytes, 0, newBytes, 0, newBytes.Length);
-					packetInfo.Bytes = newBytes;
-					tcs.SetResult(packetInfo);
-				}
-				catch (Exception e)
-				{
-					tcs.SetException(new Exception($"Rpc Error: {opcode}", e));
+					tcs.SetException(new Exception($"Rpc Error: {request.GetType().FullName}", e));
 				}
 			};
 
-			cancellationToken.Register(() => { this.requestCallback.Remove(rpcId); });
+			cancellationToken.Register(() => this.requestCallback.Remove(rpcId));
 
-			const byte flag = 0x80;
-			this.SendMessage(flag, opcode, rpcId, bytes);
+			request.RpcId = rpcId;
+			this.Send(0x00, request);
 			return tcs.Task;
 		}
 
 		public void Send(IMessage message)
 		{
-			OpcodeTypeComponent opcodeTypeComponent = Game.Scene.GetComponent<OpcodeTypeComponent>();
-			ushort opcode = opcodeTypeComponent.GetOpcode(message.GetType());
-			byte[] bytes = this.Network.MessagePacker.SerializeToByteArray(message);
-			this.Send(opcode, bytes);
+			this.Send(0x00, message);
 		}
 
-		public void Reply(uint rpcId, IResponse message)
+		public void Reply(IResponse message)
 		{
 			if (this.IsDisposed)
 			{
 				throw new Exception("session已经被Dispose了");
 			}
-			OpcodeTypeComponent opcodeTypeComponent = Game.Scene.GetComponent<OpcodeTypeComponent>();
-			ushort opcode = opcodeTypeComponent.GetOpcode(message.GetType());
-			byte[] bytes = this.Network.MessagePacker.SerializeToByteArray(message);
-			const byte flag = 0x40;
-			this.SendMessage(flag, opcode, rpcId, bytes);
+
+			this.Send(0x01, message);
 		}
 
-		public void Send(ushort opcode, byte[] bytes)
+		private void Send(byte flag, object message)
 		{
-			if (this.IsDisposed)
-			{
-				throw new Exception("session已经被Dispose了");
-			}
-			const byte flag = 0x00;
-			this.SendMessage(flag, opcode, 0, bytes);
+			OpcodeTypeComponent opcodeTypeComponent = this.Network.Entity.GetComponent<OpcodeTypeComponent>();
+			ushort opcode = opcodeTypeComponent.GetOpcode(message.GetType());
+			byte[] bytes = this.Network.MessagePacker.SerializeToByteArray(message);
+
+			Send(flag, opcode, bytes);
 		}
 
-		private void SendMessage(byte flag, ushort opcode, uint rpcId, byte[] bytes)
+		public void Send(byte flag, ushort opcode, byte[] bytes)
 		{
-			this.flagBytes[0] = flag;
+			this.byteses[0][0] = flag;
+			this.byteses[1] = BitConverter.GetBytes(opcode);
+			this.byteses[2] = bytes;
 
-			List<byte[]> bb;
-			if (rpcId == 0)
-			{
-				bb = this.byteses;
-				bb[0] = flagBytes;
-				bb[1] = BitConverter.GetBytes(opcode);
-				bb[2] = bytes;
-			}
-			else
-			{
-				bb = this.rpcByteses;
-				bb[0] = flagBytes;
-				bb[1] = BitConverter.GetBytes(opcode);
-				bb[2] = BitConverter.GetBytes(rpcId);
-				bb[3] = bytes;
-			}
-			
 #if SERVER
 			// 如果是allserver,内部消息不走网络,直接转给session,方便调试时看到整体堆栈
 			if (this.Network.AppType == AppType.AllServer)
@@ -373,7 +270,7 @@ namespace ETModel
 				Session session = this.Network.Entity.GetComponent<NetInnerComponent>().Get(this.RemoteAddress);
 				this.pkt.Length = 0;
 				ushort index = 0;
-				foreach (var byts in bb)
+				foreach (var byts in byteses)
 				{
 					Array.Copy(byts, 0, this.pkt.Bytes, index, byts.Length);
 					index += (ushort)byts.Length;
@@ -385,7 +282,7 @@ namespace ETModel
 			}
 #endif
 
-			channel.Send(bb);
+			channel.Send(this.byteses);
 		}
 
 #if SERVER

+ 10 - 0
Unity/Assets/Scripts/Module/Message/SessionCallbackComponent.cs

@@ -0,0 +1,10 @@
+using System;
+
+namespace ETModel
+{
+	public class SessionCallbackComponent: Component
+	{
+		public Action<Session, Packet> MessageCallback;
+		public Action<Session> DisposeCallback;
+	}
+}

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_PacketInfo_Binding.cs.meta → Unity/Assets/Scripts/Module/Message/SessionCallbackComponent.cs.meta

@@ -1,6 +1,6 @@
 fileFormatVersion: 2
-guid: 0e17ff631a8570d4fad045e98481e4a1
-timeCreated: 1520320313
+guid: f148d20817f02a344bf014defe49c562
+timeCreated: 1520649451
 licenseType: Free
 MonoImporter:
   serializedVersion: 2

+ 9 - 8
Unity/Assets/ThirdParty/ILRuntime/Generated/CLRBindings.cs

@@ -57,9 +57,6 @@ namespace ILRuntime.Runtime.Generated
             ETModel_GameObjectHelper_Binding.Register(app);
             UnityEngine_TextAsset_Binding.Register(app);
             UnityEngine_Resources_Binding.Register(app);
-            ETModel_PacketInfo_Binding.Register(app);
-            ETModel_ProtobufHelper_Binding.Register(app);
-            ETModel_MessageInfo_Binding.Register(app);
             System_Collections_Generic_HashSet_1_ILTypeInstance_Binding.Register(app);
             System_Linq_Enumerable_Binding.Register(app);
             System_Collections_Generic_HashSet_1_ILTypeInstance_Binding_Enumerator_Binding.Register(app);
@@ -74,6 +71,14 @@ namespace ILRuntime.Runtime.Generated
             ETModel_EventProxy_Binding.Register(app);
             ETModel_EventSystem_Binding.Register(app);
             System_Collections_Generic_Dictionary_2_Type_Queue_1_ILTypeInstance_Binding.Register(app);
+            ETModel_Packet_Binding.Register(app);
+            ETModel_ProtobufHelper_Binding.Register(app);
+            System_Collections_Generic_Dictionary_2_Int32_Action_1_ILTypeInstance_Binding.Register(app);
+            ETModel_MessageInfo_Binding.Register(app);
+            System_Threading_Tasks_TaskCompletionSource_1_ILTypeInstance_Binding.Register(app);
+            System_Threading_CancellationToken_Binding.Register(app);
+            ETModel_SessionCallbackComponent_Binding.Register(app);
+            ETModel_RpcException_Binding.Register(app);
             System_Collections_Generic_Dictionary_2_UInt16_List_1_ILTypeInstance_Binding.Register(app);
             ETModel_OpcodeTypeComponent_Binding.Register(app);
             ETModel_MessageProxy_Binding.Register(app);
@@ -89,15 +94,10 @@ namespace ILRuntime.Runtime.Generated
             System_Collections_Generic_List_1_String_Binding.Register(app);
             ETModel_Disposer_Binding.Register(app);
             ETModel_Scene_Binding.Register(app);
-            System_Runtime_CompilerServices_AsyncTaskMethodBuilder_1_ILTypeInstance_Binding.Register(app);
-            System_Threading_Tasks_Task_1_PacketInfo_Binding.Register(app);
-            System_Runtime_CompilerServices_TaskAwaiter_1_PacketInfo_Binding.Register(app);
             UnityEngine_Object_Binding.Register(app);
             System_Collections_Generic_Dictionary_2_String_ILTypeInstance_Binding_ValueCollection_Binding.Register(app);
             System_Collections_Generic_Dictionary_2_String_ILTypeInstance_Binding_ValueCollection_Binding_Enumerator_Binding.Register(app);
             UnityEngine_Component_Binding.Register(app);
-            ETModel_ClientDispatcher_Binding.Register(app);
-            ETModel_NetworkComponent_Binding.Register(app);
             ReferenceCollector_Binding.Register(app);
             UnityEngine_UI_Button_Binding.Register(app);
             ETModel_ActionHelper_Binding.Register(app);
@@ -110,6 +110,7 @@ namespace ILRuntime.Runtime.Generated
             ETModel_GlobalProto_Binding.Register(app);
             ETModel_NetworkHelper_Binding.Register(app);
             UnityEngine_UI_InputField_Binding.Register(app);
+            ETModel_NetworkComponent_Binding.Register(app);
             ETModel_ComponentFactory_Binding.Register(app);
             System_Collections_Generic_Dictionary_2_Int64_ILTypeInstance_Binding.Register(app);
         }

+ 44 - 10
Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_Entity_Binding.cs

@@ -92,6 +92,20 @@ namespace ILRuntime.Runtime.Generated
                     }
                 }
             }
+            args = new Type[]{typeof(ETModel.SessionCallbackComponent)};
+            if (genericMethods.TryGetValue("AddComponent", out lst))
+            {
+                foreach(var m in lst)
+                {
+                    if(m.GetParameters().Length == 0)
+                    {
+                        method = m.MakeGenericMethod(args);
+                        app.RegisterCLRMethodRedirection(method, AddComponent_4);
+
+                        break;
+                    }
+                }
+            }
             args = new Type[]{typeof(ETModel.MessageDispatherComponent)};
             if (genericMethods.TryGetValue("GetComponent", out lst))
             {
@@ -100,7 +114,7 @@ namespace ILRuntime.Runtime.Generated
                     if(m.GetParameters().Length == 0)
                     {
                         method = m.MakeGenericMethod(args);
-                        app.RegisterCLRMethodRedirection(method, GetComponent_4);
+                        app.RegisterCLRMethodRedirection(method, GetComponent_5);
 
                         break;
                     }
@@ -114,7 +128,7 @@ namespace ILRuntime.Runtime.Generated
                     if(m.GetParameters().Length == 0)
                     {
                         method = m.MakeGenericMethod(args);
-                        app.RegisterCLRMethodRedirection(method, GetComponent_5);
+                        app.RegisterCLRMethodRedirection(method, GetComponent_6);
 
                         break;
                     }
@@ -128,7 +142,7 @@ namespace ILRuntime.Runtime.Generated
                     if(m.GetParameters().Length == 0)
                     {
                         method = m.MakeGenericMethod(args);
-                        app.RegisterCLRMethodRedirection(method, GetComponent_6);
+                        app.RegisterCLRMethodRedirection(method, GetComponent_7);
 
                         break;
                     }
@@ -142,7 +156,7 @@ namespace ILRuntime.Runtime.Generated
                     if(m.GetParameters().Length == 0)
                     {
                         method = m.MakeGenericMethod(args);
-                        app.RegisterCLRMethodRedirection(method, AddComponent_7);
+                        app.RegisterCLRMethodRedirection(method, AddComponent_8);
 
                         break;
                     }
@@ -156,7 +170,7 @@ namespace ILRuntime.Runtime.Generated
                     if(m.GetParameters().Length == 0)
                     {
                         method = m.MakeGenericMethod(args);
-                        app.RegisterCLRMethodRedirection(method, GetComponent_8);
+                        app.RegisterCLRMethodRedirection(method, GetComponent_9);
 
                         break;
                     }
@@ -247,7 +261,7 @@ namespace ILRuntime.Runtime.Generated
             return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
         }
 
-        static StackObject* GetComponent_4(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        static StackObject* AddComponent_4(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
         {
             ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
             StackObject* ptr_of_this_method;
@@ -257,7 +271,7 @@ namespace ILRuntime.Runtime.Generated
             instance_of_this_method = (ETModel.Entity)typeof(ETModel.Entity).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
             __intp.Free(ptr_of_this_method);
 
-            var result_of_this_method = instance_of_this_method.GetComponent<ETModel.MessageDispatherComponent>();
+            var result_of_this_method = instance_of_this_method.AddComponent<ETModel.SessionCallbackComponent>();
 
             object obj_result_of_this_method = result_of_this_method;
             if(obj_result_of_this_method is CrossBindingAdaptorType)
@@ -277,7 +291,7 @@ namespace ILRuntime.Runtime.Generated
             instance_of_this_method = (ETModel.Entity)typeof(ETModel.Entity).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
             __intp.Free(ptr_of_this_method);
 
-            var result_of_this_method = instance_of_this_method.GetComponent<ETModel.OpcodeTypeComponent>();
+            var result_of_this_method = instance_of_this_method.GetComponent<ETModel.MessageDispatherComponent>();
 
             object obj_result_of_this_method = result_of_this_method;
             if(obj_result_of_this_method is CrossBindingAdaptorType)
@@ -297,6 +311,26 @@ namespace ILRuntime.Runtime.Generated
             instance_of_this_method = (ETModel.Entity)typeof(ETModel.Entity).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
             __intp.Free(ptr_of_this_method);
 
+            var result_of_this_method = instance_of_this_method.GetComponent<ETModel.OpcodeTypeComponent>();
+
+            object obj_result_of_this_method = result_of_this_method;
+            if(obj_result_of_this_method is CrossBindingAdaptorType)
+            {    
+                return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance);
+            }
+            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
+        }
+
+        static StackObject* GetComponent_7(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* ptr_of_this_method;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 1);
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
+            ETModel.Entity instance_of_this_method;
+            instance_of_this_method = (ETModel.Entity)typeof(ETModel.Entity).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            __intp.Free(ptr_of_this_method);
+
             var result_of_this_method = instance_of_this_method.GetComponent<ETModel.NetOuterComponent>();
 
             object obj_result_of_this_method = result_of_this_method;
@@ -307,7 +341,7 @@ namespace ILRuntime.Runtime.Generated
             return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
         }
 
-        static StackObject* AddComponent_7(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        static StackObject* AddComponent_8(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
         {
             ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
             StackObject* ptr_of_this_method;
@@ -327,7 +361,7 @@ namespace ILRuntime.Runtime.Generated
             return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
         }
 
-        static StackObject* GetComponent_8(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        static StackObject* GetComponent_9(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
         {
             ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
             StackObject* ptr_of_this_method;

+ 3 - 27
Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_MessageInfo_Binding.cs

@@ -28,13 +28,10 @@ namespace ILRuntime.Runtime.Generated
             args = new Type[]{};
             method = type.GetMethod("get_Message", flag, null, args, null);
             app.RegisterCLRMethodRedirection(method, get_Message_1);
-            args = new Type[]{};
-            method = type.GetMethod("get_RpcId", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, get_RpcId_2);
 
             app.RegisterCLRCreateDefaultInstance(type, () => new ETModel.MessageInfo());
 
-            args = new Type[]{typeof(System.UInt32), typeof(System.UInt16), typeof(System.Object)};
+            args = new Type[]{typeof(System.UInt16), typeof(System.Object)};
             method = type.GetConstructor(flag, null, args, null);
             app.RegisterCLRMethodRedirection(method, Ctor_0);
 
@@ -127,40 +124,19 @@ namespace ILRuntime.Runtime.Generated
             return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method, true);
         }
 
-        static StackObject* get_RpcId_2(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
-        {
-            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
-            StackObject* ptr_of_this_method;
-            StackObject* __ret = ILIntepreter.Minus(__esp, 1);
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
-            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
-            ETModel.MessageInfo instance_of_this_method;
-            instance_of_this_method = (ETModel.MessageInfo)typeof(ETModel.MessageInfo).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
-
-            var result_of_this_method = instance_of_this_method.RpcId;
-
-            WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method);
-
-            __ret->ObjectType = ObjectTypes.Integer;
-            __ret->Value = (int)result_of_this_method;
-            return __ret + 1;
-        }
-
 
         static StackObject* Ctor_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
         {
             ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
             StackObject* ptr_of_this_method;
-            StackObject* __ret = ILIntepreter.Minus(__esp, 3);
+            StackObject* __ret = ILIntepreter.Minus(__esp, 2);
             ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
             System.Object message = (System.Object)typeof(System.Object).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
             __intp.Free(ptr_of_this_method);
             ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
             System.UInt16 opcode = (ushort)ptr_of_this_method->Value;
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
-            System.UInt32 rpcId = (uint)ptr_of_this_method->Value;
 
-            var result_of_this_method = new ETModel.MessageInfo(rpcId, opcode, message);
+            var result_of_this_method = new ETModel.MessageInfo(opcode, message);
 
             if(!isNewObj)
             {

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_MessageProxy_Binding.cs

@@ -23,7 +23,7 @@ namespace ILRuntime.Runtime.Generated
             Type[] args;
             Type type = typeof(ETModel.MessageProxy);
 
-            args = new Type[]{typeof(System.Type), typeof(System.Action<ETModel.Session, System.UInt32, System.Object>)};
+            args = new Type[]{typeof(System.Type), typeof(System.Action<ETModel.Session, System.Object>)};
             method = type.GetConstructor(flag, null, args, null);
             app.RegisterCLRMethodRedirection(method, Ctor_0);
 
@@ -37,7 +37,7 @@ namespace ILRuntime.Runtime.Generated
             StackObject* ptr_of_this_method;
             StackObject* __ret = ILIntepreter.Minus(__esp, 2);
             ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
-            System.Action<ETModel.Session, System.UInt32, System.Object> action = (System.Action<ETModel.Session, System.UInt32, System.Object>)typeof(System.Action<ETModel.Session, System.UInt32, System.Object>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            System.Action<ETModel.Session, System.Object> action = (System.Action<ETModel.Session, System.Object>)typeof(System.Action<ETModel.Session, System.Object>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
             __intp.Free(ptr_of_this_method);
             ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
             System.Type type = (System.Type)typeof(System.Type).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));

+ 2 - 23
Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_NetworkComponent_Binding.cs

@@ -22,36 +22,15 @@ namespace ILRuntime.Runtime.Generated
             FieldInfo field;
             Type[] args;
             Type type = typeof(ETModel.NetworkComponent);
-            args = new Type[]{typeof(ETModel.IMessageDispatcher)};
-            method = type.GetMethod("set_MessageDispatcher", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, set_MessageDispatcher_0);
             args = new Type[]{typeof(System.Net.IPEndPoint)};
             method = type.GetMethod("Create", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, Create_1);
+            app.RegisterCLRMethodRedirection(method, Create_0);
 
 
         }
 
 
-        static StackObject* set_MessageDispatcher_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
-        {
-            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
-            StackObject* ptr_of_this_method;
-            StackObject* __ret = ILIntepreter.Minus(__esp, 2);
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
-            ETModel.IMessageDispatcher value = (ETModel.IMessageDispatcher)typeof(ETModel.IMessageDispatcher).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
-            __intp.Free(ptr_of_this_method);
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
-            ETModel.NetworkComponent instance_of_this_method;
-            instance_of_this_method = (ETModel.NetworkComponent)typeof(ETModel.NetworkComponent).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
-            __intp.Free(ptr_of_this_method);
-
-            instance_of_this_method.MessageDispatcher = value;
-
-            return __ret;
-        }
-
-        static StackObject* Create_1(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        static StackObject* Create_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
         {
             ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
             StackObject* ptr_of_this_method;

+ 62 - 18
Unity/Assets/ThirdParty/ILRuntime/Generated/System_Runtime_CompilerServices_TaskAwaiter_1_PacketInfo_Bindi_t.cs → Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_Packet_Binding.cs

@@ -13,7 +13,7 @@ using ILRuntime.CLR.Utils;
 
 namespace ILRuntime.Runtime.Generated
 {
-    unsafe class System_Runtime_CompilerServices_TaskAwaiter_1_PacketInfo_Binding
+    unsafe class ETModel_Packet_Binding
     {
         public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
         {
@@ -21,20 +21,26 @@ namespace ILRuntime.Runtime.Generated
             MethodBase method;
             FieldInfo field;
             Type[] args;
-            Type type = typeof(System.Runtime.CompilerServices.TaskAwaiter<ETModel.PacketInfo>);
+            Type type = typeof(ETModel.Packet);
             args = new Type[]{};
-            method = type.GetMethod("get_IsCompleted", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, get_IsCompleted_0);
+            method = type.GetMethod("Opcode", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, Opcode_0);
             args = new Type[]{};
-            method = type.GetMethod("GetResult", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, GetResult_1);
+            method = type.GetMethod("Flag", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, Flag_1);
+            args = new Type[]{};
+            method = type.GetMethod("get_Bytes", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, get_Bytes_2);
+            args = new Type[]{};
+            method = type.GetMethod("get_Length", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, get_Length_3);
 
-            app.RegisterCLRCreateDefaultInstance(type, () => new System.Runtime.CompilerServices.TaskAwaiter<ETModel.PacketInfo>());
+            app.RegisterCLRCreateDefaultInstance(type, () => new ETModel.Packet());
 
 
         }
 
-        static void WriteBackInstance(ILRuntime.Runtime.Enviorment.AppDomain __domain, StackObject* ptr_of_this_method, IList<object> __mStack, ref System.Runtime.CompilerServices.TaskAwaiter<ETModel.PacketInfo> instance_of_this_method)
+        static void WriteBackInstance(ILRuntime.Runtime.Enviorment.AppDomain __domain, StackObject* ptr_of_this_method, IList<object> __mStack, ref ETModel.Packet instance_of_this_method)
         {
             ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
             switch(ptr_of_this_method->ObjectType)
@@ -73,49 +79,87 @@ namespace ILRuntime.Runtime.Generated
                     break;
                  case ObjectTypes.ArrayReference:
                     {
-                        var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as System.Runtime.CompilerServices.TaskAwaiter<ETModel.PacketInfo>[];
+                        var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as ETModel.Packet[];
                         instance_of_arrayReference[ptr_of_this_method->ValueLow] = instance_of_this_method;
                     }
                     break;
             }
         }
 
-        static StackObject* get_IsCompleted_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        static StackObject* Opcode_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* ptr_of_this_method;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 1);
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
+            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
+            ETModel.Packet instance_of_this_method;
+            instance_of_this_method = (ETModel.Packet)typeof(ETModel.Packet).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+
+            var result_of_this_method = instance_of_this_method.Opcode();
+
+            WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method);
+
+            __ret->ObjectType = ObjectTypes.Integer;
+            __ret->Value = result_of_this_method;
+            return __ret + 1;
+        }
+
+        static StackObject* Flag_1(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
         {
             ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
             StackObject* ptr_of_this_method;
             StackObject* __ret = ILIntepreter.Minus(__esp, 1);
             ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
             ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
-            System.Runtime.CompilerServices.TaskAwaiter<ETModel.PacketInfo> instance_of_this_method;
-            instance_of_this_method = (System.Runtime.CompilerServices.TaskAwaiter<ETModel.PacketInfo>)typeof(System.Runtime.CompilerServices.TaskAwaiter<ETModel.PacketInfo>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            ETModel.Packet instance_of_this_method;
+            instance_of_this_method = (ETModel.Packet)typeof(ETModel.Packet).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
 
-            var result_of_this_method = instance_of_this_method.IsCompleted;
+            var result_of_this_method = instance_of_this_method.Flag();
 
             WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method);
 
             __ret->ObjectType = ObjectTypes.Integer;
-            __ret->Value = result_of_this_method ? 1 : 0;
+            __ret->Value = result_of_this_method;
             return __ret + 1;
         }
 
-        static StackObject* GetResult_1(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        static StackObject* get_Bytes_2(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
         {
             ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
             StackObject* ptr_of_this_method;
             StackObject* __ret = ILIntepreter.Minus(__esp, 1);
             ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
             ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
-            System.Runtime.CompilerServices.TaskAwaiter<ETModel.PacketInfo> instance_of_this_method;
-            instance_of_this_method = (System.Runtime.CompilerServices.TaskAwaiter<ETModel.PacketInfo>)typeof(System.Runtime.CompilerServices.TaskAwaiter<ETModel.PacketInfo>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            ETModel.Packet instance_of_this_method;
+            instance_of_this_method = (ETModel.Packet)typeof(ETModel.Packet).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
 
-            var result_of_this_method = instance_of_this_method.GetResult();
+            var result_of_this_method = instance_of_this_method.Bytes;
 
             WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method);
 
             return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
         }
 
+        static StackObject* get_Length_3(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* ptr_of_this_method;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 1);
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
+            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
+            ETModel.Packet instance_of_this_method;
+            instance_of_this_method = (ETModel.Packet)typeof(ETModel.Packet).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+
+            var result_of_this_method = instance_of_this_method.Length;
+
+            WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method);
+
+            __ret->ObjectType = ObjectTypes.Integer;
+            __ret->Value = result_of_this_method;
+            return __ret + 1;
+        }
+
 
 
     }

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/Generated/System_Runtime_CompilerServices_AsyncTaskMethodBuilder_1_ILTyp_t.cs.meta → Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_Packet_Binding.cs.meta

@@ -1,6 +1,6 @@
 fileFormatVersion: 2
-guid: 80cf86caaad25fb418839542578aa1a2
-timeCreated: 1520320313
+guid: c96eeaaada013544792cfb67cd1cb56a
+timeCreated: 1520653067
 licenseType: Free
 MonoImporter:
   serializedVersion: 2

+ 11 - 19
Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_ClientDispatcher_Binding.cs → Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_RpcException_Binding.cs

@@ -13,7 +13,7 @@ using ILRuntime.CLR.Utils;
 
 namespace ILRuntime.Runtime.Generated
 {
-    unsafe class ETModel_ClientDispatcher_Binding
+    unsafe class ETModel_RpcException_Binding
     {
         public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
         {
@@ -21,13 +21,9 @@ namespace ILRuntime.Runtime.Generated
             MethodBase method;
             FieldInfo field;
             Type[] args;
-            Type type = typeof(ETModel.ClientDispatcher);
+            Type type = typeof(ETModel.RpcException);
 
-            field = type.GetField("HotfixCallback", flag);
-            app.RegisterCLRFieldGetter(field, get_HotfixCallback_0);
-            app.RegisterCLRFieldSetter(field, set_HotfixCallback_0);
-
-            args = new Type[]{};
+            args = new Type[]{typeof(System.Int32), typeof(System.String)};
             method = type.GetConstructor(flag, null, args, null);
             app.RegisterCLRMethodRedirection(method, Ctor_0);
 
@@ -35,22 +31,18 @@ namespace ILRuntime.Runtime.Generated
 
 
 
-        static object get_HotfixCallback_0(ref object o)
-        {
-            return ((ETModel.ClientDispatcher)o).HotfixCallback;
-        }
-        static void set_HotfixCallback_0(ref object o, object v)
-        {
-            ((ETModel.ClientDispatcher)o).HotfixCallback = (System.Action<ETModel.Session, ETModel.PacketInfo>)v;
-        }
-
         static StackObject* Ctor_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
         {
             ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
             StackObject* ptr_of_this_method;
-            StackObject* __ret = ILIntepreter.Minus(__esp, 0);
-
-            var result_of_this_method = new ETModel.ClientDispatcher();
+            StackObject* __ret = ILIntepreter.Minus(__esp, 2);
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
+            System.String message = (System.String)typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            __intp.Free(ptr_of_this_method);
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
+            System.Int32 error = ptr_of_this_method->Value;
+
+            var result_of_this_method = new ETModel.RpcException(error, message);
 
             return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
         }

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_ClientDispatcher_Binding.cs.meta → Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_RpcException_Binding.cs.meta

@@ -1,6 +1,6 @@
 fileFormatVersion: 2
-guid: 1f317128d11eedf47bdbdcba1419657c
-timeCreated: 1520320313
+guid: 19c2ef3fd2c8c7f44981cb6d0345cce1
+timeCreated: 1520653067
 licenseType: Free
 MonoImporter:
   serializedVersion: 2

+ 57 - 0
Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_SessionCallbackComponent_Binding.cs

@@ -0,0 +1,57 @@
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+using ILRuntime.CLR.TypeSystem;
+using ILRuntime.CLR.Method;
+using ILRuntime.Runtime.Enviorment;
+using ILRuntime.Runtime.Intepreter;
+using ILRuntime.Runtime.Stack;
+using ILRuntime.Reflection;
+using ILRuntime.CLR.Utils;
+
+namespace ILRuntime.Runtime.Generated
+{
+    unsafe class ETModel_SessionCallbackComponent_Binding
+    {
+        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
+        {
+            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
+            MethodBase method;
+            FieldInfo field;
+            Type[] args;
+            Type type = typeof(ETModel.SessionCallbackComponent);
+
+            field = type.GetField("MessageCallback", flag);
+            app.RegisterCLRFieldGetter(field, get_MessageCallback_0);
+            app.RegisterCLRFieldSetter(field, set_MessageCallback_0);
+            field = type.GetField("DisposeCallback", flag);
+            app.RegisterCLRFieldGetter(field, get_DisposeCallback_1);
+            app.RegisterCLRFieldSetter(field, set_DisposeCallback_1);
+
+
+        }
+
+
+
+        static object get_MessageCallback_0(ref object o)
+        {
+            return ((ETModel.SessionCallbackComponent)o).MessageCallback;
+        }
+        static void set_MessageCallback_0(ref object o, object v)
+        {
+            ((ETModel.SessionCallbackComponent)o).MessageCallback = (System.Action<ETModel.Session, ETModel.Packet>)v;
+        }
+        static object get_DisposeCallback_1(ref object o)
+        {
+            return ((ETModel.SessionCallbackComponent)o).DisposeCallback;
+        }
+        static void set_DisposeCallback_1(ref object o, object v)
+        {
+            ((ETModel.SessionCallbackComponent)o).DisposeCallback = (System.Action<ETModel.Session>)v;
+        }
+
+
+    }
+}

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/Generated/System_Runtime_CompilerServices_TaskAwaiter_1_PacketInfo_Bindi_t.cs.meta → Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_SessionCallbackComponent_Binding.cs.meta

@@ -1,6 +1,6 @@
 fileFormatVersion: 2
-guid: 4aa2bfbc28de3184b925b144a76e9e25
-timeCreated: 1520320313
+guid: 9ae8ef32a39e0c8479510fe8bf4fe205
+timeCreated: 1520653067
 licenseType: Free
 MonoImporter:
   serializedVersion: 2

+ 6 - 32
Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_Session_Binding.cs

@@ -25,15 +25,12 @@ namespace ILRuntime.Runtime.Generated
             args = new Type[]{typeof(ETModel.IMessage)};
             method = type.GetMethod("Send", flag, null, args, null);
             app.RegisterCLRMethodRedirection(method, Send_0);
-            args = new Type[]{typeof(System.UInt16), typeof(System.Byte[])};
+            args = new Type[]{typeof(System.Byte), typeof(System.UInt16), typeof(System.Byte[])};
             method = type.GetMethod("Send", flag, null, args, null);
             app.RegisterCLRMethodRedirection(method, Send_1);
-            args = new Type[]{typeof(System.UInt16), typeof(System.Byte[])};
-            method = type.GetMethod("Call", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, Call_2);
             args = new Type[]{typeof(ETModel.IRequest)};
             method = type.GetMethod("Call", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, Call_3);
+            app.RegisterCLRMethodRedirection(method, Call_2);
 
 
         }
@@ -61,48 +58,25 @@ namespace ILRuntime.Runtime.Generated
         {
             ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
             StackObject* ptr_of_this_method;
-            StackObject* __ret = ILIntepreter.Minus(__esp, 3);
+            StackObject* __ret = ILIntepreter.Minus(__esp, 4);
             ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
             System.Byte[] bytes = (System.Byte[])typeof(System.Byte[]).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
             __intp.Free(ptr_of_this_method);
             ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
             System.UInt16 opcode = (ushort)ptr_of_this_method->Value;
             ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
+            System.Byte flag = (byte)ptr_of_this_method->Value;
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 4);
             ETModel.Session instance_of_this_method;
             instance_of_this_method = (ETModel.Session)typeof(ETModel.Session).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
             __intp.Free(ptr_of_this_method);
 
-            instance_of_this_method.Send(opcode, bytes);
+            instance_of_this_method.Send(flag, opcode, bytes);
 
             return __ret;
         }
 
         static StackObject* Call_2(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
-        {
-            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
-            StackObject* ptr_of_this_method;
-            StackObject* __ret = ILIntepreter.Minus(__esp, 3);
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
-            System.Byte[] bytes = (System.Byte[])typeof(System.Byte[]).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
-            __intp.Free(ptr_of_this_method);
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
-            System.UInt16 opcode = (ushort)ptr_of_this_method->Value;
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
-            ETModel.Session instance_of_this_method;
-            instance_of_this_method = (ETModel.Session)typeof(ETModel.Session).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
-            __intp.Free(ptr_of_this_method);
-
-            var result_of_this_method = instance_of_this_method.Call(opcode, bytes);
-
-            object obj_result_of_this_method = result_of_this_method;
-            if(obj_result_of_this_method is CrossBindingAdaptorType)
-            {    
-                return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance);
-            }
-            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
-        }
-
-        static StackObject* Call_3(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
         {
             ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
             StackObject* ptr_of_this_method;

+ 171 - 0
Unity/Assets/ThirdParty/ILRuntime/Generated/System_Collections_Generic_Dictionary_2_Int32_Action_1_ILTypeI_t.cs

@@ -0,0 +1,171 @@
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+using ILRuntime.CLR.TypeSystem;
+using ILRuntime.CLR.Method;
+using ILRuntime.Runtime.Enviorment;
+using ILRuntime.Runtime.Intepreter;
+using ILRuntime.Runtime.Stack;
+using ILRuntime.Reflection;
+using ILRuntime.CLR.Utils;
+
+namespace ILRuntime.Runtime.Generated
+{
+    unsafe class System_Collections_Generic_Dictionary_2_Int32_Action_1_ILTypeInstance_Binding
+    {
+        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
+        {
+            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
+            MethodBase method;
+            FieldInfo field;
+            Type[] args;
+            Type type = typeof(System.Collections.Generic.Dictionary<System.Int32, System.Action<ILRuntime.Runtime.Intepreter.ILTypeInstance>>);
+            args = new Type[]{typeof(System.Int32), typeof(System.Action<ILRuntime.Runtime.Intepreter.ILTypeInstance>).MakeByRefType()};
+            method = type.GetMethod("TryGetValue", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, TryGetValue_0);
+            args = new Type[]{typeof(System.Int32)};
+            method = type.GetMethod("Remove", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, Remove_1);
+            args = new Type[]{typeof(System.Int32), typeof(System.Action<ILRuntime.Runtime.Intepreter.ILTypeInstance>)};
+            method = type.GetMethod("set_Item", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, set_Item_2);
+
+            args = new Type[]{};
+            method = type.GetConstructor(flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, Ctor_0);
+
+        }
+
+
+        static StackObject* TryGetValue_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* ptr_of_this_method;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 3);
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
+            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
+            System.Action<ILRuntime.Runtime.Intepreter.ILTypeInstance> value = (System.Action<ILRuntime.Runtime.Intepreter.ILTypeInstance>)typeof(System.Action<ILRuntime.Runtime.Intepreter.ILTypeInstance>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
+            System.Int32 key = ptr_of_this_method->Value;
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
+            System.Collections.Generic.Dictionary<System.Int32, System.Action<ILRuntime.Runtime.Intepreter.ILTypeInstance>> instance_of_this_method;
+            instance_of_this_method = (System.Collections.Generic.Dictionary<System.Int32, System.Action<ILRuntime.Runtime.Intepreter.ILTypeInstance>>)typeof(System.Collections.Generic.Dictionary<System.Int32, System.Action<ILRuntime.Runtime.Intepreter.ILTypeInstance>>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            __intp.Free(ptr_of_this_method);
+
+            var result_of_this_method = instance_of_this_method.TryGetValue(key, out value);
+
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
+            switch(ptr_of_this_method->ObjectType)
+            {
+                case ObjectTypes.StackObjectReference:
+                    {
+                        var ___dst = *(StackObject**)&ptr_of_this_method->Value;
+                        object ___obj = value;
+                        if (___dst->ObjectType >= ObjectTypes.Object)
+                        {
+                            if (___obj is CrossBindingAdaptorType)
+                                ___obj = ((CrossBindingAdaptorType)___obj).ILInstance;
+                            __mStack[___dst->Value] = ___obj;
+                        }
+                        else
+                        {
+                            ILIntepreter.UnboxObject(___dst, ___obj, __mStack, __domain);
+                        }
+                    }
+                    break;
+                case ObjectTypes.FieldReference:
+                    {
+                        var ___obj = __mStack[ptr_of_this_method->Value];
+                        if(___obj is ILTypeInstance)
+                        {
+                            ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = value;
+                        }
+                        else
+                        {
+                            var ___type = __domain.GetType(___obj.GetType()) as CLRType;
+                            ___type.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, value);
+                        }
+                    }
+                    break;
+                case ObjectTypes.StaticFieldReference:
+                    {
+                        var ___type = __domain.GetType(ptr_of_this_method->Value);
+                        if(___type is ILType)
+                        {
+                            ((ILType)___type).StaticInstance[ptr_of_this_method->ValueLow] = value;
+                        }
+                        else
+                        {
+                            ((CLRType)___type).SetStaticFieldValue(ptr_of_this_method->ValueLow, value);
+                        }
+                    }
+                    break;
+                 case ObjectTypes.ArrayReference:
+                    {
+                        var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as System.Action<ILRuntime.Runtime.Intepreter.ILTypeInstance>[];
+                        instance_of_arrayReference[ptr_of_this_method->ValueLow] = value;
+                    }
+                    break;
+            }
+
+            __ret->ObjectType = ObjectTypes.Integer;
+            __ret->Value = result_of_this_method ? 1 : 0;
+            return __ret + 1;
+        }
+
+        static StackObject* Remove_1(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* ptr_of_this_method;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 2);
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
+            System.Int32 key = ptr_of_this_method->Value;
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
+            System.Collections.Generic.Dictionary<System.Int32, System.Action<ILRuntime.Runtime.Intepreter.ILTypeInstance>> instance_of_this_method;
+            instance_of_this_method = (System.Collections.Generic.Dictionary<System.Int32, System.Action<ILRuntime.Runtime.Intepreter.ILTypeInstance>>)typeof(System.Collections.Generic.Dictionary<System.Int32, System.Action<ILRuntime.Runtime.Intepreter.ILTypeInstance>>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            __intp.Free(ptr_of_this_method);
+
+            var result_of_this_method = instance_of_this_method.Remove(key);
+
+            __ret->ObjectType = ObjectTypes.Integer;
+            __ret->Value = result_of_this_method ? 1 : 0;
+            return __ret + 1;
+        }
+
+        static StackObject* set_Item_2(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* ptr_of_this_method;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 3);
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
+            System.Action<ILRuntime.Runtime.Intepreter.ILTypeInstance> value = (System.Action<ILRuntime.Runtime.Intepreter.ILTypeInstance>)typeof(System.Action<ILRuntime.Runtime.Intepreter.ILTypeInstance>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            __intp.Free(ptr_of_this_method);
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
+            System.Int32 key = ptr_of_this_method->Value;
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
+            System.Collections.Generic.Dictionary<System.Int32, System.Action<ILRuntime.Runtime.Intepreter.ILTypeInstance>> instance_of_this_method;
+            instance_of_this_method = (System.Collections.Generic.Dictionary<System.Int32, System.Action<ILRuntime.Runtime.Intepreter.ILTypeInstance>>)typeof(System.Collections.Generic.Dictionary<System.Int32, System.Action<ILRuntime.Runtime.Intepreter.ILTypeInstance>>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            __intp.Free(ptr_of_this_method);
+
+            instance_of_this_method[key] = value;
+
+            return __ret;
+        }
+
+
+        static StackObject* Ctor_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* ptr_of_this_method;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 0);
+
+            var result_of_this_method = new System.Collections.Generic.Dictionary<System.Int32, System.Action<ILRuntime.Runtime.Intepreter.ILTypeInstance>>();
+
+            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
+        }
+
+
+    }
+}

+ 12 - 0
Unity/Assets/ThirdParty/ILRuntime/Generated/System_Collections_Generic_Dictionary_2_Int32_Action_1_ILTypeI_t.cs.meta

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

+ 0 - 435
Unity/Assets/ThirdParty/ILRuntime/Generated/System_Runtime_CompilerServices_AsyncTaskMethodBuilder_1_ILTyp_t.cs

@@ -1,435 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-using ILRuntime.CLR.TypeSystem;
-using ILRuntime.CLR.Method;
-using ILRuntime.Runtime.Enviorment;
-using ILRuntime.Runtime.Intepreter;
-using ILRuntime.Runtime.Stack;
-using ILRuntime.Reflection;
-using ILRuntime.CLR.Utils;
-
-namespace ILRuntime.Runtime.Generated
-{
-    unsafe class System_Runtime_CompilerServices_AsyncTaskMethodBuilder_1_ILTypeInstance_Binding
-    {
-        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
-        {
-            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
-            MethodBase method;
-            FieldInfo field;
-            Type[] args;
-            Type type = typeof(System.Runtime.CompilerServices.AsyncTaskMethodBuilder<ILRuntime.Runtime.Intepreter.ILTypeInstance>);
-            args = new Type[]{};
-            method = type.GetMethod("Create", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, Create_0);
-            Dictionary<string, List<MethodInfo>> genericMethods = new Dictionary<string, List<MethodInfo>>();
-            List<MethodInfo> lst = null;                    
-            foreach(var m in type.GetMethods())
-            {
-                if(m.IsGenericMethodDefinition)
-                {
-                    if (!genericMethods.TryGetValue(m.Name, out lst))
-                    {
-                        lst = new List<MethodInfo>();
-                        genericMethods[m.Name] = lst;
-                    }
-                    lst.Add(m);
-                }
-            }
-            args = new Type[]{typeof(ETModel.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor)};
-            if (genericMethods.TryGetValue("Start", out lst))
-            {
-                foreach(var m in lst)
-                {
-                    if(m.GetParameters().Length == 1)
-                    {
-                        method = m.MakeGenericMethod(args);
-                        app.RegisterCLRMethodRedirection(method, Start_1);
-
-                        break;
-                    }
-                }
-            }
-            args = new Type[]{};
-            method = type.GetMethod("get_Task", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, get_Task_2);
-            args = new Type[]{typeof(System.Runtime.CompilerServices.TaskAwaiter<ETModel.PacketInfo>), typeof(ETModel.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor)};
-            if (genericMethods.TryGetValue("AwaitUnsafeOnCompleted", out lst))
-            {
-                foreach(var m in lst)
-                {
-                    if(m.GetParameters().Length == 2)
-                    {
-                        method = m.MakeGenericMethod(args);
-                        app.RegisterCLRMethodRedirection(method, AwaitUnsafeOnCompleted_3);
-
-                        break;
-                    }
-                }
-            }
-            args = new Type[]{typeof(System.Exception)};
-            method = type.GetMethod("SetException", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, SetException_4);
-            args = new Type[]{typeof(ILRuntime.Runtime.Intepreter.ILTypeInstance)};
-            method = type.GetMethod("SetResult", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, SetResult_5);
-            args = new Type[]{typeof(System.Runtime.CompilerServices.IAsyncStateMachine)};
-            method = type.GetMethod("SetStateMachine", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, SetStateMachine_6);
-
-            app.RegisterCLRCreateDefaultInstance(type, () => new System.Runtime.CompilerServices.AsyncTaskMethodBuilder<ILRuntime.Runtime.Intepreter.ILTypeInstance>());
-
-
-        }
-
-        static void WriteBackInstance(ILRuntime.Runtime.Enviorment.AppDomain __domain, StackObject* ptr_of_this_method, IList<object> __mStack, ref System.Runtime.CompilerServices.AsyncTaskMethodBuilder<ILRuntime.Runtime.Intepreter.ILTypeInstance> instance_of_this_method)
-        {
-            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
-            switch(ptr_of_this_method->ObjectType)
-            {
-                case ObjectTypes.Object:
-                    {
-                        __mStack[ptr_of_this_method->Value] = instance_of_this_method;
-                    }
-                    break;
-                case ObjectTypes.FieldReference:
-                    {
-                        var ___obj = __mStack[ptr_of_this_method->Value];
-                        if(___obj is ILTypeInstance)
-                        {
-                            ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = instance_of_this_method;
-                        }
-                        else
-                        {
-                            var t = __domain.GetType(___obj.GetType()) as CLRType;
-                            t.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, instance_of_this_method);
-                        }
-                    }
-                    break;
-                case ObjectTypes.StaticFieldReference:
-                    {
-                        var t = __domain.GetType(ptr_of_this_method->Value);
-                        if(t is ILType)
-                        {
-                            ((ILType)t).StaticInstance[ptr_of_this_method->ValueLow] = instance_of_this_method;
-                        }
-                        else
-                        {
-                            ((CLRType)t).SetStaticFieldValue(ptr_of_this_method->ValueLow, instance_of_this_method);
-                        }
-                    }
-                    break;
-                 case ObjectTypes.ArrayReference:
-                    {
-                        var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as System.Runtime.CompilerServices.AsyncTaskMethodBuilder<ILRuntime.Runtime.Intepreter.ILTypeInstance>[];
-                        instance_of_arrayReference[ptr_of_this_method->ValueLow] = instance_of_this_method;
-                    }
-                    break;
-            }
-        }
-
-        static StackObject* Create_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
-        {
-            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
-            StackObject* ptr_of_this_method;
-            StackObject* __ret = ILIntepreter.Minus(__esp, 0);
-
-            var result_of_this_method = System.Runtime.CompilerServices.AsyncTaskMethodBuilder<ILRuntime.Runtime.Intepreter.ILTypeInstance>.Create();
-
-            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
-        }
-
-        static StackObject* Start_1(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
-        {
-            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
-            StackObject* ptr_of_this_method;
-            StackObject* __ret = ILIntepreter.Minus(__esp, 2);
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
-            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
-            ETModel.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor stateMachine = (ETModel.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor)typeof(ETModel.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
-            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
-            System.Runtime.CompilerServices.AsyncTaskMethodBuilder<ILRuntime.Runtime.Intepreter.ILTypeInstance> instance_of_this_method;
-            instance_of_this_method = (System.Runtime.CompilerServices.AsyncTaskMethodBuilder<ILRuntime.Runtime.Intepreter.ILTypeInstance>)typeof(System.Runtime.CompilerServices.AsyncTaskMethodBuilder<ILRuntime.Runtime.Intepreter.ILTypeInstance>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
-
-            instance_of_this_method.Start<ETModel.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor>(ref stateMachine);
-
-            WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method);
-
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
-            switch(ptr_of_this_method->ObjectType)
-            {
-                case ObjectTypes.StackObjectReference:
-                    {
-                        var ___dst = *(StackObject**)&ptr_of_this_method->Value;
-                        object ___obj = stateMachine;
-                        if (___dst->ObjectType >= ObjectTypes.Object)
-                        {
-                            if (___obj is CrossBindingAdaptorType)
-                                ___obj = ((CrossBindingAdaptorType)___obj).ILInstance;
-                            __mStack[___dst->Value] = ___obj;
-                        }
-                        else
-                        {
-                            ILIntepreter.UnboxObject(___dst, ___obj, __mStack, __domain);
-                        }
-                    }
-                    break;
-                case ObjectTypes.FieldReference:
-                    {
-                        var ___obj = __mStack[ptr_of_this_method->Value];
-                        if(___obj is ILTypeInstance)
-                        {
-                            ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = stateMachine;
-                        }
-                        else
-                        {
-                            var ___type = __domain.GetType(___obj.GetType()) as CLRType;
-                            ___type.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, stateMachine);
-                        }
-                    }
-                    break;
-                case ObjectTypes.StaticFieldReference:
-                    {
-                        var ___type = __domain.GetType(ptr_of_this_method->Value);
-                        if(___type is ILType)
-                        {
-                            ((ILType)___type).StaticInstance[ptr_of_this_method->ValueLow] = stateMachine;
-                        }
-                        else
-                        {
-                            ((CLRType)___type).SetStaticFieldValue(ptr_of_this_method->ValueLow, stateMachine);
-                        }
-                    }
-                    break;
-                 case ObjectTypes.ArrayReference:
-                    {
-                        var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as ETModel.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor[];
-                        instance_of_arrayReference[ptr_of_this_method->ValueLow] = stateMachine;
-                    }
-                    break;
-            }
-
-            return __ret;
-        }
-
-        static StackObject* get_Task_2(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
-        {
-            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
-            StackObject* ptr_of_this_method;
-            StackObject* __ret = ILIntepreter.Minus(__esp, 1);
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
-            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
-            System.Runtime.CompilerServices.AsyncTaskMethodBuilder<ILRuntime.Runtime.Intepreter.ILTypeInstance> instance_of_this_method;
-            instance_of_this_method = (System.Runtime.CompilerServices.AsyncTaskMethodBuilder<ILRuntime.Runtime.Intepreter.ILTypeInstance>)typeof(System.Runtime.CompilerServices.AsyncTaskMethodBuilder<ILRuntime.Runtime.Intepreter.ILTypeInstance>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
-
-            var result_of_this_method = instance_of_this_method.Task;
-
-            WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method);
-
-            object obj_result_of_this_method = result_of_this_method;
-            if(obj_result_of_this_method is CrossBindingAdaptorType)
-            {    
-                return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance);
-            }
-            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
-        }
-
-        static StackObject* AwaitUnsafeOnCompleted_3(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
-        {
-            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
-            StackObject* ptr_of_this_method;
-            StackObject* __ret = ILIntepreter.Minus(__esp, 3);
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
-            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
-            ETModel.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor stateMachine = (ETModel.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor)typeof(ETModel.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
-            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
-            System.Runtime.CompilerServices.TaskAwaiter<ETModel.PacketInfo> awaiter = (System.Runtime.CompilerServices.TaskAwaiter<ETModel.PacketInfo>)typeof(System.Runtime.CompilerServices.TaskAwaiter<ETModel.PacketInfo>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
-            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
-            System.Runtime.CompilerServices.AsyncTaskMethodBuilder<ILRuntime.Runtime.Intepreter.ILTypeInstance> instance_of_this_method;
-            instance_of_this_method = (System.Runtime.CompilerServices.AsyncTaskMethodBuilder<ILRuntime.Runtime.Intepreter.ILTypeInstance>)typeof(System.Runtime.CompilerServices.AsyncTaskMethodBuilder<ILRuntime.Runtime.Intepreter.ILTypeInstance>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
-
-            instance_of_this_method.AwaitUnsafeOnCompleted<System.Runtime.CompilerServices.TaskAwaiter<ETModel.PacketInfo>, ETModel.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor>(ref awaiter, ref stateMachine);
-
-            WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method);
-
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
-            switch(ptr_of_this_method->ObjectType)
-            {
-                case ObjectTypes.StackObjectReference:
-                    {
-                        var ___dst = *(StackObject**)&ptr_of_this_method->Value;
-                        object ___obj = stateMachine;
-                        if (___dst->ObjectType >= ObjectTypes.Object)
-                        {
-                            if (___obj is CrossBindingAdaptorType)
-                                ___obj = ((CrossBindingAdaptorType)___obj).ILInstance;
-                            __mStack[___dst->Value] = ___obj;
-                        }
-                        else
-                        {
-                            ILIntepreter.UnboxObject(___dst, ___obj, __mStack, __domain);
-                        }
-                    }
-                    break;
-                case ObjectTypes.FieldReference:
-                    {
-                        var ___obj = __mStack[ptr_of_this_method->Value];
-                        if(___obj is ILTypeInstance)
-                        {
-                            ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = stateMachine;
-                        }
-                        else
-                        {
-                            var ___type = __domain.GetType(___obj.GetType()) as CLRType;
-                            ___type.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, stateMachine);
-                        }
-                    }
-                    break;
-                case ObjectTypes.StaticFieldReference:
-                    {
-                        var ___type = __domain.GetType(ptr_of_this_method->Value);
-                        if(___type is ILType)
-                        {
-                            ((ILType)___type).StaticInstance[ptr_of_this_method->ValueLow] = stateMachine;
-                        }
-                        else
-                        {
-                            ((CLRType)___type).SetStaticFieldValue(ptr_of_this_method->ValueLow, stateMachine);
-                        }
-                    }
-                    break;
-                 case ObjectTypes.ArrayReference:
-                    {
-                        var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as ETModel.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor[];
-                        instance_of_arrayReference[ptr_of_this_method->ValueLow] = stateMachine;
-                    }
-                    break;
-            }
-
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
-            switch(ptr_of_this_method->ObjectType)
-            {
-                case ObjectTypes.StackObjectReference:
-                    {
-                        var ___dst = *(StackObject**)&ptr_of_this_method->Value;
-                        object ___obj = awaiter;
-                        if (___dst->ObjectType >= ObjectTypes.Object)
-                        {
-                            if (___obj is CrossBindingAdaptorType)
-                                ___obj = ((CrossBindingAdaptorType)___obj).ILInstance;
-                            __mStack[___dst->Value] = ___obj;
-                        }
-                        else
-                        {
-                            ILIntepreter.UnboxObject(___dst, ___obj, __mStack, __domain);
-                        }
-                    }
-                    break;
-                case ObjectTypes.FieldReference:
-                    {
-                        var ___obj = __mStack[ptr_of_this_method->Value];
-                        if(___obj is ILTypeInstance)
-                        {
-                            ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = awaiter;
-                        }
-                        else
-                        {
-                            var ___type = __domain.GetType(___obj.GetType()) as CLRType;
-                            ___type.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, awaiter);
-                        }
-                    }
-                    break;
-                case ObjectTypes.StaticFieldReference:
-                    {
-                        var ___type = __domain.GetType(ptr_of_this_method->Value);
-                        if(___type is ILType)
-                        {
-                            ((ILType)___type).StaticInstance[ptr_of_this_method->ValueLow] = awaiter;
-                        }
-                        else
-                        {
-                            ((CLRType)___type).SetStaticFieldValue(ptr_of_this_method->ValueLow, awaiter);
-                        }
-                    }
-                    break;
-                 case ObjectTypes.ArrayReference:
-                    {
-                        var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as System.Runtime.CompilerServices.TaskAwaiter<ETModel.PacketInfo>[];
-                        instance_of_arrayReference[ptr_of_this_method->ValueLow] = awaiter;
-                    }
-                    break;
-            }
-
-            return __ret;
-        }
-
-        static StackObject* SetException_4(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
-        {
-            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
-            StackObject* ptr_of_this_method;
-            StackObject* __ret = ILIntepreter.Minus(__esp, 2);
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
-            System.Exception exception = (System.Exception)typeof(System.Exception).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
-            __intp.Free(ptr_of_this_method);
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
-            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
-            System.Runtime.CompilerServices.AsyncTaskMethodBuilder<ILRuntime.Runtime.Intepreter.ILTypeInstance> instance_of_this_method;
-            instance_of_this_method = (System.Runtime.CompilerServices.AsyncTaskMethodBuilder<ILRuntime.Runtime.Intepreter.ILTypeInstance>)typeof(System.Runtime.CompilerServices.AsyncTaskMethodBuilder<ILRuntime.Runtime.Intepreter.ILTypeInstance>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
-
-            instance_of_this_method.SetException(exception);
-
-            WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method);
-
-            return __ret;
-        }
-
-        static StackObject* SetResult_5(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
-        {
-            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
-            StackObject* ptr_of_this_method;
-            StackObject* __ret = ILIntepreter.Minus(__esp, 2);
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
-            ILRuntime.Runtime.Intepreter.ILTypeInstance result = (ILRuntime.Runtime.Intepreter.ILTypeInstance)typeof(ILRuntime.Runtime.Intepreter.ILTypeInstance).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
-            __intp.Free(ptr_of_this_method);
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
-            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
-            System.Runtime.CompilerServices.AsyncTaskMethodBuilder<ILRuntime.Runtime.Intepreter.ILTypeInstance> instance_of_this_method;
-            instance_of_this_method = (System.Runtime.CompilerServices.AsyncTaskMethodBuilder<ILRuntime.Runtime.Intepreter.ILTypeInstance>)typeof(System.Runtime.CompilerServices.AsyncTaskMethodBuilder<ILRuntime.Runtime.Intepreter.ILTypeInstance>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
-
-            instance_of_this_method.SetResult(result);
-
-            WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method);
-
-            return __ret;
-        }
-
-        static StackObject* SetStateMachine_6(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
-        {
-            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
-            StackObject* ptr_of_this_method;
-            StackObject* __ret = ILIntepreter.Minus(__esp, 2);
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
-            System.Runtime.CompilerServices.IAsyncStateMachine stateMachine = (System.Runtime.CompilerServices.IAsyncStateMachine)typeof(System.Runtime.CompilerServices.IAsyncStateMachine).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
-            __intp.Free(ptr_of_this_method);
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
-            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
-            System.Runtime.CompilerServices.AsyncTaskMethodBuilder<ILRuntime.Runtime.Intepreter.ILTypeInstance> instance_of_this_method;
-            instance_of_this_method = (System.Runtime.CompilerServices.AsyncTaskMethodBuilder<ILRuntime.Runtime.Intepreter.ILTypeInstance>)typeof(System.Runtime.CompilerServices.AsyncTaskMethodBuilder<ILRuntime.Runtime.Intepreter.ILTypeInstance>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
-
-            instance_of_this_method.SetStateMachine(stateMachine);
-
-            WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method);
-
-            return __ret;
-        }
-
-
-
-    }
-}

+ 28 - 5
Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_PacketInfo_Binding.cs → Unity/Assets/ThirdParty/ILRuntime/Generated/System_Threading_CancellationToken_Binding.cs

@@ -13,7 +13,7 @@ using ILRuntime.CLR.Utils;
 
 namespace ILRuntime.Runtime.Generated
 {
-    unsafe class ETModel_PacketInfo_Binding
+    unsafe class System_Threading_CancellationToken_Binding
     {
         public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
         {
@@ -21,14 +21,17 @@ namespace ILRuntime.Runtime.Generated
             MethodBase method;
             FieldInfo field;
             Type[] args;
-            Type type = typeof(ETModel.PacketInfo);
+            Type type = typeof(System.Threading.CancellationToken);
+            args = new Type[]{typeof(System.Action)};
+            method = type.GetMethod("Register", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, Register_0);
 
-            app.RegisterCLRCreateDefaultInstance(type, () => new ETModel.PacketInfo());
+            app.RegisterCLRCreateDefaultInstance(type, () => new System.Threading.CancellationToken());
 
 
         }
 
-        static void WriteBackInstance(ILRuntime.Runtime.Enviorment.AppDomain __domain, StackObject* ptr_of_this_method, IList<object> __mStack, ref ETModel.PacketInfo instance_of_this_method)
+        static void WriteBackInstance(ILRuntime.Runtime.Enviorment.AppDomain __domain, StackObject* ptr_of_this_method, IList<object> __mStack, ref System.Threading.CancellationToken instance_of_this_method)
         {
             ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
             switch(ptr_of_this_method->ObjectType)
@@ -67,13 +70,33 @@ namespace ILRuntime.Runtime.Generated
                     break;
                  case ObjectTypes.ArrayReference:
                     {
-                        var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as ETModel.PacketInfo[];
+                        var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as System.Threading.CancellationToken[];
                         instance_of_arrayReference[ptr_of_this_method->ValueLow] = instance_of_this_method;
                     }
                     break;
             }
         }
 
+        static StackObject* Register_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* ptr_of_this_method;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 2);
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
+            System.Action callback = (System.Action)typeof(System.Action).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            __intp.Free(ptr_of_this_method);
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
+            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
+            System.Threading.CancellationToken instance_of_this_method;
+            instance_of_this_method = (System.Threading.CancellationToken)typeof(System.Threading.CancellationToken).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+
+            var result_of_this_method = instance_of_this_method.Register(callback);
+
+            WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method);
+
+            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
+        }
+
 
 
     }

+ 12 - 0
Unity/Assets/ThirdParty/ILRuntime/Generated/System_Threading_CancellationToken_Binding.cs.meta

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

+ 112 - 0
Unity/Assets/ThirdParty/ILRuntime/Generated/System_Threading_Tasks_TaskCompletionSource_1_ILTypeInstance_B_t.cs

@@ -0,0 +1,112 @@
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+using ILRuntime.CLR.TypeSystem;
+using ILRuntime.CLR.Method;
+using ILRuntime.Runtime.Enviorment;
+using ILRuntime.Runtime.Intepreter;
+using ILRuntime.Runtime.Stack;
+using ILRuntime.Reflection;
+using ILRuntime.CLR.Utils;
+
+namespace ILRuntime.Runtime.Generated
+{
+    unsafe class System_Threading_Tasks_TaskCompletionSource_1_ILTypeInstance_Binding
+    {
+        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
+        {
+            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
+            MethodBase method;
+            FieldInfo field;
+            Type[] args;
+            Type type = typeof(System.Threading.Tasks.TaskCompletionSource<ILRuntime.Runtime.Intepreter.ILTypeInstance>);
+            args = new Type[]{};
+            method = type.GetMethod("get_Task", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, get_Task_0);
+            args = new Type[]{typeof(ILRuntime.Runtime.Intepreter.ILTypeInstance)};
+            method = type.GetMethod("SetResult", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, SetResult_1);
+            args = new Type[]{typeof(System.Exception)};
+            method = type.GetMethod("SetException", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, SetException_2);
+
+            args = new Type[]{};
+            method = type.GetConstructor(flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, Ctor_0);
+
+        }
+
+
+        static StackObject* get_Task_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* ptr_of_this_method;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 1);
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
+            System.Threading.Tasks.TaskCompletionSource<ILRuntime.Runtime.Intepreter.ILTypeInstance> instance_of_this_method;
+            instance_of_this_method = (System.Threading.Tasks.TaskCompletionSource<ILRuntime.Runtime.Intepreter.ILTypeInstance>)typeof(System.Threading.Tasks.TaskCompletionSource<ILRuntime.Runtime.Intepreter.ILTypeInstance>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            __intp.Free(ptr_of_this_method);
+
+            var result_of_this_method = instance_of_this_method.Task;
+
+            object obj_result_of_this_method = result_of_this_method;
+            if(obj_result_of_this_method is CrossBindingAdaptorType)
+            {    
+                return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance);
+            }
+            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
+        }
+
+        static StackObject* SetResult_1(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* ptr_of_this_method;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 2);
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
+            ILRuntime.Runtime.Intepreter.ILTypeInstance result = (ILRuntime.Runtime.Intepreter.ILTypeInstance)typeof(ILRuntime.Runtime.Intepreter.ILTypeInstance).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            __intp.Free(ptr_of_this_method);
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
+            System.Threading.Tasks.TaskCompletionSource<ILRuntime.Runtime.Intepreter.ILTypeInstance> instance_of_this_method;
+            instance_of_this_method = (System.Threading.Tasks.TaskCompletionSource<ILRuntime.Runtime.Intepreter.ILTypeInstance>)typeof(System.Threading.Tasks.TaskCompletionSource<ILRuntime.Runtime.Intepreter.ILTypeInstance>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            __intp.Free(ptr_of_this_method);
+
+            instance_of_this_method.SetResult(result);
+
+            return __ret;
+        }
+
+        static StackObject* SetException_2(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* ptr_of_this_method;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 2);
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
+            System.Exception exception = (System.Exception)typeof(System.Exception).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            __intp.Free(ptr_of_this_method);
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
+            System.Threading.Tasks.TaskCompletionSource<ILRuntime.Runtime.Intepreter.ILTypeInstance> instance_of_this_method;
+            instance_of_this_method = (System.Threading.Tasks.TaskCompletionSource<ILRuntime.Runtime.Intepreter.ILTypeInstance>)typeof(System.Threading.Tasks.TaskCompletionSource<ILRuntime.Runtime.Intepreter.ILTypeInstance>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            __intp.Free(ptr_of_this_method);
+
+            instance_of_this_method.SetException(exception);
+
+            return __ret;
+        }
+
+
+        static StackObject* Ctor_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* ptr_of_this_method;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 0);
+
+            var result_of_this_method = new System.Threading.Tasks.TaskCompletionSource<ILRuntime.Runtime.Intepreter.ILTypeInstance>();
+
+            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
+        }
+
+
+    }
+}

+ 12 - 0
Unity/Assets/ThirdParty/ILRuntime/Generated/System_Threading_Tasks_TaskCompletionSource_1_ILTypeInstance_B_t.cs.meta

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

+ 0 - 51
Unity/Assets/ThirdParty/ILRuntime/Generated/System_Threading_Tasks_Task_1_PacketInfo_Binding.cs

@@ -1,51 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-using ILRuntime.CLR.TypeSystem;
-using ILRuntime.CLR.Method;
-using ILRuntime.Runtime.Enviorment;
-using ILRuntime.Runtime.Intepreter;
-using ILRuntime.Runtime.Stack;
-using ILRuntime.Reflection;
-using ILRuntime.CLR.Utils;
-
-namespace ILRuntime.Runtime.Generated
-{
-    unsafe class System_Threading_Tasks_Task_1_PacketInfo_Binding
-    {
-        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
-        {
-            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
-            MethodBase method;
-            FieldInfo field;
-            Type[] args;
-            Type type = typeof(System.Threading.Tasks.Task<ETModel.PacketInfo>);
-            args = new Type[]{};
-            method = type.GetMethod("GetAwaiter", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, GetAwaiter_0);
-
-
-        }
-
-
-        static StackObject* GetAwaiter_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
-        {
-            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
-            StackObject* ptr_of_this_method;
-            StackObject* __ret = ILIntepreter.Minus(__esp, 1);
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
-            System.Threading.Tasks.Task<ETModel.PacketInfo> instance_of_this_method;
-            instance_of_this_method = (System.Threading.Tasks.Task<ETModel.PacketInfo>)typeof(System.Threading.Tasks.Task<ETModel.PacketInfo>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
-            __intp.Free(ptr_of_this_method);
-
-            var result_of_this_method = instance_of_this_method.GetAwaiter();
-
-            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
-        }
-
-
-
-    }
-}

+ 0 - 12
Unity/Assets/ThirdParty/ILRuntime/Generated/System_Threading_Tasks_Task_1_PacketInfo_Binding.cs.meta

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

+ 1 - 8
Unity/Hotfix/Init.cs

@@ -15,14 +15,7 @@ namespace ETHotfix
 				ETModel.Game.Hotfix.Update = () => { Update(); };
 				ETModel.Game.Hotfix.LateUpdate = () => { LateUpdate(); };
 				ETModel.Game.Hotfix.OnApplicationQuit = () => { OnApplicationQuit(); };
-
-				// 注册热更层消息回调
-				ClientDispatcher clientDispatcher = new ClientDispatcher
-				{
-					HotfixCallback = (s, p) => { HotfixMessageDispatcher.Run(s, p); }
-				};
-				ETModel.Game.Scene.GetComponent<NetOuterComponent>().MessageDispatcher = clientDispatcher;
-
+				
 				Game.Scene.AddComponent<UIComponent>();
 				Game.Scene.AddComponent<OpcodeTypeComponent>();
 				Game.Scene.AddComponent<MessageDispatherComponent>();

+ 2 - 2
Unity/Hotfix/Module/FrameSync/OperaComponent.cs

@@ -41,7 +41,7 @@ namespace ETHotfix
 	            if (Physics.Raycast(ray, out hit, 1000, this.mapMask))
 	            {
 					this.ClickPoint = hit.point;
-		            SessionComponent.Instance.Session.Send(new Frame_ClickMap() { X = (int)(this.ClickPoint.x * 1000), Z = (int)(this.ClickPoint.z * 1000) });
+		            ETModel.SessionComponent.Instance.Session.Send(new Frame_ClickMap() { X = (int)(this.ClickPoint.x * 1000), Z = (int)(this.ClickPoint.z * 1000) });
 
 					// 测试actor rpc消息
 					this.TestActor();
@@ -51,7 +51,7 @@ namespace ETHotfix
 
 	    public async void TestActor()
 	    {
-		    M2C_TestActorResponse response = (M2C_TestActorResponse)await SessionComponent.Instance.Session.Call(
+		    M2C_TestActorResponse response = (M2C_TestActorResponse)await SessionWrapComponent.Instance.Session.Call(
 					new C2M_TestActorRequest() {Info = "actor rpc request"});
 			Log.Info(response.Info);
 		}

+ 1 - 1
Unity/Hotfix/Module/Message/AMHandler.cs

@@ -7,7 +7,7 @@ namespace ETHotfix
 	{
 		protected abstract void Run(Session session, Message message);
 
-		public void Handle(Session session, uint rpcId, object msg)
+		public void Handle(Session session, object msg)
 		{
 			Message message = msg as Message;
 			if (message == null)

+ 23 - 0
Unity/Hotfix/Module/Message/HotfixMessage.cs

@@ -8,6 +8,8 @@ namespace ETHotfix
 	[ProtoContract]
 	public partial class C2R_Login: IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public string Account;
 
@@ -24,6 +26,8 @@ namespace ETHotfix
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public string Address;
 
@@ -36,6 +40,8 @@ namespace ETHotfix
 	[ProtoContract]
 	public partial class C2G_LoginGate: IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public long Key;
 
@@ -49,6 +55,8 @@ namespace ETHotfix
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public long PlayerId;
 
@@ -67,6 +75,8 @@ namespace ETHotfix
 	[ProtoContract]
 	public partial class C2M_TestActorRequest: MessageObject, IActorRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public string Info;
 
@@ -80,6 +90,8 @@ namespace ETHotfix
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, IsRequired = true)]
 		public string Info;
 
@@ -95,6 +107,8 @@ namespace ETHotfix
 	[ProtoContract]
 	public partial class C2G_PlayerInfo: IRequest
 	{
+		[ProtoMember(90, IsRequired = true)]
+		public int RpcId { get; set; }
 	}
 
 	[Message(HotfixOpcode.G2C_PlayerInfo)]
@@ -105,9 +119,18 @@ namespace ETHotfix
 		public int Error { get; set; }
 		[ProtoMember(91, IsRequired = true)]
 		public string Message { get; set; }
+		[ProtoMember(92, IsRequired = true)]
+		public int RpcId { get; set; }
 		[ProtoMember(1, TypeName = "ETHotfix.PlayerInfo")]
 		public List<PlayerInfo> PlayerInfos = new List<PlayerInfo>();
 
 	}
 
 }
+namespace ETHotfix
+{
+	[ProtoInclude(HotfixOpcode.C2M_TestActorRequest, typeof(C2M_TestActorRequest))]
+	[ProtoInclude(HotfixOpcode.M2C_TestActorResponse, typeof(M2C_TestActorResponse))]
+	public partial class MessageObject {}
+
+}

+ 1 - 7
Unity/Hotfix/Module/Message/HotfixMessageDispatcher.cs

@@ -5,12 +5,6 @@ namespace ETHotfix
 {
 	public static class HotfixMessageDispatcher
 	{
-		public static void Run(Session session, PacketInfo packetInfo)
-		{
-			ushort opcode = packetInfo.Opcode;
-			Type t = Game.Scene.GetComponent<OpcodeTypeComponent>().GetType(opcode);
-			object message = ProtobufHelper.FromBytes(t, packetInfo.Bytes, packetInfo.Index, packetInfo.Length);
-			Game.Scene.GetComponent<MessageDispatherComponent>().Handle(session, new MessageInfo(packetInfo.RpcId, packetInfo.Opcode, message));
-		}
+
 	}
 }

+ 1 - 1
Unity/Hotfix/Module/Message/IMHandler.cs

@@ -6,7 +6,7 @@ namespace ETHotfix
 #if ILRuntime
 	public interface IMHandler
 	{
-		void Handle(Session session, uint rpcId, object message);
+		void Handle(Session session, object message);
 		Type GetMessageType();
 	}
 #else

+ 3 - 1
Unity/Hotfix/Module/Message/IMessage.cs

@@ -10,13 +10,15 @@ namespace ETHotfix
 	{
 	}
 	
-	public interface IRequest
+	public interface IRequest: IMessage
 	{
+		int RpcId { get; set; }
 	}
 
 	public interface IResponse : IMessage
 	{
 		int Error { get; set; }
 		string Message { get; set; }
+		int RpcId { get; set; }
 	}
 }

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

@@ -74,7 +74,7 @@ namespace ETHotfix
 						continue;
 					}
 
-					MessageProxy messageProxy = new MessageProxy(messageType, (session, rpcId, o) => { iMHandler.Handle(session, rpcId, o); });
+					MessageProxy messageProxy = new MessageProxy(messageType, (session, o) => { iMHandler.Handle(session, o); });
 					messageDispatherComponent.RegisterHandler(monoOpcode, messageProxy);
 				}
 			}
@@ -101,7 +101,7 @@ namespace ETHotfix
 			{
 				try
 				{
-					ev.Handle(session, messageInfo.RpcId, messageInfo.Message);
+					ev.Handle(session, messageInfo.Message);
 				}
 				catch (Exception e)
 				{

+ 0 - 29
Unity/Hotfix/Module/Message/SessionHelper.cs

@@ -1,29 +0,0 @@
-using System;
-using System.Threading.Tasks;
-using ETModel;
-
-namespace ETHotfix
-{
-	public static class SessionHelper
-	{
-		public static void Send(this Session session, IMessage message)
-		{
-			ushort opcode = Game.Scene.GetComponent<OpcodeTypeComponent>().GetOpcode(message.GetType());
-			byte[] bytes = ProtobufHelper.ToBytes(message);
-			session.Send(opcode, bytes);
-		}
-
-		public static async Task<IResponse> Call(this Session session, IRequest request)
-		{
-			OpcodeTypeComponent opcodeTypeComponent = Game.Scene.GetComponent<OpcodeTypeComponent>();
-			byte[] bytes = ProtobufHelper.ToBytes(request);
-			ushort opcode = opcodeTypeComponent.GetOpcode(request.GetType());
-			PacketInfo packetInfo = await session.Call(opcode, bytes);
-			ushort responseOpcode = packetInfo.Opcode;
-			Type t = opcodeTypeComponent.GetType(responseOpcode);
-			object aa = ProtobufHelper.FromBytes(t, packetInfo.Bytes, packetInfo.Index, packetInfo.Length);
-			IResponse response = (IResponse)aa;
-			return response;
-		}
-	}
-}

+ 145 - 0
Unity/Hotfix/Module/Message/SessionWrap.cs

@@ -0,0 +1,145 @@
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using ETModel;
+
+namespace ETHotfix
+{
+	public class SessionWrap: Entity
+	{
+		public readonly Session session;
+
+		private static int RpcId { get; set; }
+		private readonly Dictionary<int, Action<IResponse>> requestCallback = new Dictionary<int, Action<IResponse>>();
+
+		public SessionWrap(Session session)
+		{
+			this.session = session;
+			SessionCallbackComponent sessionComponent = this.session.AddComponent<SessionCallbackComponent>();
+			sessionComponent.MessageCallback = (s, p) => { this.Run(s, p); };
+			sessionComponent.DisposeCallback = s => { this.Dispose(); };
+		}
+
+		public void Run(Session s, Packet p)
+		{
+			ushort opcode = p.Opcode();
+			byte flag = p.Flag();
+			
+			OpcodeTypeComponent opcodeTypeComponent = Game.Scene.GetComponent<OpcodeTypeComponent>();
+			Type responseType = opcodeTypeComponent.GetType(opcode);
+			object message = ProtobufHelper.FromBytes(responseType, p.Bytes, Packet.Index, p.Length - Packet.Index);
+			if ((flag & 0x01) > 0)
+			{
+				IResponse response = message as IResponse;
+				if (response == null)
+				{
+					throw new Exception($"flag is response, but hotfix message is not! {opcode}");
+				}
+				Action<IResponse> action;
+				if (!this.requestCallback.TryGetValue(response.RpcId, out action))
+				{
+					return;
+				}
+				this.requestCallback.Remove(response.RpcId);
+
+				action(response);
+				return;
+			}
+
+			Game.Scene.GetComponent<MessageDispatherComponent>().Handle(session, new MessageInfo(opcode, message));
+		}
+
+		public void Send(IMessage message)
+		{
+			Send(0x00, message);
+		}
+
+		public void Send(byte flag, IMessage message)
+		{
+			ushort opcode = Game.Scene.GetComponent<OpcodeTypeComponent>().GetOpcode(message.GetType());
+			byte[] bytes = ProtobufHelper.ToBytes(message);
+			session.Send(flag, opcode, bytes);
+		}
+
+		public void Send(byte flag, ushort opcode, byte[] bytes)
+		{
+			session.Send(flag, opcode, bytes);
+		}
+
+		public Task<IResponse> Call(IRequest request)
+		{
+			int rpcId = ++RpcId;
+			var tcs = new TaskCompletionSource<IResponse>();
+
+			this.requestCallback[rpcId] = (response) =>
+			{
+				try
+				{
+					if (response.RpcId != rpcId)
+					{
+						return;
+					}
+					if (response.Error > ErrorCode.ERR_Exception)
+					{
+						throw new RpcException(response.Error, response.Message);
+					}
+
+					tcs.SetResult(response);
+				}
+				catch (Exception e)
+				{
+					tcs.SetException(new Exception($"Rpc Error: {request.GetType().FullName}", e));
+				}
+			};
+
+			request.RpcId = rpcId;
+			
+			this.Send(0x00, request);
+			return tcs.Task;
+		}
+
+		public Task<IResponse> Call(IRequest request, CancellationToken cancellationToken)
+		{
+			int rpcId = ++RpcId;
+			var tcs = new TaskCompletionSource<IResponse>();
+
+			this.requestCallback[rpcId] = (response) =>
+			{
+				try
+				{
+					if (response.RpcId != rpcId)
+					{
+						return;
+					}
+					if (response.Error > ErrorCode.ERR_Exception)
+					{
+						throw new RpcException(response.Error, response.Message);
+					}
+
+					tcs.SetResult(response);
+				}
+				catch (Exception e)
+				{
+					tcs.SetException(new Exception($"Rpc Error: {request.GetType().FullName}", e));
+				}
+			};
+
+			cancellationToken.Register(() => { this.requestCallback.Remove(rpcId); });
+
+			request.RpcId = rpcId;
+
+			this.Send(0x00, request);
+			return tcs.Task;
+		}
+
+		public override void Dispose()
+		{
+			if (this.IsDisposed)
+			{
+				return;
+			}
+			base.Dispose();
+		}
+	}
+}

+ 39 - 0
Unity/Hotfix/Module/Message/SessionWrapComponent.cs

@@ -0,0 +1,39 @@
+using ETModel;
+
+namespace ETHotfix
+{
+	[ObjectSystem]
+	public class SessionComponentAwakeSystem : AwakeSystem<SessionWrapComponent>
+	{
+		public override void Awake(SessionWrapComponent self)
+		{
+			self.Awake();
+		}
+	}
+
+	public class SessionWrapComponent: Component
+	{
+		public static SessionWrapComponent Instance;
+
+		public SessionWrap Session;
+
+		public void Awake()
+		{
+			Instance = this;
+		}
+
+		public override void Dispose()
+		{
+			if (this.IsDisposed)
+			{
+				return;
+			}
+
+			base.Dispose();
+
+			this.Session.Dispose();
+			this.Session = null;
+			Instance = null;
+		}
+	}
+}

+ 8 - 6
Unity/Hotfix/UI/UILogin/Component/UILoginComponent.cs

@@ -30,22 +30,23 @@ namespace ETHotfix
 
 		public async void OnLogin()
 		{
+			SessionWrap sessionWrap = null;
 			try
 			{
 				IPEndPoint connetEndPoint = NetworkHelper.ToIPEndPoint(GlobalConfigComponent.Instance.GlobalProto.Address);
 
 				string text = this.account.GetComponent<InputField>().text;
 
-				R2C_Login r2CLogin;
-				using (Session session = ETModel.Game.Scene.GetComponent<NetOuterComponent>().Create(connetEndPoint))
-				{
-					r2CLogin = (R2C_Login) await session.Call(new C2R_Login() { Account = text, Password = "111111" });
-				}
+				Session session = ETModel.Game.Scene.GetComponent<NetOuterComponent>().Create(connetEndPoint);
+				sessionWrap = new SessionWrap(session);
+				R2C_Login r2CLogin = (R2C_Login) await sessionWrap.Call(new C2R_Login() { Account = text, Password = "111111" });
+				sessionWrap.Dispose();
 
 				connetEndPoint = NetworkHelper.ToIPEndPoint(r2CLogin.Address);
 				Session gateSession = ETModel.Game.Scene.GetComponent<NetOuterComponent>().Create(connetEndPoint);
+				Game.Scene.AddComponent<SessionWrapComponent>().Session = new SessionWrap(gateSession);
 				ETModel.Game.Scene.AddComponent<SessionComponent>().Session = gateSession;
-				G2C_LoginGate g2CLoginGate = (G2C_LoginGate)await SessionComponent.Instance.Session.Call(new C2G_LoginGate() { Key = r2CLogin.Key });
+				G2C_LoginGate g2CLoginGate = (G2C_LoginGate)await SessionWrapComponent.Instance.Session.Call(new C2G_LoginGate() { Key = r2CLogin.Key });
 
 				Log.Info("登陆gate成功!");
 
@@ -59,6 +60,7 @@ namespace ETHotfix
 			}
 			catch (Exception e)
 			{
+				sessionWrap?.Dispose();
 				Log.Error(e.ToStr());
 			}
 		}

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

@@ -85,6 +85,8 @@
     <Compile Include="Base\Object\Object.cs" />
     <Compile Include="Base\Object\EventSystem.cs" />
     <Compile Include="Base\Object\ObjectPool.cs" />
+    <Compile Include="Module\Message\SessionWrapComponent.cs" />
+    <Compile Include="Module\Message\SessionWrap.cs" />
     <Compile Include="Module\UI\IUIFactory.cs" />
     <Compile Include="Module\Message\MessageDispatherComponent.cs" />
     <Compile Include="Module\Message\OpcodeTypeComponent.cs" />
@@ -92,7 +94,6 @@
     <Compile Include="Entity\Game.cs" />
     <Compile Include="Entity\Scene.cs" />
     <Compile Include="Module\Message\HotfixMessage.cs" />
-    <Compile Include="Module\Message\SessionHelper.cs" />
     <Compile Include="Module\UI\UI.cs" />
     <Compile Include="Init.cs" />
     <Compile Include="Module\Message\HotfixOpcode.cs" />

+ 7 - 5
Unity/Unity.csproj

@@ -315,6 +315,7 @@
     <Compile Include="Assets\Scripts\Module\Message\ProtobufPacker.cs" />
     <Compile Include="Assets\Scripts\Module\Message\RpcException.cs" />
     <Compile Include="Assets\Scripts\Module\Message\Session.cs" />
+    <Compile Include="Assets\Scripts\Module\Message\SessionCallbackComponent.cs" />
     <Compile Include="Assets\Scripts\Module\Numeric\INumericWatcher.cs" />
     <Compile Include="Assets\Scripts\Module\Numeric\NumericChangeEvent_NotifyWatcher.cs" />
     <Compile Include="Assets\Scripts\Module\Numeric\NumericComponent.cs" />
@@ -350,7 +351,6 @@
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_C2G_EnterMap_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_CameraComponent_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_CanvasConfig_Binding.cs" />
-    <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_ClientDispatcher_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_Component_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_ComponentFactory_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_Define_Binding.cs" />
@@ -375,13 +375,15 @@
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_NetworkComponent_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_NetworkHelper_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_OpcodeTypeComponent_Binding.cs" />
-    <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_PacketInfo_Binding.cs" />
+    <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_Packet_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_Player_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_PlayerComponent_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_ProtobufHelper_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_ResourcesComponent_Binding.cs" />
+    <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_RpcException_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_Scene_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_Session_Binding.cs" />
+    <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_SessionCallbackComponent_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_SessionComponent_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_UIFactoryAttribute_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_Unit_Binding.cs" />
@@ -393,6 +395,7 @@
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ProtoBuf_PType_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ReferenceCollector_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\System_Activator_Binding.cs" />
+    <Compile Include="Assets\ThirdParty\ILRuntime\Generated\System_Collections_Generic_Dictionary_2_Int32_Action_1_ILTypeI_t.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\System_Collections_Generic_Dictionary_2_Int64_ILTypeInstance_B_t.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\System_Collections_Generic_Dictionary_2_String_ILTypeInstance__t.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\System_Collections_Generic_Dictionary_2_String_ILTypeInstance__t_t.cs" />
@@ -417,15 +420,14 @@
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\System_NotImplementedException_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\System_Object_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\System_Reflection_MemberInfo_Binding.cs" />
-    <Compile Include="Assets\ThirdParty\ILRuntime\Generated\System_Runtime_CompilerServices_AsyncTaskMethodBuilder_1_ILTyp_t.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\System_Runtime_CompilerServices_AsyncVoidMethodBuilder_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\System_Runtime_CompilerServices_TaskAwaiter_1_ILTypeInstance_B_t.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\System_Runtime_CompilerServices_TaskAwaiter_1_IResponse_Bindin_t.cs" />
-    <Compile Include="Assets\ThirdParty\ILRuntime\Generated\System_Runtime_CompilerServices_TaskAwaiter_1_PacketInfo_Bindi_t.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\System_String_Binding.cs" />
+    <Compile Include="Assets\ThirdParty\ILRuntime\Generated\System_Threading_CancellationToken_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\System_Threading_Tasks_Task_1_ILTypeInstance_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\System_Threading_Tasks_Task_1_IResponse_Binding.cs" />
-    <Compile Include="Assets\ThirdParty\ILRuntime\Generated\System_Threading_Tasks_Task_1_PacketInfo_Binding.cs" />
+    <Compile Include="Assets\ThirdParty\ILRuntime\Generated\System_Threading_Tasks_TaskCompletionSource_1_ILTypeInstance_B_t.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\System_Type_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\UnityEngine_Camera_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\UnityEngine_Component_Binding.cs" />