From f1409ff23aa6bcda1d53b6bd96dbb1a7cbaaf884 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Mon, 13 Mar 2023 10:31:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E9=89=B4=E6=95=B0=E6=8D=AE=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/imodule.go | 2 +- modules/hero/module.go | 14 +++++++------- modules/library/module.go | 19 +++++++++---------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/comm/imodule.go b/comm/imodule.go index 4245e1446..45a9e7a47 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -295,7 +295,7 @@ type ( ModifyHeroFetterData(uid string, obj string, data map[string]interface{}) (code pb.ErrorCode) // 修改羁绊信息 QueryHeroFetter(uid string) (data []*pb.DBHeroFetter) // 查询所有的羁绊信息 AddHeroFetterData(uid string, heroConfId string) (code pb.ErrorCode) // 创建一条羁绊信息 - SendRpcAddHero(session IUserSession, heroConfId string) (err error) + SendRpcAddHero(uid string, heroConfId string, serverTag string) (err error) } //月子秘境 IMoonFantasy interface { diff --git a/modules/hero/module.go b/modules/hero/module.go index 87b6f5ea1..d5371c5af 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -83,13 +83,13 @@ func (this *Hero) createRepeatHero(session comm.IUserSession, heroCfgId string, ) hero, bFirst, atno, err = this.modelHero.createHero(session, heroCfgId, num) if err == nil && bFirst { - //go func(uid string, heroCfgId string) { // 携程处理 图鉴数据 - if db.IsCross() { - this.moduleFetter.SendRpcAddHero(session, heroCfgId) - } else { - this.moduleFetter.AddHeroFetterData(session.GetUserId(), heroCfgId) - } - //}(session.GetUserId(), heroCfgId) + go func() { // 携程处理 图鉴数据 + if db.IsCross() { + this.moduleFetter.SendRpcAddHero(session.GetUserId(), heroCfgId, session.GetServiecTag()) + } else { + this.moduleFetter.AddHeroFetterData(session.GetUserId(), heroCfgId) + } + }() // 统计任务 // 查品质 diff --git a/modules/library/module.go b/modules/library/module.go index 702d491d3..6bbdfc742 100644 --- a/modules/library/module.go +++ b/modules/library/module.go @@ -3,7 +3,6 @@ package library import ( "context" "errors" - "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/base" "go_dreamfactory/lego/core" @@ -155,14 +154,15 @@ func (this *Library) QueryOneHeroFetter(uid string, cid string) *pb.DBHeroFetter } // 发送prc消息到区服处理 -func (this *Library) SendRpcAddHero(session comm.IUserSession, heroConfId string) (err error) { +func (this *Library) SendRpcAddHero(uid string, heroConfId string, serverTag string) (err error) { if this.IsCross() { + if _, err = this.service.AcrossClusterRpcGo( // 给区服发送rpc消息 context.Background(), - session.GetServiecTag(), + serverTag, comm.Service_Worker, string(comm.Rpc_ModuleFetter), - pb.RPCGeneralReqA2{Param1: session.GetUserId(), Param2: heroConfId}, + pb.RPCGeneralReqA2{Param1: uid, Param2: heroConfId}, nil); err != nil { this.Errorln(err) } @@ -253,15 +253,14 @@ func (this *Library) Rpc_ModuleFetter(ctx context.Context, args *pb.RPCGeneralRe session comm.IUserSession ok bool ) - defer func() { - this.PutUserSession(session) - }() - if session, ok = this.GetUserSession(args.Param1); !ok { - err = fmt.Errorf("目标用户:%s 不在线", args.Param1) - } else { + + if session, ok = this.GetUserSession(args.Param1); ok { this.AddHeroFetterData(session.GetUserId(), args.Param2) session.Push() + } else { + this.Debugf("Rpc_ModuleFetter 目标用户:%s 不在线", args.Param1) } + this.PutUserSession(session) return }