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

网络调试通过,暂时外网内网全部使用TCP

tanghai 4 лет назад
Родитель
Сommit
5811ca1494

+ 12 - 0
Proto/InnerMessage.proto

@@ -4,6 +4,7 @@ package ET;
 /// <summary>
 /// 传送unit
 /// </summary>
+//ResponseType M2M_TrasferUnitResponse
 message M2M_TrasferUnitRequest // IActorRequest
 {
     int32 RpcId = 90;
@@ -20,6 +21,7 @@ message M2M_TrasferUnitResponse // IActorResponse
     int64 InstanceId = 1;
 }
 
+//ResponseType A2M_Reload
 message M2A_Reload // IActorRequest
 {
     int32 RpcId = 90;
@@ -33,6 +35,7 @@ message A2M_Reload // IActorResponse
     string Message = 92;
 }
 
+//ResponseType G2G_LockResponse
 message G2G_LockRequest // IActorRequest
 {
     int32 RpcId = 90;
@@ -48,6 +51,7 @@ message G2G_LockResponse // IActorResponse
     string Message = 92;
 }
 
+//ResponseType G2G_LockReleaseResponse
 message G2G_LockReleaseRequest // IActorRequest
 {
     int32 RpcId = 90;
@@ -63,6 +67,7 @@ message G2G_LockReleaseResponse // IActorResponse
     string Message = 92;
 }
 
+//ResponseType ObjectAddResponse
 message ObjectAddRequest // IActorRequest
 {
     int32 RpcId = 90;
@@ -77,6 +82,8 @@ message ObjectAddResponse // IActorResponse
     int32 Error = 91;
     string Message = 92;
 }
+
+//ResponseType ObjectLockResponse
 message ObjectLockRequest // IActorRequest
 {
     int32 RpcId = 90;
@@ -92,6 +99,7 @@ message ObjectLockResponse // IActorResponse
     string Message = 92;
 }
 
+//ResponseType ObjectUnLockResponse
 message ObjectUnLockRequest // IActorRequest
 {
     int32 RpcId = 90;
@@ -107,6 +115,7 @@ message ObjectUnLockResponse // IActorResponse
     string Message = 92;
 }
 
+//ResponseType ObjectRemoveResponse
 message ObjectRemoveRequest // IActorRequest
 {
     int32 RpcId = 90;
@@ -120,6 +129,7 @@ message ObjectRemoveResponse // IActorResponse
     string Message = 92;
 }
 
+//ResponseType ObjectGetResponse
 message ObjectGetRequest // IActorRequest
 {
     int32 RpcId = 90;
@@ -135,6 +145,7 @@ message ObjectGetResponse // IActorResponse
     int64 InstanceId = 1;
 }
 
+//ResponseType G2R_GetLoginKey
 message R2G_GetLoginKey // IActorRequest
 {
     int32 RpcId = 90;
@@ -152,6 +163,7 @@ message G2R_GetLoginKey // IActorResponse
     int64 GateId = 2;
 }
 
