mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-03-01 00:35:36 +08:00
修改聊天数据存储结构
This commit is contained in:
@@ -105,6 +105,10 @@ func (g *GameManager) SendPrivateChat(player *model.Player, targetUid uint32, co
|
||||
}
|
||||
}
|
||||
chatMsg := g.ConvChatInfoToChatMsg(chatInfo)
|
||||
|
||||
// 写入db
|
||||
go USER_MANAGER.SaveUserChatMsgToDbSync(chatMsg)
|
||||
|
||||
// 消息加入自己的队列
|
||||
msgList, exist := player.ChatMsgMap[targetUid]
|
||||
if !exist {
|
||||
@@ -141,15 +145,10 @@ func (g *GameManager) SendPrivateChat(player *model.Player, targetUid uint32, co
|
||||
},
|
||||
},
|
||||
})
|
||||
} else {
|
||||
// 目标玩家全服离线
|
||||
chatMsgMap := map[uint32][]*model.ChatMsg{
|
||||
player.PlayerID: {chatMsg},
|
||||
}
|
||||
go USER_MANAGER.AppendOfflineUserChatMsgToDbSync(targetUid, chatMsgMap)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 消息加入目标玩家的队列
|
||||
msgList, exist = targetPlayer.ChatMsgMap[player.PlayerID]
|
||||
if !exist {
|
||||
@@ -327,6 +326,9 @@ func (g *GameManager) ServerChatMsgNotify(chatMsgInfo *mq.ChatMsgInfo) {
|
||||
if !exist {
|
||||
msgList = make([]*model.ChatMsg, 0)
|
||||
}
|
||||
if len(msgList) > MaxMsgListLen {
|
||||
msgList = msgList[1:]
|
||||
}
|
||||
msgList = append(msgList, chatMsg)
|
||||
targetPlayer.ChatMsgMap[chatMsgInfo.Uid] = msgList
|
||||
|
||||
|
||||
Reference in New Issue
Block a user