From 522577fc1f64bc294d34578cc46586373ca65380 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Sun, 4 Feb 2024 11:35:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=89=AB=E8=8D=A1=E6=AD=A3?= =?UTF-8?q?=E5=BC=8F=E6=8E=A5=E5=85=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/battle/battleclient.go | 20 +++++++++++++++----- modules/battle/module.go | 3 +-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/modules/battle/battleclient.go b/modules/battle/battleclient.go index 1bafb7b72..714bbf7e9 100644 --- a/modules/battle/battleclient.go +++ b/modules/battle/battleclient.go @@ -107,14 +107,24 @@ locp: } func (this *client) handleresponse(resp *pb.BattleRpcMessage) { - var call *MessageCall + var ( + call *MessageCall + ok bool + ) + if resp.Rid != 0 { this.pendingmutex.Lock() - call = this.pending[resp.Rid] - delete(this.pending, resp.Rid) + call, ok = this.pending[resp.Rid] + if ok { + delete(this.pending, resp.Rid) + } this.pendingmutex.Unlock() - call.Error = resp.Data.UnmarshalTo(call.Reply) - call.done(this.log) + if ok { + call.Error = resp.Data.UnmarshalTo(call.Reply) + call.done(this.log) + } else { + this.log.Warnf("C# Reply ON Fiund Method:%s Rid:%s", resp.Method, resp.Rid) + } } else { switch resp.Method { case "BattleOutCmd": //输出指令 diff --git a/modules/battle/module.go b/modules/battle/module.go index 87cd605e1..2f306c015 100644 --- a/modules/battle/module.go +++ b/modules/battle/module.go @@ -696,8 +696,7 @@ func (this *Battle) RunServerBattle(session comm.IUserSession, req *pb.BattleRun ctx context.Context err error ) - // if this.options.OpenCheck { - if false { + if this.options.OpenCheck { stime := time.Now() ctx, _ = context.WithTimeout(context.Background(), time.Second*5) if reply, err = this.clientmgr.RunBattle(ctx, req); err != nil {