+//ResponseType M2G_CreateUnit
 message G2M_CreateUnit // IActorRequest
 {
     int32 RpcId = 90;

+ 14 - 3
Proto/OuterMessage.proto

@@ -1,6 +1,7 @@
 syntax = "proto3";
 package ET;
 
+//ResponseType M2C_TestResponse
 message C2M_TestRequest // IActorLocationRequest
 {
 	int32 RpcId = 90;
@@ -16,6 +17,7 @@ message M2C_TestResponse // IActorLocationResponse
 	string response = 1;
 }
 
+//ResponseType Actor_TransferResponse
 message Actor_TransferRequest // IActorLocationRequest
 {
 	int32 RpcId = 90;
@@ -30,6 +32,7 @@ message Actor_TransferResponse // IActorLocationResponse
 	string Message = 92;
 }
 
+//ResponseType G2C_EnterMap
 message C2G_EnterMap // IRequest
 {
 	int32 RpcId = 90;
@@ -88,23 +91,27 @@ message M2C_PathfindingResult // IActorMessage
 	repeated float Zs = 7;
 }
 
-
-message C2R_Ping // IRequest
+//ResponseType G2C_Ping
+message C2G_Ping // IRequest
 {
 	int32 RpcId = 90;
 }
 
-message R2C_Ping // IResponse
+message G2C_Ping // IResponse
 {
 	int32 RpcId = 90;
 	int32 Error = 91;
 	string Message = 92;
+	
+	int64 Time = 1;
 }
 
+
 message G2C_Test // IMessage
 {
 }
 
+//ResponseType M2C_Reload
 message C2M_Reload // IRequest
 {
 	int32 RpcId = 90;
@@ -119,6 +126,7 @@ message M2C_Reload // IResponse
 	string Message = 92;
 }
 
+//ResponseType R2C_Login
 message C2R_Login // IRequest
 {
 	int32 RpcId = 90;
@@ -136,6 +144,7 @@ message R2C_Login // IResponse
 	int64 GateId = 3;
 }
 
+//ResponseType G2C_LoginGate
 message C2G_LoginGate // IRequest
 {
 	int32 RpcId = 90;
@@ -156,6 +165,7 @@ message G2C_TestHotfixMessage // IMessage
 	string Info = 1;
 }
 
+//ResponseType M2C_TestActorResponse
 message C2M_TestActorRequest // IActorLocationRequest
 {
 	int32 RpcId = 90;
@@ -176,6 +186,7 @@ message PlayerInfo // IMessage
 	int32 RpcId = 90;
 }
 
+//ResponseType G2C_PlayerInfo
 message C2G_PlayerInfo // IRequest
 {
 	int32 RpcId = 90;

+ 3 - 1
Server/App/Program.cs

@@ -42,7 +42,9 @@ namespace ET
 					{
 						Thread.Sleep(1);
 						ThreadSynchronizationContext.Instance.Update();
-						Game.EventSystem.Update();
+						Game.Update();
+						Game.LateUpdate();
+						Game.FrameFinish();
 					}
 					catch (Exception e)
 					{

+ 16 - 0
Server/Hotfix/Handler/C2G_PingHandler.cs

@@ -0,0 +1,16 @@
+using System;
+
+
+namespace ET
+{
+	[MessageHandler]
+	public class C2G_PingHandler : AMRpcHandler<C2G_Ping, G2C_Ping>
+	{
+		protected override async ETTask Run(Session session, C2G_Ping request, G2C_Ping response, Action reply)
+		{
+			response.Time = TimeHelper.ServerNow();
+			reply();
+			await ETTask.CompletedTask;
+		}
+	}
+}

+ 0 - 15
Server/Hotfix/Handler/C2R_PingHandler.cs

@@ -1,15 +0,0 @@
-using System;
-
-
-namespace ET
-{
-	[MessageHandler]
-	public class C2R_PingHandler : AMRpcHandler<C2R_Ping, R2C_Ping>
-	{
-		protected override async ETTask Run(Session session, C2R_Ping request, R2C_Ping response, Action reply)
-		{
-			reply();
-			await ETTask.CompletedTask;
-		}
-	}
-}

+ 0 - 29
Server/Model/Generate/InnerProtoOpcode.cs

@@ -1,29 +0,0 @@
-namespace ET
-{
-    public static partial class InnerOpcode
-    {
-        public const ushort M2M_TrasferUnitRequest = 10001;
-        public const ushort M2M_TrasferUnitResponse = 10002;
-        public const ushort M2A_Reload = 10003;
-        public const ushort A2M_Reload = 10004;
-        public const ushort G2G_LockRequest = 10005;
-        public const ushort G2G_LockResponse = 10006;
-        public const ushort G2G_LockReleaseRequest = 10007;
-        public const ushort G2G_LockReleaseResponse = 10008;
-        public const ushort ObjectAddRequest = 10009;
-        public const ushort ObjectAddResponse = 10010;
-        public const ushort ObjectLockRequest = 10011;
-        public const ushort ObjectLockResponse = 10012;
-        public const ushort ObjectUnLockRequest = 10013;
-        public const ushort ObjectUnLockResponse = 10014;
-        public const ushort ObjectRemoveRequest = 10015;
-        public const ushort ObjectRemoveResponse = 10016;
-        public const ushort ObjectGetRequest = 10017;
-        public const ushort ObjectGetResponse = 10018;
-        public const ushort R2G_GetLoginKey = 10019;
-        public const ushort G2R_GetLoginKey = 10020;
-        public const ushort G2M_CreateUnit = 10021;
-        public const ushort M2G_CreateUnit = 10022;
-        public const ushort G2M_SessionDisconnect = 10023;
-    }
-}

+ 11 - 0
Server/Model/Generate/InnerProtoMessage.cs → Server/Model/Generate/Message/InnerMessage.cs

@@ -6,6 +6,7 @@ namespace ET
 /// <summary>
 /// 传送unit
 /// </summary>
+	[ResponseType(typeof(M2M_TrasferUnitResponse))]
 	[Message(InnerOpcode.M2M_TrasferUnitRequest)]
 	[ProtoContract]
 	public partial class M2M_TrasferUnitRequest: IActorRequest
@@ -39,6 +40,7 @@ namespace ET
 
 	}
 
+	[ResponseType(typeof(A2M_Reload))]
 	[Message(InnerOpcode.M2A_Reload)]
 	[ProtoContract]
 	public partial class M2A_Reload: IActorRequest
@@ -66,6 +68,7 @@ namespace ET
 
 	}
 
+	[ResponseType(typeof(G2G_LockResponse))]
 	[Message(InnerOpcode.G2G_LockRequest)]
 	[ProtoContract]
 	public partial class G2G_LockRequest: IActorRequest
@@ -99,6 +102,7 @@ namespace ET
 
 	}
 
