上传代码

This commit is contained in:
liwei1dao 2023-02-02 11:03:11 +08:00
parent 00ee9c35ab
commit 628f673aec
4 changed files with 34 additions and 22 deletions

View File

@ -27,10 +27,18 @@ namespace BattleServer
private void doBinary(byte[] message)
{
BattleRpcMessage msg = ProtoDeSerialize<BattleRpcMessage>(message);
Console.WriteLine("接收到消息 {0}",msg.method);
// Pb.BattleRpcMessage msg = Deserialize<Pb.BattleRpcMessage>(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);
}
/// <summary>
@ -39,24 +47,28 @@ namespace BattleServer
/// <param name="msg"></param>
private void handle(BattleRpcMessage msg)
{
try{
Console.WriteLine("收到战斗消息:{0}", msg.method);
switch(msg.method){
case "Check":
BattleReport report = ProtoDeSerialize<BattleReport>(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<BattleReport>(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;
}
}
/// <summary>

View File

@ -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);
}
}
}

View File

@ -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\