diff --git a/Proto/InnerMessage.proto b/Proto/InnerMessage.proto index 192aae8bcce1301a0358e0a5244d5fe6acbcf973..df2ddb1de3139e4d615953df8bc09506d720c4a7 100644 --- a/Proto/InnerMessage.proto +++ b/Proto/InnerMessage.proto @@ -4,6 +4,7 @@ package ET; /// /// 传送unit /// +//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; diff --git a/Proto/OuterMessage.proto b/Proto/OuterMessage.proto index 726abec4d890819090e9bb55695eab211d294ac9..479a938c11f6fa19bc1129d0f555d1620df2ba01 100644 --- a/Proto/OuterMessage.proto +++ b/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; diff --git a/Server/App/Program.cs b/Server/App/Program.cs index ca43c150bff75e6d287ea69ae8fd3df8cd48b17e..c3456a14bce530157099db5f85b8c9db530a821e 100644 --- a/Server/App/Program.cs +++ b/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) { diff --git a/Server/Hotfix/Handler/C2G_PingHandler.cs b/Server/Hotfix/Handler/C2G_PingHandler.cs new file mode 100644 index 0000000000000000000000000000000000000000..83ec3e701b1d5fd042a78984f9881613bfdfd80e --- /dev/null +++ b/Server/Hotfix/Handler/C2G_PingHandler.cs @@ -0,0 +1,16 @@ +using System; + + +namespace ET +{ + [MessageHandler] + public class C2G_PingHandler : AMRpcHandler + { + protected override async ETTask Run(Session session, C2G_Ping request, G2C_Ping response, Action reply) + { + response.Time = TimeHelper.ServerNow(); + reply(); + await ETTask.CompletedTask; + } + } +} \ No newline at end of file diff --git a/Server/Hotfix/Handler/C2R_PingHandler.cs b/Server/Hotfix/Handler/C2R_PingHandler.cs deleted file mode 100644 index 8a6b353f6873f479752fec964ad9501337dd6ce5..0000000000000000000000000000000000000000 --- a/Server/Hotfix/Handler/C2R_PingHandler.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; - - -namespace ET -{ - [MessageHandler] - public class C2R_PingHandler : AMRpcHandler - { - protected override async ETTask Run(Session session, C2R_Ping request, R2C_Ping response, Action reply) - { - reply(); - await ETTask.CompletedTask; - } - } -} \ No newline at end of file diff --git a/Server/Model/Generate/InnerProtoOpcode.cs b/Server/Model/Generate/InnerProtoOpcode.cs deleted file mode 100644 index dc64c8887971e36ac342d9a6cc9112564aeda6bf..0000000000000000000000000000000000000000 --- a/Server/Model/Generate/InnerProtoOpcode.cs +++ /dev/null @@ -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; - } -} \ No newline at end of file diff --git a/Server/Model/Generate/InnerProtoMessage.cs b/Server/Model/Generate/Message/InnerMessage.cs similarity index 94% rename from Server/Model/Generate/InnerProtoMessage.cs rename to Server/Model/Generate/Message/InnerMessage.cs index 2f33542a16be85262d6c7fc2c5fbd814690ea5fe..1cf96f9eace9df1115647896b9a3a0c46f1b79a9 100644 --- a/Server/Model/Generate/InnerProtoMessage.cs +++ b/Server/Model/Generate/Message/InnerMessage.cs @@ -6,6 +6,7 @@ namespace ET /// /// 传送unit /// + [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 diff --git a/Server/Model/Generate/Message/InnerOpcode.cs b/Server/Model/Generate/Message/InnerOpcode.cs new file mode 100644 index 0000000000000000000000000000000000000000..aaf516c3c62b9a8ffa79cea379f01e51bbc13ee0 --- /dev/null +++ b/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; + } +} diff --git a/Server/Model/Generate/OuterProtoMessage.cs b/Server/Model/Generate/Message/OuterMessage.cs similarity index 93% rename from Server/Model/Generate/OuterProtoMessage.cs rename to Server/Model/Generate/Message/OuterMessage.cs index e6faf912f7fa0edc16f659d505d955e1df12dd2c..7fe16be2dd565bbc1edaea8672b02feac9ba942c 100644 --- a/Server/Model/Generate/OuterProtoMessage.cs +++ b/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 diff --git a/Server/Model/Generate/Message/OuterOpcode.cs b/Server/Model/Generate/Message/OuterOpcode.cs new file mode 100644 index 0000000000000000000000000000000000000000..7002d0a40d2f7fd982d2102f5656d881ced858cd --- /dev/null +++ b/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; + } +} diff --git a/Server/Model/Generate/OuterProtoOpcode.cs b/Server/Model/Generate/OuterProtoOpcode.cs deleted file mode 100644 index 0bc1ed983d62d2cb61f9db3ab6cb9615977306de..0000000000000000000000000000000000000000 --- a/Server/Model/Generate/OuterProtoOpcode.cs +++ /dev/null @@ -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; - } -} \ No newline at end of file diff --git a/Tools/Proto2CS/Program.cs b/Tools/Proto2CS/Program.cs index 8282c8052ab66d431935e1d646cac2c7876dde69..1cc6d9c278ced1d169fa4eebd843684af63ed1db 100644 --- a/Tools/Proto2CS/Program.cs +++ b/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 msgOpcode = new List(); 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) diff --git a/Unity/Assets/Hotfix/Module/Message/NetKcpComponentSystem.cs b/Unity/Assets/Hotfix/Module/Message/NetKcpComponentSystem.cs index 3ce388591ed8fed736c9d8bf03b8fd734b300e8a..9e34d6b779f6e1283a64585cd41e12c79f9e0d74 100644 --- a/Unity/Assets/Hotfix/Module/Message/NetKcpComponentSystem.cs +++ b/Unity/Assets/Hotfix/Module/Message/NetKcpComponentSystem.cs @@ -103,7 +103,7 @@ namespace ET Session session = EntityFactory.CreateWithParentAndId(self, channelId, self.Service); session.RemoteAddress = realIPEndPoint; session.AddComponent(NetThreadComponent.checkInteral); - + self.Service.GetOrCreate(session.Id, realIPEndPoint); return session; diff --git a/Unity/Assets/Hotfix/Scene/LoginHelper.cs b/Unity/Assets/Hotfix/Scene/LoginHelper.cs index 1a9c5a5a306a4905e021e275f4099062385174db..175a6af2bf15f5de8a5acf60d1c8bd0decc0a54a 100644 --- a/Unity/Assets/Hotfix/Scene/LoginHelper.cs +++ b/Unity/Assets/Hotfix/Scene/LoginHelper.cs @@ -18,6 +18,7 @@ namespace ET // 创建一个gate Session,并且保存到SessionComponent中 Session gateSession = zoneScene.GetComponent().Create(NetworkHelper.ToIPEndPoint(r2CLogin.Address)); + gateSession.AddComponent(); zoneScene.AddComponent().Session = gateSession; G2C_LoginGate g2CLoginGate = (G2C_LoginGate)await gateSession.Call( diff --git a/Unity/Assets/Model/Core/Object/TimeInfo.cs b/Unity/Assets/Model/Core/Object/TimeInfo.cs index 98eecf995e3189a483a6308b278c59f91cc9d367..9bc09cf4b0000062f24829a80d29c4b5d8e549b8 100644 --- a/Unity/Assets/Model/Core/Object/TimeInfo.cs +++ b/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() diff --git a/Unity/Assets/Model/Generate/Message.meta b/Unity/Assets/Model/Generate/Message.meta new file mode 100644 index 0000000000000000000000000000000000000000..e4c10e9eda650b20a72e1f0220f127b04fbcf01b --- /dev/null +++ b/Unity/Assets/Model/Generate/Message.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b78b87e70906a438ba5b820ca91d645f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Model/Generate/OuterProtoMessage.cs b/Unity/Assets/Model/Generate/Message/OuterMessage.cs similarity index 90% rename from Unity/Assets/Model/Generate/OuterProtoMessage.cs rename to Unity/Assets/Model/Generate/Message/OuterMessage.cs index cd9b674651478a92fee0f3cad20a9fdd83136180..7fe16be2dd565bbc1edaea8672b02feac9ba942c 100644 --- a/Unity/Assets/Model/Generate/OuterProtoMessage.cs +++ b/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 diff --git a/Unity/Assets/Model/Generate/OuterProtoMessage.cs.meta b/Unity/Assets/Model/Generate/Message/OuterMessage.cs.meta similarity index 83% rename from Unity/Assets/Model/Generate/OuterProtoMessage.cs.meta rename to Unity/Assets/Model/Generate/Message/OuterMessage.cs.meta index cb769e305af80b979a6ceedb3aa7b05bbbda0e0b..73603f84924199effff9a9d7d4cf7f6d002b9b43 100644 --- a/Unity/Assets/Model/Generate/OuterProtoMessage.cs.meta +++ b/Unity/Assets/Model/Generate/Message/OuterMessage.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: b150ee0832ac9442ab93655b90a82caf +guid: 044fa867eb79745f4b119b77e4db9c41 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Unity/Assets/Model/Generate/Message/OuterOpcode.cs b/Unity/Assets/Model/Generate/Message/OuterOpcode.cs new file mode 100644 index 0000000000000000000000000000000000000000..7002d0a40d2f7fd982d2102f5656d881ced858cd --- /dev/null +++ b/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; + } +} diff --git a/Unity/Assets/Model/Generate/OuterProtoOpcode.cs.meta b/Unity/Assets/Model/Generate/Message/OuterOpcode.cs.meta similarity index 83% rename from Unity/Assets/Model/Generate/OuterProtoOpcode.cs.meta rename to Unity/Assets/Model/Generate/Message/OuterOpcode.cs.meta index 16f932107db546f6791d5d00a074c3b576546bc7..89e1e672cb7f364aabf89b9e4f4013d72ec2e875 100644 --- a/Unity/Assets/Model/Generate/OuterProtoOpcode.cs.meta +++ b/Unity/Assets/Model/Generate/Message/OuterOpcode.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: c44825a92c0e84e4087e616edbdd0ac6 +guid: 731471567040e43da827c2acfd5c2f7b MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Unity/Assets/Model/Generate/OuterProtoOpcode.cs b/Unity/Assets/Model/Generate/OuterProtoOpcode.cs deleted file mode 100644 index 21798c623fc1a008a5be70affdfa6602917df01b..0000000000000000000000000000000000000000 --- a/Unity/Assets/Model/Generate/OuterProtoOpcode.cs +++ /dev/null @@ -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; - } -} \ No newline at end of file diff --git a/Unity/Assets/Model/Module/Message/OpcodeTypeComponent.cs b/Unity/Assets/Model/Module/Message/OpcodeTypeComponent.cs index 1514d001eeff27a4b067430ce4063364e62a82ba..1b34bdf43cb167ca2ba1caff2907dfdea9aef061 100644 --- a/Unity/Assets/Model/Module/Message/OpcodeTypeComponent.cs +++ b/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; } diff --git a/Unity/Assets/Model/Module/NetworkTCP/TChannel.cs b/Unity/Assets/Model/Module/NetworkTCP/TChannel.cs index c1d39229856f2bc9a6a22d45244fc0768d8938a0..04c9e61bf1ae3a5f7bad08b7917e97f625153eb5 100644 --- a/Unity/Assets/Model/Module/NetworkTCP/TChannel.cs +++ b/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; diff --git a/Unity/Assets/Model/Module/Resource/ResourcesComponent.cs b/Unity/Assets/Model/Module/Resource/ResourcesComponent.cs index 6be0fdd7b4264e90a807efb58f53f52823f084ce..5c9e0532a17fcb049d43dcd3e93f287a2c334b56 100644 --- a/Unity/Assets/Model/Module/Resource/ResourcesComponent.cs +++ b/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(this)) diff --git a/Unity/Unity.Model.csproj b/Unity/Unity.Model.csproj index d8ddcee78fa4a4da0c73bbf094c79f5b83a18ffc..312d2b58902d2634968825d8180c735e4736e224 100644 --- a/Unity/Unity.Model.csproj +++ b/Unity/Unity.Model.csproj @@ -101,7 +101,6 @@ - @@ -173,7 +172,6 @@ - @@ -199,6 +197,8 @@ + + /Applications/Unity/Hub/Editor/2020.2.2f1c1/Unity.app/Contents/Managed/UnityEngine/UnityEngine.dll