From d37c24e66bdf61ae3b6c0c7f1249dc5792d52b01 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Thu, 25 Jan 2024 10:49:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E9=80=80=E5=87=BA=E5=85=AC?= =?UTF-8?q?=E4=BC=9A=E5=9F=8B=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/const.go | 1 + comm/core.go | 1 + comm/usersession.go | 9 +++++++++ modules/enchant/api_challengeover.go | 1 - modules/modulebase.go | 4 +++- modules/sociaty/api_cross_discharge.go | 10 +++++++++- modules/sociaty/api_cross_quit.go | 8 +++++++- 7 files changed, 30 insertions(+), 4 deletions(-) diff --git a/comm/const.go b/comm/const.go index debff5406..69580943f 100644 --- a/comm/const.go +++ b/comm/const.go @@ -1013,6 +1013,7 @@ const ( Rtype250 TaskType = 250 //在{0}回合内完成维京{1}key值 Rtype251 TaskType = 251 //在{0}回合内完成狩猎内{1}key值 Rtype252 TaskType = 252 //完成指定世界任务 + Rtype253 TaskType = 253 //退出公会 ) const ( MailLineEasy int32 = 1 // 简单 diff --git a/comm/core.go b/comm/core.go index 017ec97fb..b93c62a82 100644 --- a/comm/core.go +++ b/comm/core.go @@ -77,6 +77,7 @@ type IUserSession interface { GetServiecTag() string GetGatewayServiceId() string IsLogin() bool + IsOnline() bool Bind(uid string, wokerId string) (err error) UnBind() (err error) SendMsg(mainType, subType string, msg proto.Message) (err error) diff --git a/comm/usersession.go b/comm/usersession.go index ef8238975..9946bb6f3 100644 --- a/comm/usersession.go +++ b/comm/usersession.go @@ -31,6 +31,7 @@ type UserSession struct { GatewayServiceId string //用户所在网关服务 UserId string Group int32 //用户分组 + Online bool service IService msgqueue []*pb.UserMessage lock sync.RWMutex @@ -47,6 +48,9 @@ func (this *UserSession) SetSession(ip, sessionId, stag, sid, uid string, group this.Group = group this.msgqueue = this.msgqueue[:0] this.mate = make(map[string]interface{}) + if sessionId != "" { + this.Online = true + } } // 重置 @@ -55,6 +59,7 @@ func (this *UserSession) Reset() { this.SessionId = "" this.GatewayServiceId = "" this.UserId = "" + this.Online = false this.msgqueue = this.msgqueue[:0] this.mate = make(map[string]interface{}) } @@ -94,6 +99,10 @@ func (this *UserSession) IsLogin() bool { return this.UserId != "" } +func (this *UserSession) IsOnline() bool { + return this.Online +} + // /绑定uid 登录后操作 // /uid 用户id // /wokerId 用户绑定worker服务id diff --git a/modules/enchant/api_challengeover.go b/modules/enchant/api_challengeover.go index 6316df6ff..c06a9e436 100644 --- a/modules/enchant/api_challengeover.go +++ b/modules/enchant/api_challengeover.go @@ -98,7 +98,6 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.EnchantCha if enchant.BossTime[key] > req.Report.Costtime || enchant.BossTime[key] == 0 { enchant.BossTime[key] = req.Report.Costtime mapData["bossTime"] = enchant.BossTime // 更新时间 - this.module.CheckRank(session.GetUserId(), req.BossType, req.Report, userinfo, req.Score) } diff --git a/modules/modulebase.go b/modules/modulebase.go index 9f9f3f839..e0db04f53 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -993,7 +993,9 @@ func (this *ModuleBase) AsynHandleSession(session comm.IUserSession, handle func } }() handle(session) - session.Push() + if session.IsOnline() { + session.Push() + } this.PutUserSession(session) } diff --git a/modules/sociaty/api_cross_discharge.go b/modules/sociaty/api_cross_discharge.go index 22e4f483b..3df4dea3b 100644 --- a/modules/sociaty/api_cross_discharge.go +++ b/modules/sociaty/api_cross_discharge.go @@ -21,6 +21,9 @@ func (this *apiComp) DischargeCheck(session comm.IUserSession, req *pb.SociatyDi } func (this *apiComp) Discharge(session comm.IUserSession, req *pb.SociatyDischargeReq) (errdata *pb.ErrorData) { + var ( + tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0) + ) if errdata = this.DischargeCheck(session, req); errdata != nil { return } @@ -113,7 +116,7 @@ func (this *apiComp) Discharge(session comm.IUserSession, req *pb.SociatyDischar log.Field{Key: "err", Value: err.Error()}, ) } - + tasks = append(tasks, comm.GetBuriedParam(comm.Rtype253, 1)) rsp := &pb.SociatyDischargeResp{ TargetId: req.TargetId, SociatyId: sociaty.Id, @@ -122,5 +125,10 @@ func (this *apiComp) Discharge(session comm.IUserSession, req *pb.SociatyDischar session.SendMsg(string(this.module.GetType()), SociatySubTypeDischarge, rsp) this.module.SendMsgToUser(string(this.module.GetType()), "pdischange", &pb.SociatyPDischangePush{Uid: req.TargetId, SociatyId: sociaty.Id}, req.TargetId) + + tsession, _ := this.module.GetUserSession(req.TargetId) + go this.module.AsynHandleSession(tsession, func(session comm.IUserSession) { + this.module.ModuleBuried.TriggerBuried(session, tasks...) + }) return } diff --git a/modules/sociaty/api_cross_quit.go b/modules/sociaty/api_cross_quit.go index cc5d22b49..71fce0563 100644 --- a/modules/sociaty/api_cross_quit.go +++ b/modules/sociaty/api_cross_quit.go @@ -14,7 +14,9 @@ func (this *apiComp) QuitCheck(session comm.IUserSession, req *pb.SociatyQuitReq } func (this *apiComp) Quit(session comm.IUserSession, req *pb.SociatyQuitReq) (errdata *pb.ErrorData) { - + var ( + tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0) + ) uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) if sociaty == nil { @@ -78,6 +80,10 @@ func (this *apiComp) Quit(session comm.IUserSession, req *pb.SociatyQuitReq) (er SociatyId: sociaty.Id, SociatyCD: cd, } + tasks = append(tasks, comm.GetBuriedParam(comm.Rtype253, 1)) session.SendMsg(string(this.module.GetType()), SociatySubTypeQuit, rsp) + go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { + this.module.ModuleBuried.TriggerBuried(session, tasks...) + }) return }