save
This commit is contained in:
parent
f924d4e880
commit
05cccd3e9a
@ -17,7 +17,8 @@ type ChatMgr struct {
|
|||||||
|
|
||||||
worldMsgId uint64
|
worldMsgId uint64
|
||||||
guildMsgId uint64
|
guildMsgId uint64
|
||||||
tmpMsgId uint64
|
teamMsgId uint64
|
||||||
|
//tmpMsgId uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewChatMgr(pm *PlayerMgr, fm *FriendsMgr, gm *GuildMgr) *ChatMgr {
|
func NewChatMgr(pm *PlayerMgr, fm *FriendsMgr, gm *GuildMgr) *ChatMgr {
|
||||||
@ -32,7 +33,7 @@ func NewChatMgr(pm *PlayerMgr, fm *FriendsMgr, gm *GuildMgr) *ChatMgr {
|
|||||||
// Default values
|
// Default values
|
||||||
cm.worldMsgId = 1000
|
cm.worldMsgId = 1000
|
||||||
cm.guildMsgId = 1000
|
cm.guildMsgId = 1000
|
||||||
cm.tmpMsgId = 1000
|
cm.teamMsgId = 1000
|
||||||
|
|
||||||
return cm
|
return cm
|
||||||
}
|
}
|
||||||
@ -118,9 +119,9 @@ func (cm *ChatMgr) ProcGuildChat(p *Player, msg *cs.CMSendChatMsg) {
|
|||||||
if msgRec, exists := cm.guildMsgRec[guildId]; exists {
|
if msgRec, exists := cm.guildMsgRec[guildId]; exists {
|
||||||
msgRec.AddChatMsg(chatMsg)
|
msgRec.AddChatMsg(chatMsg)
|
||||||
} else {
|
} else {
|
||||||
msgRec := &ChatMsgRec{}
|
cm.guildMsgRec[guildId] = &ChatMsgRec{
|
||||||
msgRec.CurrID = cm.guildMsgId
|
CurrID: cm.guildMsgId,
|
||||||
cm.guildMsgRec[guildId] = msgRec
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TraverseMember
|
// TraverseMember
|
||||||
@ -132,6 +133,27 @@ func (cm *ChatMgr) ProcGuildChat(p *Player, msg *cs.CMSendChatMsg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (cm *ChatMgr) ProcTeamChat(p *Player, msg *cs.CMSendChatMsg) {
|
||||||
|
chatMsg := new(cs.MFChatMsg)
|
||||||
|
cm.teamMsgId++
|
||||||
|
cm.FillMFChatMsg(chatMsg, p, cm.teamMsgId, *msg.ChatChannel, *msg.MsgType, msg.MsgBody)
|
||||||
|
|
||||||
|
notifyMsg := &cs.SMChatMsgNotify{}
|
||||||
|
notifyMsg.MsgList = append(notifyMsg.MsgList, chatMsg)
|
||||||
|
|
||||||
|
// Traverse msg members
|
||||||
|
for _, accountId := range msg.GetMembers() {
|
||||||
|
p2 := cm.pm.GetPlayerByAccountId(accountId)
|
||||||
|
if p2 != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
p2.SendMsg(notifyMsg)
|
||||||
|
if p2.chatChannel == kCCTeam {
|
||||||
|
// p2.SyncPrivateChatRedPoint()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (cm *ChatMgr) ProcPrivateChat(p *Player, msg *cs.CMSendChatMsg) {
|
func (cm *ChatMgr) ProcPrivateChat(p *Player, msg *cs.CMSendChatMsg) {
|
||||||
targetAccountId := msg.GetTargetAccountId()
|
targetAccountId := msg.GetTargetAccountId()
|
||||||
if p.accountId == targetAccountId {
|
if p.accountId == targetAccountId {
|
||||||
|
@ -257,13 +257,14 @@ func (p *Player) CMSendChatMsg(hdr *f5.MsgHdr, msg *cs.CMSendChatMsg) {
|
|||||||
chatMgr.ProcPrivateChat(p, msg)
|
chatMgr.ProcPrivateChat(p, msg)
|
||||||
case kCCGuild:
|
case kCCGuild:
|
||||||
chatMgr.ProcGuildChat(p, msg)
|
chatMgr.ProcGuildChat(p, msg)
|
||||||
|
case kCCTeam:
|
||||||
|
chatMgr.ProcTeamChat(p, msg)
|
||||||
default:
|
default:
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Player) SyncPrivateChatRedPoint() {
|
func (p *Player) SyncPrivateChatRedPoint() {
|
||||||
//rspMsg := &cs.SMDeleteFriendShip{}
|
|
||||||
msg := &cs.SMUpdatePrivateChatRedPointNotify{}
|
msg := &cs.SMUpdatePrivateChatRedPointNotify{}
|
||||||
chatMgr.FillSMUpdatePrivateChatRedPointNotify(p, msg)
|
chatMgr.FillSMUpdatePrivateChatRedPointNotify(p, msg)
|
||||||
}
|
}
|
||||||
@ -277,6 +278,25 @@ func (p *Player) CMReadMsgAndOpenChatNotify(hdr *f5.MsgHdr, msg *cs.CMReadMsgAnd
|
|||||||
if p.chatChannel == kCCPrivate {
|
if p.chatChannel == kCCPrivate {
|
||||||
p.SyncPrivateChatRedPoint()
|
p.SyncPrivateChatRedPoint()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// lastIds [{key:1, value:0}, {key:1, value:0}, ]
|
||||||
|
for _, v := range msg.GetLastIds() {
|
||||||
|
chatChannel := q5.ToInt32(v.GetKey())
|
||||||
|
if !IsValidChatChannel(chatChannel) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
chatChannelLastId := uint64(v.GetValue())
|
||||||
|
switch chatChannel {
|
||||||
|
case kCCWorld:
|
||||||
|
p.worldChannelLastId = chatChannelLastId
|
||||||
|
chatMgr.SyncWorldChatMsg(p)
|
||||||
|
case kCCGuild:
|
||||||
|
p.guildChannelLastId = chatChannelLastId
|
||||||
|
chatMgr.SyncGuildChatMsg(p)
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CMSetCurrPrivateChatTarget 设置当前私聊目标
|
// CMSetCurrPrivateChatTarget 设置当前私聊目标
|
||||||
|
Loading…
x
Reference in New Issue
Block a user