From 62eae3d17def8f72e1330015dabbc4440fe16a9d Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 12 Apr 2024 14:15:03 +0800 Subject: [PATCH] 1 --- server/imserver_new/common/types.go | 2 +- server/imserver_new/guild/guildmgr.go | 11 ++++++----- server/imserver_new/player/player.go | 22 +++++++++++++++++++++- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/server/imserver_new/common/types.go b/server/imserver_new/common/types.go index 973d2d79..7918c8e6 100644 --- a/server/imserver_new/common/types.go +++ b/server/imserver_new/common/types.go @@ -91,7 +91,7 @@ type GuildMgr interface { AsyncGetGuildRank(int32, func(int32, string, []string)) AsyncGetRecommendGuild(int32, func(int32, string, []string)) - AsyncLeave(string, func(int32, string, []string)) + AsyncLeave(string, func(int32, string, string, string, []string)) AsyncKickout(string, string, func(int32, string, string, string)) AsyncDisband(string, func(int32, string, []string)) AsyncSetGuildJob(string, string, int32, func(int32, string, string, string)) diff --git a/server/imserver_new/guild/guildmgr.go b/server/imserver_new/guild/guildmgr.go index 7bd3d452..7553111a 100644 --- a/server/imserver_new/guild/guildmgr.go +++ b/server/imserver_new/guild/guildmgr.go @@ -408,13 +408,14 @@ func (this *guildMgr) AsyncRejectApply(accountId string, targetId string, }) } -func (this *guildMgr) AsyncLeave(accountId string, cb func(int32, string, []string)) { +func (this *guildMgr) AsyncLeave(accountId string, + cb func(int32, string, string, string, []string)) { members := []string{} keys := [][]string{} { guild := this.internalGetGuildByAccountId(accountId) if guild == nil { - cb(0, "", members) + cb(0, "", "", "", members) return } keys = [][]string{ @@ -435,18 +436,18 @@ func (this *guildMgr) AsyncLeave(accountId string, cb func(int32, string, []stri members := []string{} if guild == nil { task.SetSucc() - cb(0, "", members) + cb(0, "", guild.guildId, guild.guildName, members) return } guild.asyncLeave(accountId, func (errCode int32, errMsg string) { if errCode != 0 { task.SetFail() - cb(errCode, errMsg, members) + cb(errCode, errMsg, guild.guildId, guild.guildName, members) return } task.SetSucc() - cb(0, "", members) + cb(0, "", guild.guildId, guild.guildName, members) return }) }) diff --git a/server/imserver_new/player/player.go b/server/imserver_new/player/player.go index bd5c95dc..2dbaec47 100644 --- a/server/imserver_new/player/player.go +++ b/server/imserver_new/player/player.go @@ -560,12 +560,32 @@ func (this *player) CMLeaveGuild(hdr *f5.MsgHdr, msg *cs.CMLeaveGuild) { rspMsg := new(cs.SMLeaveGuild) GetGuildMgr().AsyncLeave( this.GetAccountId(), - func (errCode int32, errMsg string, members []string) { + func (errCode int32, errMsg string, guildId string, guildName string, members []string) { if errCode != 0 { this.SendMsg(rspMsg.Err(errCode, errMsg)) return } this.SendMsg(rspMsg) + { + { + pbGuilds := []*cs.MFGuildMember{} + GetCacheMgr().AsyncGetUsersAndFillMFGuildMember( + []string{ + this.GetAccountId(), + }, + &pbGuilds, + func (errCode int32, errMsg string) { + if errCode == 0 && len(pbGuilds) > 0 { + notifyMsg := new(cs.SMLeaveGuildNotify) + notifyMsg.GuildId = proto.Int64(q5.ToInt64(guildId)) + notifyMsg.Name = proto.String(guildName) + notifyMsg.AccountId = proto.String(pbGuilds[0].GetAccountId()) + notifyMsg.Username = proto.String(pbGuilds[0].GetUsername()) + GetGuildMgr().NotifyGuildMsg(guildId, notifyMsg) + } + }) + } + } }) }