diff --git a/server/imserver_new/chatmgr.go b/server/imserver_new/chatmgr.go index 71992b7a..77100154 100644 --- a/server/imserver_new/chatmgr.go +++ b/server/imserver_new/chatmgr.go @@ -10,7 +10,6 @@ import ( ) type ChatMgr struct { - gm *GuildMgr worldMsgRec *ChatMsgRec guildMsgRec map[int64]*ChatMsgRec @@ -22,9 +21,8 @@ type ChatMgr struct { //tmpMsgId uint64 } -func NewChatMgr(gm *GuildMgr) *ChatMgr { +func NewChatMgr() *ChatMgr { cm := &ChatMgr{ - gm: gm, worldMsgRec: &ChatMsgRec{}, guildMsgRec: make(map[int64]*ChatMsgRec), privateChatUsers: make(map[string]*ChatUserRec), @@ -57,7 +55,7 @@ func (cm *ChatMgr) FillSMUpdateChatRedPointNotify(p common.Player, msg *cs.SMUpd if cm.worldMsgRec.CurrID > p.GetWorldChannelLastId() { msg.HasUnreadMsgChannels = append(msg.HasUnreadMsgChannels, constant.CCWorld) } - guildId := cm.gm.GetGuildIdByAccountId(p.GetAccountId()) + guildId := GetGuildMgr().GetGuildIdByAccountId(p.GetAccountId()) if guildId > 0 { if msgRec, exists := cm.guildMsgRec[guildId]; exists { if msgRec.CurrID > p.GetGuildChannelLastId() { @@ -105,7 +103,7 @@ func (cm *ChatMgr) ProcWorldChat(p common.Player, msg *cs.CMSendChatMsg) { } func (cm *ChatMgr) ProcGuildChat(p common.Player, msg *cs.CMSendChatMsg) { - guild := cm.gm.GetGuildByAccountId(p.GetAccountId()) + guild := GetGuildMgr().GetGuildByAccountId(p.GetAccountId()) if guild == nil { return } @@ -125,7 +123,7 @@ func (cm *ChatMgr) ProcGuildChat(p common.Player, msg *cs.CMSendChatMsg) { } // TraverseMember - for _, member := range guild.Members { + for _, member := range guild.GetMembers() { guildMember := GetPlayerMgr().GetPlayerByAccountId(member.GetAccountId()) if guildMember != nil { cm.SyncGuildChatMsg(guildMember) @@ -223,7 +221,7 @@ func (cm *ChatMgr) SyncPrivateChatMsg(p common.Player) { } func (cm *ChatMgr) SyncGuildChatMsg(p common.Player) { - guildId := cm.gm.GetGuildIdByAccountId(p.GetAccountId()) + guildId := GetGuildMgr().GetGuildIdByAccountId(p.GetAccountId()) if guildId <= 0 { return } diff --git a/server/imserver_new/common/types.go b/server/imserver_new/common/types.go index 921f9577..1a23ea01 100644 --- a/server/imserver_new/common/types.go +++ b/server/imserver_new/common/types.go @@ -54,5 +54,19 @@ type User interface { } type FriendMgr interface { - GetFriendByAccountId(account1Id, account2Id string) *User + GetFriendByAccountId(account1Id, account2Id string) User +} + +type Guild interface { + GetGuildId() int64 + GetMembers() map[string]GuildMember +} + +type GuildMember interface { + GetAccountId() string +} + +type GuildMgr interface { + GetGuildByAccountId(string) Guild + GetGuildIdByAccountId(string) int64 } diff --git a/server/imserver_new/export.go b/server/imserver_new/export.go index fb39c966..29c32048 100644 --- a/server/imserver_new/export.go +++ b/server/imserver_new/export.go @@ -3,6 +3,4 @@ package main var handlerMgr = new(HandlerMgr) var cacheMgr = new(CacheMgr) -// var guildMgr = new(GuildMgr) -var guildMgr = NewGuildMgr() -var chatMgr = NewChatMgr(guildMgr) +var chatMgr = NewChatMgr() diff --git a/server/imserver_new/global/global.go b/server/imserver_new/global/global.go index 7cfb6349..62b1860f 100644 --- a/server/imserver_new/global/global.go +++ b/server/imserver_new/global/global.go @@ -20,6 +20,7 @@ var app common.App var playerMgr common.PlayerMgr var wspListener common.WspListener var friendMgr common.FriendMgr +var guildMgr common.GuildMgr func GetPlayerMgr() common.PlayerMgr { return playerMgr @@ -29,6 +30,10 @@ func GetFriendMgr() common.FriendMgr { return friendMgr } +func GetGuildMgr() common.GuildMgr { + return guildMgr +} + func GetWspListener() common.WspListener { return wspListener }