diff --git a/Client.cs b/Client.cs index f377022..7c0bf94 100644 --- a/Client.cs +++ b/Client.cs @@ -27,10 +27,18 @@ namespace BattleServer private void doBinary(byte[] message) { BattleRpcMessage msg = ProtoDeSerialize(message); + Console.WriteLine("接收到消息 {0}",msg.method); // Pb.BattleRpcMessage msg = Deserialize(message); - Task.Run(() =>{ + Task t = Task.Run(() =>{ handle(msg); }); + + t.ContinueWith(r => + { + //Thread.Sleep(3000); + string Exception = Convert.ToString(t.Exception); + Console.WriteLine("消息处理异常:" + Exception); + }, TaskContinuationOptions.OnlyOnFaulted); } /// @@ -39,24 +47,28 @@ namespace BattleServer /// private void handle(BattleRpcMessage msg) { - try{ - Console.WriteLine("收到战斗消息:{0}", msg.method); - switch(msg.method){ - case "Check": - BattleReport report = ProtoDeSerialize(msg.data.value); - bool ischeck = HotUpdateScripts.FightRunnerMgr.Instance.VerifyOnceFight(report); - Console.WriteLine("战斗校验结果:{0}", ischeck); - msg.data = new Google.Protobuf.WellKnownTypes.Any { - type_url = "type.googleapis.com/BattleCheckResults", - value = ProtoSerialize(new BattleCheckResults{ischeck=ischeck}), - }; - socket.Send(ProtoSerialize(msg)); - break; - } - } catch (IOException ex){ - Console.WriteLine("战斗异常 {0}",ex.Message); - socket.Close(); + + long ts = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000; + Console.WriteLine("接收到战斗消息 1 {0}|{1}",msg.method,ts); + switch(msg.method){ + case "Check": + BattleReport report = ProtoDeSerialize(msg.data.value); + ts = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000; + Console.WriteLine("接收到战斗消息 2 |{0}",ts); + bool ischeck = HotUpdateScripts.FightRunnerMgr.Instance.VerifyOnceFight(report); + ts = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000; + Console.WriteLine("接收到战斗消息 3 |{0}",ts); + msg.data = new Google.Protobuf.WellKnownTypes.Any { + type_url = "type.googleapis.com/BattleCheckResults", + value = ProtoSerialize(new BattleCheckResults{ischeck=ischeck}), + }; + byte[] _msg = ProtoSerialize(msg); + ts = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000; + Console.WriteLine("接收到战斗消息 4 |{0}",ts); + socket.Send(_msg); + break; } + } /// diff --git a/Program.cs b/Program.cs index d1e5cb1..3ae8478 100644 --- a/Program.cs +++ b/Program.cs @@ -10,10 +10,10 @@ namespace BattleServer { HotUpdateScripts.FightRunnerMgr.Instance.Init("./GameConfig/"); cfg.Game.HeroData data = HotUpdateScripts.FightBase.GC.Hero.Get("25001"); - HotUpdateScripts.FightDebug.Log("测试读取配置 name:"+data.Name); - Console.WriteLine("BattleServer Start!"); + // HotUpdateScripts.FightDebug.Log("测试读取配置 name:"+data.Name); Service service = new Service(); - Console.ReadKey(); + Console.WriteLine("BattleServer Start!"); + Thread.Sleep(Timeout.Infinite); } } } \ No newline at end of file diff --git a/obj/Debug/net6.0/dfbattle.GeneratedMSBuildEditorConfig.editorconfig b/obj/Debug/net6.0/dfbattle.GeneratedMSBuildEditorConfig.editorconfig index 31327a7..8265cfe 100644 --- a/obj/Debug/net6.0/dfbattle.GeneratedMSBuildEditorConfig.editorconfig +++ b/obj/Debug/net6.0/dfbattle.GeneratedMSBuildEditorConfig.editorconfig @@ -7,4 +7,4 @@ build_property.InvariantGlobalization = build_property.PlatformNeutralAssembly = build_property._SupportedPlatformList = Linux,macOS,Windows build_property.RootNamespace = dfbattle -build_property.ProjectDir = F:\work\c#\dfbattle\ +build_property.ProjectDir = f:\work\c#\dfbattle\ diff --git a/obj/Debug/net6.0/dfbattle.assets.cache b/obj/Debug/net6.0/dfbattle.assets.cache index 21832a2..34defa8 100644 Binary files a/obj/Debug/net6.0/dfbattle.assets.cache and b/obj/Debug/net6.0/dfbattle.assets.cache differ