+	[ResponseType(typeof(G2G_LockReleaseResponse))]
 	[Message(InnerOpcode.G2G_LockReleaseRequest)]
 	[ProtoContract]
 	public partial class G2G_LockReleaseRequest: IActorRequest
@@ -132,6 +136,7 @@ namespace ET
 
 	}
 
+	[ResponseType(typeof(ObjectAddResponse))]
 	[Message(InnerOpcode.ObjectAddRequest)]
 	[ProtoContract]
 	public partial class ObjectAddRequest: IActorRequest
@@ -165,6 +170,7 @@ namespace ET
 
 	}
 
+	[ResponseType(typeof(ObjectLockResponse))]
 	[Message(InnerOpcode.ObjectLockRequest)]
 	[ProtoContract]
 	public partial class ObjectLockRequest: IActorRequest
@@ -201,6 +207,7 @@ namespace ET
 
 	}
 
+	[ResponseType(typeof(ObjectUnLockResponse))]
 	[Message(InnerOpcode.ObjectUnLockRequest)]
 	[ProtoContract]
 	public partial class ObjectUnLockRequest: IActorRequest
@@ -237,6 +244,7 @@ namespace ET
 
 	}
 
+	[ResponseType(typeof(ObjectRemoveResponse))]
 	[Message(InnerOpcode.ObjectRemoveRequest)]
 	[ProtoContract]
 	public partial class ObjectRemoveRequest: IActorRequest
@@ -267,6 +275,7 @@ namespace ET
 
 	}
 
+	[ResponseType(typeof(ObjectGetResponse))]
 	[Message(InnerOpcode.ObjectGetRequest)]
 	[ProtoContract]
 	public partial class ObjectGetRequest: IActorRequest
@@ -300,6 +309,7 @@ namespace ET
 
 	}
 
+	[ResponseType(typeof(G2R_GetLoginKey))]
 	[Message(InnerOpcode.R2G_GetLoginKey)]
 	[ProtoContract]
 	public partial class R2G_GetLoginKey: IActorRequest
@@ -336,6 +346,7 @@ namespace ET
 
 	}
 
+	[ResponseType(typeof(M2G_CreateUnit))]
 	[Message(InnerOpcode.G2M_CreateUnit)]
 	[ProtoContract]
 	public partial class G2M_CreateUnit: IActorRequest

+ 29 - 0
Server/Model/Generate/Message/InnerOpcode.cs

@@ -0,0 +1,29 @@
+namespace ET
+{
+	public static partial class InnerOpcode
+	{
+		 public const ushort M2M_TrasferUnitRequest = 10001;
+		 public const ushort M2M_TrasferUnitResponse = 10002;
+		 public const ushort M2A_Reload = 10003;
+		 public const ushort A2M_Reload = 10004;
+		 public const ushort G2G_LockRequest = 10005;
+		 public const ushort G2G_LockResponse = 10006;
+		 public const ushort G2G_LockReleaseRequest = 10007;
+		 public const ushort G2G_LockReleaseResponse = 10008;
+		 public const ushort ObjectAddRequest = 10009;
+		 public const ushort ObjectAddResponse = 10010;
+		 public const ushort ObjectLockRequest = 10011;
+		 public const ushort ObjectLockResponse = 10012;
+		 public const ushort ObjectUnLockRequest = 10013;
+		 public const ushort ObjectUnLockResponse = 10014;
+		 public const ushort ObjectRemoveRequest = 10015;
+		 public const ushort ObjectRemoveResponse = 10016;
+		 public const ushort ObjectGetRequest = 10017;
+		 public const ushort ObjectGetResponse = 10018;
+		 public const ushort R2G_GetLoginKey = 10019;
+		 public const ushort G2R_GetLoginKey = 10020;
+		 public const ushort G2M_CreateUnit = 10021;
+		 public const ushort M2G_CreateUnit = 10022;
+		 public const ushort G2M_SessionDisconnect = 10023;
+	}
+}

+ 16 - 4
Server/Model/Generate/OuterProtoMessage.cs → Server/Model/Generate/Message/OuterMessage.cs

@@ -3,6 +3,7 @@ using ProtoBuf;
 using System.Collections.Generic;
 namespace ET
 {
+	[ResponseType(typeof(M2C_TestResponse))]
 	[Message(OuterOpcode.C2M_TestRequest)]
 	[ProtoContract]
 	public partial class C2M_TestRequest: IActorLocationRequest
@@ -36,6 +37,7 @@ namespace ET
 
 	}
 
