1
This commit is contained in:
parent
497cbd5379
commit
0906499a4a
@ -54,6 +54,12 @@ void ChatMgr::ProcWorldChat(Player* hum, const cs::CMSendChatMsg& msg)
|
|||||||
|
|
||||||
cs::MFChatMsg* p = new cs::MFChatMsg();
|
cs::MFChatMsg* p = new cs::MFChatMsg();
|
||||||
p->set_msg_uuid(world_msg_id_);
|
p->set_msg_uuid(world_msg_id_);
|
||||||
|
hum->FillMFUserInfo(p->mutable_sender());
|
||||||
|
//p->set_receiver(world_msg_id_);
|
||||||
|
p->set_chat_channel(msg.chat_channel());
|
||||||
|
p->set_msg_type(msg.msg_type());
|
||||||
|
p->set_msg_body(msg.msg_body());
|
||||||
|
p->set_send_time(time(nullptr));
|
||||||
|
|
||||||
world_msgrec_.curr_id = world_msg_id_;
|
world_msgrec_.curr_id = world_msg_id_;
|
||||||
world_msgrec_.msg_list.push_back(p);
|
world_msgrec_.msg_list.push_back(p);
|
||||||
@ -71,6 +77,10 @@ void ChatMgr::ProcPrivateChat(Player* hum, const cs::CMSendChatMsg& msg)
|
|||||||
|
|
||||||
cs::MFChatMsg* p = new cs::MFChatMsg();
|
cs::MFChatMsg* p = new cs::MFChatMsg();
|
||||||
p->set_msg_uuid(private_msg_id_);
|
p->set_msg_uuid(private_msg_id_);
|
||||||
|
p->set_chat_channel(msg.chat_channel());
|
||||||
|
p->set_msg_type(msg.msg_type());
|
||||||
|
p->set_msg_body(msg.msg_body());
|
||||||
|
p->set_send_time(time(nullptr));
|
||||||
|
|
||||||
ChatMgr::Instance()->SyncPrivateChatMsg(hum);
|
ChatMgr::Instance()->SyncPrivateChatMsg(hum);
|
||||||
Player* target_hum = PlayerMgr::Instance()->GetPlayerByAccountId(msg.target());
|
Player* target_hum = PlayerMgr::Instance()->GetPlayerByAccountId(msg.target());
|
||||||
@ -81,11 +91,27 @@ void ChatMgr::ProcPrivateChat(Player* hum, const cs::CMSendChatMsg& msg)
|
|||||||
|
|
||||||
void ChatMgr::ProcGuildChat(Player* hum, const cs::CMSendChatMsg& msg)
|
void ChatMgr::ProcGuildChat(Player* hum, const cs::CMSendChatMsg& msg)
|
||||||
{
|
{
|
||||||
|
if (hum->GuildId() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
++guild_msg_id_;
|
++guild_msg_id_;
|
||||||
|
|
||||||
cs::MFChatMsg* p = new cs::MFChatMsg();
|
cs::MFChatMsg* p = new cs::MFChatMsg();
|
||||||
p->set_msg_uuid(guild_msg_id_);
|
p->set_msg_uuid(guild_msg_id_);
|
||||||
|
p->set_chat_channel(msg.chat_channel());
|
||||||
|
p->set_msg_type(msg.msg_type());
|
||||||
|
p->set_msg_body(msg.msg_body());
|
||||||
|
p->set_send_time(time(nullptr));
|
||||||
|
|
||||||
|
auto itr = guild_msgrec_.find(hum->GuildId());
|
||||||
|
if (itr != guild_msgrec_.end()) {
|
||||||
|
itr->second.msg_list.push_back(p);
|
||||||
|
itr->second.PopAndDelete(50);
|
||||||
|
} else {
|
||||||
|
ChatMsgRec msgrec;
|
||||||
|
msgrec.curr_id = guild_msg_id_;
|
||||||
|
guild_msgrec_[hum->GuildId()] = msgrec;
|
||||||
|
}
|
||||||
Guild* guild = GuildMgr::Instance()->GetGuild(hum->GuildId());
|
Guild* guild = GuildMgr::Instance()->GetGuild(hum->GuildId());
|
||||||
if (guild) {
|
if (guild) {
|
||||||
guild->TraverseMember
|
guild->TraverseMember
|
||||||
@ -123,12 +149,30 @@ void ChatMgr::SyncWorldChatMsg(Player* hum)
|
|||||||
} else {
|
} else {
|
||||||
hum->MarkNewMsg();
|
hum->MarkNewMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatMgr::SyncPrivateChatMsg(Player* hum)
|
void ChatMgr::SyncPrivateChatMsg(Player* hum)
|
||||||
{
|
{
|
||||||
|
if (hum->chat_channel == kCCPrivate) {
|
||||||
|
ChatedUserRec* chated_user = GetChatedUser(hum->AccountId());
|
||||||
|
if (chated_user) {
|
||||||
|
cs::SMChatMsgNotify notifymsg;
|
||||||
|
auto itr = chated_user->users.find(hum->private_target);
|
||||||
|
if (itr != chated_user->users.end()) {
|
||||||
|
for (cs::MFChatMsg* chat_msg : itr->second.msg_list) {
|
||||||
|
if (chat_msg->msg_uuid() > itr->second.curr_id) {
|
||||||
|
*notifymsg.add_msg_list() = *chat_msg;
|
||||||
|
itr->second.curr_id = chat_msg->msg_uuid();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!notifymsg.msg_list().size() > 0) {
|
||||||
|
hum->SendMsg(notifymsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
hum->MarkNewMsg();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatMgr::SyncGuildChatMsg(Player* hum)
|
void ChatMgr::SyncGuildChatMsg(Player* hum)
|
||||||
|
@ -11,12 +11,16 @@ struct ChatMsgRec
|
|||||||
|
|
||||||
void Pop(int max_num)
|
void Pop(int max_num)
|
||||||
{
|
{
|
||||||
|
while (msg_list.size() > max_num) {
|
||||||
|
msg_list.erase(msg_list.begin());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopAndDelete(int max_num)
|
void PopAndDelete(int max_num)
|
||||||
{
|
{
|
||||||
|
while (msg_list.size() > max_num) {
|
||||||
|
msg_list.erase(msg_list.begin());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -579,6 +579,7 @@ void Player::_CMSendChatMsg(f8::MsgHdr& hdr, const cs::CMSendChatMsg& msg)
|
|||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
ss::SS_IM_SendChatMsg ss_msg;
|
ss::SS_IM_SendChatMsg ss_msg;
|
||||||
FillIMMsgConext(ss_msg.mutable_context());
|
FillIMMsgConext(ss_msg.mutable_context());
|
||||||
ss_msg.set_chat_channel(msg.chat_channel());
|
ss_msg.set_chat_channel(msg.chat_channel());
|
||||||
@ -589,6 +590,7 @@ void Player::_CMSendChatMsg(f8::MsgHdr& hdr, const cs::CMSendChatMsg& msg)
|
|||||||
if (friend_data) {
|
if (friend_data) {
|
||||||
SendSSMsg(*friend_data, ss_msg);
|
SendSSMsg(*friend_data, ss_msg);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::_CMReadMsgAndOpenChatNotify(f8::MsgHdr& hdr, const cs::CMReadMsgAndOpenChatNotify& msg)
|
void Player::_CMReadMsgAndOpenChatNotify(f8::MsgHdr& hdr, const cs::CMReadMsgAndOpenChatNotify& msg)
|
||||||
@ -601,7 +603,25 @@ void Player::_CMReadMsgAndOpenChatNotify(f8::MsgHdr& hdr, const cs::CMReadMsgAnd
|
|||||||
|
|
||||||
for (auto& pair : msg.last_ids()) {
|
for (auto& pair : msg.last_ids()) {
|
||||||
if (IsValidChatChannel(pair.key())) {
|
if (IsValidChatChannel(pair.key())) {
|
||||||
chat_last_ids_hash[pair.key()] = pair.val();
|
switch (pair.key()) {
|
||||||
|
case kCCWorld:
|
||||||
|
{
|
||||||
|
world_channel_last_id = pair.val();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case kCCPrivate:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case kCCGuild:
|
||||||
|
{
|
||||||
|
guild_channel_last_id = pair.val();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1516,7 +1536,9 @@ void Player::SaveToDB(a8::XParams param, f8::AsyncDBOnOkFunc on_ok, f8::AsyncDBO
|
|||||||
|
|
||||||
void Player::MarkNewMsg()
|
void Player::MarkNewMsg()
|
||||||
{
|
{
|
||||||
|
cs::SMUpdateChatRedPointNotify msg;
|
||||||
|
ChatMgr::Instance()->FillSMUpdateChatRedPointNotify(this, msg);
|
||||||
|
SendMsg(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
Friend* Player::GetFriendById(const std::string& friend_id)
|
Friend* Player::GetFriendById(const std::string& friend_id)
|
||||||
|
@ -26,7 +26,6 @@ class Player
|
|||||||
|
|
||||||
int chat_channel = -1;
|
int chat_channel = -1;
|
||||||
std::string private_target;
|
std::string private_target;
|
||||||
std::map<int, long long> chat_last_ids_hash;
|
|
||||||
|
|
||||||
long long world_channel_last_id = 0;
|
long long world_channel_last_id = 0;
|
||||||
long long guild_channel_last_id = 0;
|
long long guild_channel_last_id = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user