+	[ResponseType(typeof(Actor_TransferResponse))]
 	[Message(OuterOpcode.Actor_TransferRequest)]
 	[ProtoContract]
 	public partial class Actor_TransferRequest: IActorLocationRequest
@@ -66,6 +68,7 @@ namespace ET
 
 	}
 
+	[ResponseType(typeof(G2C_EnterMap))]
 	[Message(OuterOpcode.C2G_EnterMap)]
 	[ProtoContract]
 	public partial class C2G_EnterMap: IRequest
@@ -187,18 +190,19 @@ namespace ET
 
 	}
 
-	[Message(OuterOpcode.C2R_Ping)]
+	[ResponseType(typeof(G2C_Ping))]
+	[Message(OuterOpcode.C2G_Ping)]
 	[ProtoContract]
-	public partial class C2R_Ping: IRequest
+	public partial class C2G_Ping: IRequest
 	{
 		[ProtoMember(90)]
 		public int RpcId { get; set; }
 
 	}
 
-	[Message(OuterOpcode.R2C_Ping)]
+	[Message(OuterOpcode.G2C_Ping)]
 	[ProtoContract]
-	public partial class R2C_Ping: IResponse
+	public partial class G2C_Ping: IResponse
 	{
 		[ProtoMember(90)]
 		public int RpcId { get; set; }
@@ -209,6 +213,9 @@ namespace ET
 		[ProtoMember(92)]
 		public string Message { get; set; }
 
+		[ProtoMember(1)]
+		public long Time { get; set; }
+
 	}
 
 	[Message(OuterOpcode.G2C_Test)]
@@ -217,6 +224,7 @@ namespace ET
 	{
 	}
 
+	[ResponseType(typeof(M2C_Reload))]
 	[Message(OuterOpcode.C2M_Reload)]
 	[ProtoContract]
 	public partial class C2M_Reload: IRequest
@@ -247,6 +255,7 @@ namespace ET
 
 	}
 
+	[ResponseType(typeof(R2C_Login))]
 	[Message(OuterOpcode.C2R_Login)]
 	[ProtoContract]
 	public partial class C2R_Login: IRequest
@@ -286,6 +295,7 @@ namespace ET
 
 	}
 
+	[ResponseType(typeof(G2C_LoginGate))]
 	[Message(OuterOpcode.C2G_LoginGate)]
 	[ProtoContract]
 	public partial class C2G_LoginGate: IRequest
@@ -328,6 +338,7 @@ namespace ET
 
 	}
 
+	[ResponseType(typeof(M2C_TestActorResponse))]
 	[Message(OuterOpcode.C2M_TestActorRequest)]
 	[ProtoContract]
 	public partial class C2M_TestActorRequest: IActorLocationRequest
@@ -370,6 +381,7 @@ namespace ET
 
 	}
 
+	[ResponseType(typeof(G2C_PlayerInfo))]
 	[Message(OuterOpcode.C2G_PlayerInfo)]
 	[ProtoContract]
 	public partial class C2G_PlayerInfo: IRequest

+ 31 - 0
Server/Model/Generate/Message/OuterOpcode.cs

@@ -0,0 +1,31 @@
+namespace ET
+{
+	public static partial class OuterOpcode
+	{
+		 public const ushort C2M_TestRequest = 20001;
+		 public const ushort M2C_TestResponse = 20002;
+		 public const ushort Actor_TransferRequest = 20003;
+		 public const ushort Actor_TransferResponse = 20004;
+		 public const ushort C2G_EnterMap = 20005;
+		 public const ushort G2C_EnterMap = 20006;
+		 public const ushort UnitInfo = 20007;
+		 public const ushort M2C_CreateUnits = 20008;
+		 public const ushort Frame_ClickMap = 20009;
+		 public const ushort M2C_PathfindingResult = 20010;
+		 public const ushort C2G_Ping = 20011;
+		 public const ushort G2C_Ping = 20012;
+		 public const ushort G2C_Test = 20013;
+		 public const ushort C2M_Reload = 20014;
+		 public const ushort M2C_Reload = 20015;
+		 public const ushort C2R_Login = 20016;
+		 public const ushort R2C_Login = 20017;
+		 public const ushort C2G_LoginGate = 20018;
+		 public const ushort G2C_LoginGate = 20019;
+		 public const ushort G2C_TestHotfixMessage = 20020;
+		 public const ushort C2M_TestActorRequest = 20021;
+		 public const ushort M2C_TestActorResponse = 20022;
+		 public const ushort PlayerInfo = 20023;
+		 public const ushort C2G_PlayerInfo = 20024;
+		 public const ushort G2C_PlayerInfo = 20025;
+	}
+}

+ 0 - 31
Server/Model/Generate/OuterProtoOpcode.cs

@@ -1,31 +0,0 @@
-namespace ET
-{
-    public static partial class OuterOpcode
-    {
-        public const ushort C2M_TestRequest = 20001;
-        public const ushort M2C_TestResponse = 20002;
-        public const ushort Actor_TransferRequest = 20003;
-        public const ushort Actor_TransferResponse = 20004;
-        public const ushort C2G_EnterMap = 20005;
-        public const ushort G2C_EnterMap = 20006;
-        public const ushort UnitInfo = 20007;
-        public const ushort M2C_CreateUnits = 20008;
-        public const ushort Frame_ClickMap = 20009;
-        public const ushort M2C_PathfindingResult = 20010;
-        public const ushort C2R_Ping = 20011;
-        public const ushort R2C_Ping = 20012;
-        public const ushort G2C_Test = 20013;
-        public const ushort C2M_Reload = 20014;
-        public const ushort M2C_Reload = 20015;
-        public const ushort C2R_Login = 20016;
-        public const ushort R2C_Login = 20017;
-        public const ushort C2G_LoginGate = 20018;
-        public const ushort G2C_LoginGate = 20019;
-        public const ushort G2C_TestHotfixMessage = 20020;
-        public const ushort C2M_TestActorRequest = 20021;
-        public const ushort M2C_TestActorResponse = 20022;
-        public const ushort PlayerInfo = 20023;
-        public const ushort C2G_PlayerInfo = 20024;
-        public const ushort G2C_PlayerInfo = 20025;
-    }
-}

+ 32 - 7
Tools/Proto2CS/Program.cs

@@ -25,23 +25,33 @@ namespace ET
     public static class InnerProto2CS
     {
         private const string protoPath = ".";
-        private const string clientMessagePath = "../../Unity/Assets/Model/Module/Message/";
-        private const string serverMessagePath = "../../Server/Model/Module/Message/";
+        private const string clientMessagePath = "../../../Unity/Assets/Model/Generate/Message/";
+        private const string serverMessagePath = "../../../Server/Model/Generate/Message/";
         private static readonly char[] splitChars = { ' ', '\t' };
         private static readonly List<OpcodeInfo> msgOpcode = new List<OpcodeInfo>();
 
         public static void Proto2CS()
         {
             msgOpcode.Clear();
-            Proto2CS("ET", "InnerMessage.proto", serverMessagePath, "InnerOpcode", 10000);
+            Proto2CS("ET", "../../../Proto/InnerMessage.proto", serverMessagePath, "InnerOpcode", 10000);
             GenerateOpcode("ET", "InnerOpcode", serverMessagePath);
             
-            Proto2CS("ET", "OuterMessage.proto", clientMessagePath, "OuterOpcode", 20000);
+            Proto2CS("ET", "../../../Proto/OuterMessage.proto", serverMessagePath, "OuterOpcode", 20000);
+            GenerateOpcode("ET", "OuterOpcode", serverMessagePath);
+            
+            Proto2CS("ET", "../../../Proto/OuterMessage.proto", clientMessagePath, "OuterOpcode", 20000);
             GenerateOpcode("ET", "OuterOpcode", clientMessagePath);
+            
+ 
         }
 
         public static void Proto2CS(string ns, string protoName, string outputPath, string opcodeClassName, int startOpcode)
         {
+            if (!Directory.Exists(outputPath))
+            {
+                Directory.CreateDirectory(outputPath);
+            }
+            
             msgOpcode.Clear();
             string proto = Path.Combine(protoPath, protoName);
             string csPath = Path.Combine(outputPath, Path.GetFileNameWithoutExtension(proto) + ".cs");
@@ -65,6 +75,13 @@ namespace ET
                 {
                     continue;
                 }
+                
+                if (newline.StartsWith("//ResponseType"))
+                {
+                    string responseType = line.Split(" ")[1];
+                    sb.AppendLine($"\t[ResponseType(typeof({responseType}))]");
+                    continue;
+                }
 
                 if (newline.StartsWith("//"))
                 {
@@ -140,12 +157,17 @@ namespace ET
             }
 
             sb.Append("}\n");
-
-            File.WriteAllText(csPath, sb.ToString());
+            using FileStream txt = new FileStream(csPath, FileMode.Create, FileAccess.ReadWrite);
+            using StreamWriter sw = new StreamWriter(txt);
+            sw.Write(sb.ToString());
         }
 
         private static void GenerateOpcode(string ns, string outputFileName, string outputPath)
         {
+            if (!Directory.Exists(outputPath))
+            {
+                Directory.CreateDirectory(outputPath);
+            }
             StringBuilder sb = new StringBuilder();
             sb.AppendLine($"namespace {ns}");
             sb.AppendLine("{");
@@ -160,7 +182,10 @@ namespace ET
             sb.AppendLine("}");
 
             string csPath = Path.Combine(outputPath, outputFileName + ".cs");
-            File.WriteAllText(csPath, sb.ToString());
+            
+            using FileStream txt = new FileStream(csPath, FileMode.Create);
+            using StreamWriter sw = new StreamWriter(txt);
+            sw.Write(sb.ToString());
         }
 
         private static void Repeated(StringBuilder sb, string ns, string newline)

+ 1 - 1
Unity/Assets/Hotfix/Module/Message/NetKcpComponentSystem.cs

@@ -103,7 +103,7 @@ namespace ET
             Session session = EntityFactory.CreateWithParentAndId<Session, AService>(self, channelId, self.Service);
             session.RemoteAddress = realIPEndPoint;
             session.AddComponent<SessionIdleCheckerComponent, int>(NetThreadComponent.checkInteral);
-
+            
             self.Service.GetOrCreate(session.Id, realIPEndPoint);
 
             return session;

+ 1 - 0
Unity/Assets/Hotfix/Scene/LoginHelper.cs

@@ -18,6 +18,7 @@ namespace ET
 
                 // 创建一个gate Session,并且保存到SessionComponent中
                 Session gateSession = zoneScene.GetComponent<NetKcpComponent>().Create(NetworkHelper.ToIPEndPoint(r2CLogin.Address));
+                gateSession.AddComponent<PingComponent>();
                 zoneScene.AddComponent<SessionComponent>().Session = gateSession;
 				
                 G2C_LoginGate g2CLoginGate = (G2C_LoginGate)await gateSession.Call(

+ 2 - 2
Unity/Assets/Model/Core/Object/TimeInfo.cs

@@ -28,7 +28,7 @@ namespace ET
 
         public long FrameTime;
 
-        public TimeInfo()
+        private TimeInfo()
         {
             this.FrameTime = this.ClientNow();
         }
@@ -49,7 +49,7 @@ namespace ET
         // 线程安全
         public long ClientNow()
         {
-            return DateTime.Now.Ticks - this.dt1970.Ticks;
+            return (DateTime.Now.Ticks - this.dt1970.Ticks) / 10000;
         }
         
         public long ServerNow()

+ 8 - 0
Unity/Assets/Model/Generate/Message.meta

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

+ 28 - 9
Unity/Assets/Model/Generate/OuterProtoMessage.cs → Unity/Assets/Model/Generate/Message/OuterMessage.cs

@@ -3,17 +3,25 @@ using ProtoBuf;
 using System.Collections.Generic;
 namespace ET
 {
-	[Message(OuterOpcode.C2G_Ping)]
+	[ResponseType(typeof(M2C_TestResponse))]
+	[Message(OuterOpcode.C2M_TestRequest)]
 	[ProtoContract]
-	public partial class C2G_Ping: IRequest
+	public partial class C2M_TestRequest: IActorLocationRequest
 	{
 		[ProtoMember(90)]
 		public int RpcId { get; set; }
+
+		[ProtoMember(93)]
+		public long ActorId { get; set; }
+
+		[ProtoMember(1)]
+		public string request { get; set; }
+
 	}
 
-	[Message(OuterOpcode.G2C_Ping)]
+	[Message(OuterOpcode.M2C_TestResponse)]
 	[ProtoContract]
-	public partial class G2C_Ping: IActorLocationResponse
+	public partial class M2C_TestResponse: IActorLocationResponse
 	{
 		[ProtoMember(90)]
 		public int RpcId { get; set; }
@@ -25,10 +33,11 @@ namespace ET
 		public string Message { get; set; }
 
 		[ProtoMember(1)]
-		public long Time { get; set; }
+		public string response { get; set; }
 
 	}
 
+	[ResponseType(typeof(Actor_TransferResponse))]
 	[Message(OuterOpcode.Actor_TransferRequest)]
 	[ProtoContract]
 	public partial class Actor_TransferRequest: IActorLocationRequest
@@ -59,6 +68,7 @@ namespace ET
 
 	}
 
+	[ResponseType(typeof(G2C_EnterMap))]
 	[Message(OuterOpcode.C2G_EnterMap)]
 	[ProtoContract]
 	public partial class C2G_EnterMap: IRequest
@@ -180,18 +190,19 @@ namespace ET
 
 	}
 
-	[Message(OuterOpcode.C2R_Ping)]
+	[ResponseType(typeof(G2C_Ping))]
+	[Message(OuterOpcode.C2G_Ping)]
 	[ProtoContract]
-	public partial class C2R_Ping: IRequest
+	public partial class C2G_Ping: IRequest
 	{
 		[ProtoMember(90)]
 		public int RpcId { get; set; }
 
 	}
 
-	[Message(OuterOpcode.R2C_Ping)]
+	[Message(OuterOpcode.G2C_Ping)]
 	[ProtoContract]
-	public partial class R2C_Ping: IResponse
+	public partial class G2C_Ping: IResponse
 	{
 		[ProtoMember(90)]
 		public int RpcId { get; set; }
@@ -202,6 +213,9 @@ namespace ET
 		[ProtoMember(92)]
 		public string Message { get; set; }
 
+		[ProtoMember(1)]
+		public long Time { get; set; }
+
 	}
 
 	[Message(OuterOpcode.G2C_Test)]
@@ -210,6 +224,7 @@ namespace ET
 	{
 	}
 
+	[ResponseType(typeof(M2C_Reload))]
 	[Message(OuterOpcode.C2M_Reload)]
 	[ProtoContract]
 	public partial class C2M_Reload: IRequest
@@ -240,6 +255,7 @@ namespace ET
 
 	}
 
+	[ResponseType(typeof(R2C_Login))]
 	[Message(OuterOpcode.C2R_Login)]
 	[ProtoContract]
 	public partial class C2R_Login: IRequest
@@ -279,6 +295,7 @@ namespace ET
 
 	}
 
+	[ResponseType(typeof(G2C_LoginGate))]
 	[Message(OuterOpcode.C2G_LoginGate)]
 	[ProtoContract]
 	public partial class C2G_LoginGate: IRequest
@@ -321,6 +338,7 @@ namespace ET
 
 	}
 
+	[ResponseType(typeof(M2C_TestActorResponse))]
 	[Message(OuterOpcode.C2M_TestActorRequest)]
 	[ProtoContract]
 	public partial class C2M_TestActorRequest: IActorLocationRequest
@@ -363,6 +381,7 @@ namespace ET
 
 	}
 
+	[ResponseType(typeof(G2C_PlayerInfo))]
 	[Message(OuterOpcode.C2G_PlayerInfo)]
 	[ProtoContract]
 	public partial class C2G_PlayerInfo: IRequest

+ 1 - 1
Unity/Assets/Model/Generate/OuterProtoMessage.cs.meta → Unity/Assets/Model/Generate/Message/OuterMessage.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: b150ee0832ac9442ab93655b90a82caf
+guid: 044fa867eb79745f4b119b77e4db9c41
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 31 - 0
Unity/Assets/Model/Generate/Message/OuterOpcode.cs

@@ -0,0 +1,31 @@
+namespace ET
+{
+	public static partial class OuterOpcode
+	{
+		 public const ushort C2M_TestRequest = 20001;
+		 public const ushort M2C_TestResponse = 20002;
+		 public const ushort Actor_TransferRequest = 20003;
+		 public const ushort Actor_TransferResponse = 20004;
+		 public const ushort C2G_EnterMap = 20005;
+		 public const ushort G2C_EnterMap = 20006;
+		 public const ushort UnitInfo = 20007;
+		 public const ushort M2C_CreateUnits = 20008;
+		 public const ushort Frame_ClickMap = 20009;
+		 public const ushort M2C_PathfindingResult = 20010;
+		 public const ushort C2G_Ping = 20011;
+		 public const ushort G2C_Ping = 20012;
+		 public const ushort G2C_Test = 20013;
+		 public const ushort C2M_Reload = 20014;
+		 public const ushort M2C_Reload = 20015;
+		 public const ushort C2R_Login = 20016;
+		 public const ushort R2C_Login = 20017;
+		 public const ushort C2G_LoginGate = 20018;
+		 public const ushort G2C_LoginGate = 20019;
+		 public const ushort G2C_TestHotfixMessage = 20020;
+		 public const ushort C2M_TestActorRequest = 20021;
+		 public const ushort M2C_TestActorResponse = 20022;
+		 public const ushort PlayerInfo = 20023;
+		 public const ushort C2G_PlayerInfo = 20024;
+		 public const ushort G2C_PlayerInfo = 20025;
+	}
+}

+ 1 - 1
Unity/Assets/Model/Generate/OuterProtoOpcode.cs.meta → Unity/Assets/Model/Generate/Message/OuterOpcode.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: c44825a92c0e84e4087e616edbdd0ac6
+guid: 731471567040e43da827c2acfd5c2f7b
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 0 - 31
Unity/Assets/Model/Generate/OuterProtoOpcode.cs

@@ -1,31 +0,0 @@
-namespace ET
-{
-    public static partial class OuterOpcode
-    {
-        public const ushort C2G_Ping = 20001;
-        public const ushort G2C_Ping = 20002;
-        public const ushort Actor_TransferRequest = 20003;
-        public const ushort Actor_TransferResponse = 20004;
-        public const ushort C2G_EnterMap = 20005;
-        public const ushort G2C_EnterMap = 20006;
-        public const ushort UnitInfo = 20007;
-        public const ushort M2C_CreateUnits = 20008;
-        public const ushort Frame_ClickMap = 20009;
-        public const ushort M2C_PathfindingResult = 20010;
-        public const ushort C2R_Ping = 20011;
-        public const ushort R2C_Ping = 20012;
-        public const ushort G2C_Test = 20013;
-        public const ushort C2M_Reload = 20014;
-        public const ushort M2C_Reload = 20015;
-        public const ushort C2R_Login = 20016;
-        public const ushort R2C_Login = 20017;
-        public const ushort C2G_LoginGate = 20018;
-        public const ushort G2C_LoginGate = 20019;
-        public const ushort G2C_TestHotfixMessage = 20020;
-        public const ushort C2M_TestActorRequest = 20021;
-        public const ushort M2C_TestActorResponse = 20022;
-        public const ushort PlayerInfo = 20023;
-        public const ushort C2G_PlayerInfo = 20024;
-        public const ushort G2C_PlayerInfo = 20025;
-    }
-}

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

@@ -63,7 +63,6 @@ namespace ET
                     this.outrActorMessage.Add(messageAttribute.Opcode);
                 }
                 
-                /*
                 // 检查request response
                 if (typeof (IRequest).IsAssignableFrom(type))
                 {
@@ -83,7 +82,6 @@ namespace ET
                     ResponseTypeAttribute responseTypeAttribute = attrs[0] as ResponseTypeAttribute;
                     this.requestResponse.Add(type, responseTypeAttribute.Type);
                 }
-                */
             }
         }
 
@@ -106,7 +104,7 @@ namespace ET
         {
             if (!this.requestResponse.TryGetValue(request, out Type response))
             {
-                throw new Exception($"not found response type, request type: {request.GetType()}");
+                throw new Exception($"not found response type, request type: {request.GetType().Name}");
             }
             return response;
         }

+ 1 - 1
Unity/Assets/Model/Module/NetworkTCP/TChannel.cs

@@ -392,7 +392,7 @@ namespace ET
 
 		private void OnError(int error)
 		{
-			Log.Debug($"TChannel error: {error} {this.RemoteAddress}");
+			Log.Error($"TChannel error: {error} {this.RemoteAddress}");
 			
 			long channelId = this.Id;
 			

+ 1 - 1
Unity/Assets/Model/Module/Resource/ResourcesComponent.cs

@@ -489,7 +489,7 @@ namespace ET
 
                 if (isScene)
                 {
-                    p = Path.Combine(Application.dataPath, "../../AssetBundles/Windows_Scene/", assetBundleName);
+                    p = Path.Combine(Application.dataPath, "../SceneBundle/", assetBundleName);
                     if (File.Exists(p)) // 如果场景有预先打包
                     {
                         using (AssetsBundleLoaderAsync assetsBundleLoaderAsync = EntityFactory.CreateWithParent<AssetsBundleLoaderAsync>(this))

+ 2 - 2
Unity/Unity.Model.csproj

@@ -101,7 +101,6 @@
      <Compile Include="Assets\Model\Core\Event\IEvent.cs" />
      <Compile Include="Assets\Model\Module\Message\SessionCallbackComponent.cs" />
      <Compile Include="Assets\Model\Module\Network\Circularbuffer.cs" />
-     <Compile Include="Assets\Model\Generate\OuterProtoMessage.cs" />
      <Compile Include="Assets\Model\Module\ActorLocation\IActorLocationMessage.cs" />
      <Compile Include="Assets\Model\Core\Async\AsyncMethodBuilderAttribute.cs" />
      <Compile Include="Assets\Model\Core\MultiDictionary.cs" />
@@ -173,7 +172,6 @@
      <Compile Include="Assets\Model\Module\CoroutineLock\CoroutineLock.cs" />
      <Compile Include="Assets\Model\Module\Message\ErrorCode.cs" />
      <Compile Include="Assets\Model\Module\NetworkTCP\PacketParser.cs" />
-     <Compile Include="Assets\Model\Generate\OuterProtoOpcode.cs" />
      <Compile Include="Assets\Model\Core\Object\ProtoObject.cs" />
      <Compile Include="Assets\Model\Module\Message\ProtobufHelper.cs" />
      <Compile Include="Assets\Model\Generate\Config\StartSceneConfig.cs" />
@@ -199,6 +197,8 @@
      <Compile Include="Assets\Model\Core\Async\ETTaskHelper.cs" />
      <Compile Include="Assets\Model\Module\NetworkTCP\TChannel.cs" />
      <Compile Include="Assets\Model\Module\Network\AChannel.cs" />
+     <Compile Include="Assets\Model\Generate\Message\OuterOpcode.cs" />
+     <Compile Include="Assets\Model\Generate\Message\OuterMessage.cs" />
      <None Include="Assets\Model\Unity.Model.asmdef" />
  <Reference Include="UnityEngine">
  <HintPath>/Applications/Unity/Hub/Editor/2020.2.2f1c1/Unity.app/Contents/Managed/UnityEngine/UnityEngine.dll</HintPath>