From 5508f96ab86074c6c7941dd8715bd20258217429 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 9 Jul 2020 18:28:32 +0800 Subject: [PATCH 01/10] 1 --- server/imserver/dbhelper.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/imserver/dbhelper.cc b/server/imserver/dbhelper.cc index 91d43b0..52af2f6 100644 --- a/server/imserver/dbhelper.cc +++ b/server/imserver/dbhelper.cc @@ -207,6 +207,11 @@ void DBHelper::ShuaOfflineUsers(Player* hum) fmtstr += " UNION SELECT '%s'"; sql_params.push_back(a8::XValue(account_id)); } + if (f8::IsOnlineEnv()) { + sql_params.push_back(10000 + (rand() % 5000)); + } else { + sql_params.push_back(10000 + (rand() % 50)); + } auto on_ok = [] (a8::XParams& param, const f8::DataSet* data_set) { @@ -242,7 +247,7 @@ void DBHelper::ShuaOfflineUsers(Player* hum) " A.user_value2, A.user_value3, A.last_logintime " "FROM `user` A " " LEFT JOIN (" + fmtstr + ") AS B ON B.account_id = A.account_id " - "WHERE A.idx > (SELECT 9999 + FLOOR(RAND() * (MAX(idx) - 10000)) FROM `user`) AND " + "WHERE A.idx > %d AND " " B.account_id IS NULL LIMIT 1, 10;" ).c_str(), sql_params, From dc613359c93fcf18753fe971e460081b53c4888a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 10 Jul 2020 10:23:00 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BF=9D=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/imserver/playermgr.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/server/imserver/playermgr.cc b/server/imserver/playermgr.cc index 5730b9f..b72bebd 100644 --- a/server/imserver/playermgr.cc +++ b/server/imserver/playermgr.cc @@ -467,11 +467,17 @@ void PlayerMgr::AsyncLoginOnOk(const std::string& account_id, if (hdr) { Player* hum = GetPlayerByAccountId(account_id); if (hum) { - abort(); + pending_socket_hash_.erase(hdr->socket_handle); + pending_account_hash_.erase(account_id); + f8::MsgHdr::Destroy(hdr); + return; } hum = GetPlayerBySocket(hdr->socket_handle); if (hum) { - abort(); + pending_socket_hash_.erase(hdr->socket_handle); + pending_account_hash_.erase(account_id); + f8::MsgHdr::Destroy(hdr); + return; } { hum = new Player(); From 0c8a248450c80a8cbc2f8f8176fd33bd2d26dbd4 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 10 Jul 2020 10:40:18 +0800 Subject: [PATCH 03/10] 1 --- server/imserver/WSListener.h | 4 ++++ server/imserver/perfmonitor.cc | 6 ++++-- server/imserver/perfmonitor.h | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/server/imserver/WSListener.h b/server/imserver/WSListener.h index 0a96e5f..e4cfaea 100644 --- a/server/imserver/WSListener.h +++ b/server/imserver/WSListener.h @@ -2,6 +2,8 @@ #include "framework/cpp/netmsghandler.h" +#include "perfmonitor.h" + //gate listener namespace a8 { @@ -31,6 +33,7 @@ class WSListener : public a8::Singleton { static int msgid = f8::Net_GetMessageId(msg); f8::Net_SendProxyMsg(tcp_listener_, sockhandle, 0, 0, msgid, msg); + ++PerfMonitor::Instance()->send_ws_count; #ifdef DEBUG f8::DumpMsgToLog(msg, "<<<<<< { static int msgid = f8::Net_GetMessageId(msg); f8::Net_SendProxyMsg(tcp_listener_, sockhandle, seqid, 0, msgid, msg); + ++PerfMonitor::Instance()->send_ws_count; #ifdef DEBUG f8::DumpMsgToLog(msg, "<<<<<<Info ("max_run_delay_time:%d max_timer_idle:%d " "in_data_size:%d out_data_size:%d msgnode_size:%d read_count:%d max_login_time:%d " - "login_ok_time:%d login_error_time:%d online_num:%d watch_num:%d cache_users_num:%d ", + "login_ok_time:%d login_error_time:%d online_num:%d watch_num:%d cache_users_num:%d " + "send_ws_count:%d ", { PerfMonitor::Instance()->max_run_delay_time, PerfMonitor::Instance()->max_timer_idle, @@ -26,7 +27,8 @@ static void SavePerfLog() PerfMonitor::Instance()->login_error_times, PlayerMgr::Instance()->OnlineNum(), PlayerMgr::Instance()->WatchPlayerNum(), - DBHelper::Instance()->cache_users_hash.size() + DBHelper::Instance()->cache_users_hash.size(), + PerfMonitor::Instance()->send_ws_count }); a8::UdpLog::Instance()->Info ("run_times:%d timer_times:%d event_times:%d free_times:%d " diff --git a/server/imserver/perfmonitor.h b/server/imserver/perfmonitor.h index a86f352..57dbb00 100644 --- a/server/imserver/perfmonitor.h +++ b/server/imserver/perfmonitor.h @@ -16,6 +16,7 @@ class PerfMonitor : public a8::Singleton long long out_data_size = 0; long long in_data_size = 0; long long read_count = 0; + long long send_ws_count = 0; void Init(); void UnInit(); From e256b557b483447f8af247ffe714b9033a967a25 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 10 Jul 2020 11:00:02 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/imserver/perfmonitor.cc | 9 +++++++-- third_party/framework | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/server/imserver/perfmonitor.cc b/server/imserver/perfmonitor.cc index 02cbd10..80ce651 100644 --- a/server/imserver/perfmonitor.cc +++ b/server/imserver/perfmonitor.cc @@ -8,13 +8,15 @@ #include "playermgr.h" #include "dbhelper.h" +#include "framework/cpp/dbpool.h" + static void SavePerfLog() { a8::UdpLog::Instance()->Info ("max_run_delay_time:%d max_timer_idle:%d " "in_data_size:%d out_data_size:%d msgnode_size:%d read_count:%d max_login_time:%d " "login_ok_time:%d login_error_time:%d online_num:%d watch_num:%d cache_users_num:%d " - "send_ws_count:%d ", + "send_ws_count:%d db.total_query_num:%d db.exec_query_num:%d db.run_loop_num:%d ", { PerfMonitor::Instance()->max_run_delay_time, PerfMonitor::Instance()->max_timer_idle, @@ -28,7 +30,10 @@ static void SavePerfLog() PlayerMgr::Instance()->OnlineNum(), PlayerMgr::Instance()->WatchPlayerNum(), DBHelper::Instance()->cache_users_hash.size(), - PerfMonitor::Instance()->send_ws_count + PerfMonitor::Instance()->send_ws_count, + (long long)f8::DBPool::Instance()->total_query_num, + (long long)f8::DBPool::Instance()->exec_query_num, + (long long)f8::DBPool::Instance()->run_loop_num }); a8::UdpLog::Instance()->Info ("run_times:%d timer_times:%d event_times:%d free_times:%d " diff --git a/third_party/framework b/third_party/framework index 6e1e842..8268f46 160000 --- a/third_party/framework +++ b/third_party/framework @@ -1 +1 @@ -Subproject commit 6e1e84260c42c24a58fe98e25ea6ccd18331248d +Subproject commit 8268f46febd430357e19c41271219ead8fbdcccc From 0a4b2392e1a4c1c151dd966134671bfcbbf5afef Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 10 Jul 2020 13:36:37 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=80=A7=E8=83=BD?= =?UTF-8?q?=E7=9B=91=E6=8E=A7=E6=97=A5=E5=BF=97=E6=B7=BB=E5=8A=A0=E4=BF=9D?= =?UTF-8?q?=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/imserver/MSConn.h | 4 ++++ server/imserver/perfmonitor.cc | 7 +++++-- server/imserver/perfmonitor.h | 2 ++ server/imserver/playermgr.cc | 22 ++++++++++++++++++++++ third_party/a8engine | 2 +- 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/server/imserver/MSConn.h b/server/imserver/MSConn.h index 982a020..867e84b 100644 --- a/server/imserver/MSConn.h +++ b/server/imserver/MSConn.h @@ -3,6 +3,8 @@ #include "framework/cpp/protoutils.h" #include "framework/cpp/netmsghandler.h" +#include "perfmonitor.h" + namespace a8 { class AsyncTcpClient; @@ -30,6 +32,7 @@ class MSConn { static int msgid = f8::Net_GetMessageId(msg); f8::Net_SendMsg(tcp_client_, 0, msgid, msg); + ++PerfMonitor::Instance()->ms_send_times; #ifdef DEBUG f8::DumpMsgToLog(msg, "<<<<<<ms_send_times; #ifdef DEBUG f8::DumpMsgToLog(msg, "<<<<<<max_run_delay_time, PerfMonitor::Instance()->max_timer_idle, @@ -33,7 +34,9 @@ static void SavePerfLog() PerfMonitor::Instance()->send_ws_count, (long long)f8::DBPool::Instance()->total_query_num, (long long)f8::DBPool::Instance()->exec_query_num, - (long long)f8::DBPool::Instance()->run_loop_num + (long long)f8::DBPool::Instance()->run_loop_num, + PerfMonitor::Instance()->ms_send_times, + PerfMonitor::Instance()->ms_recv_times }); a8::UdpLog::Instance()->Info ("run_times:%d timer_times:%d event_times:%d free_times:%d " diff --git a/server/imserver/perfmonitor.h b/server/imserver/perfmonitor.h index 57dbb00..f151869 100644 --- a/server/imserver/perfmonitor.h +++ b/server/imserver/perfmonitor.h @@ -17,6 +17,8 @@ class PerfMonitor : public a8::Singleton long long in_data_size = 0; long long read_count = 0; long long send_ws_count = 0; + long long ms_send_times = 0; + long long ms_recv_times = 0; void Init(); void UnInit(); diff --git a/server/imserver/playermgr.cc b/server/imserver/playermgr.cc index b72bebd..22644e2 100644 --- a/server/imserver/playermgr.cc +++ b/server/imserver/playermgr.cc @@ -87,6 +87,7 @@ void PlayerMgr::_SS_IM_FriendApply(f8::MsgHdr& hdr, const ss::SS_IM_FriendApply& void PlayerMgr::_SS_IM_OnUserOnline(f8::MsgHdr& hdr, const ss::SS_IM_OnUserOnline& msg) { + int times = 0; for (auto& account_id : msg.account_ids()) { auto itr = watch_players_.find(account_id); if (itr != watch_players_.end()) { @@ -94,6 +95,16 @@ void PlayerMgr::_SS_IM_OnUserOnline(f8::MsgHdr& hdr, const ss::SS_IM_OnUserOnlin list_for_each_entry_safe(node, tmp, &itr->second, watch_node) { node->base_data.online = true; node->hum->NotifyUserInfoUpdate(node); + ++times; + if (times > 100) { + a8::UdpLog::Instance()->Warning + ("OnUserOnLine watch account_id:%s times:%d ", + { + account_id, + times + }); + break; + } } } } @@ -101,6 +112,7 @@ void PlayerMgr::_SS_IM_OnUserOnline(f8::MsgHdr& hdr, const ss::SS_IM_OnUserOnlin void PlayerMgr::_SS_IM_OnUserOffline(f8::MsgHdr& hdr, const ss::SS_IM_OnUserOffline& msg) { + int times = 0; for (auto& account_id : msg.account_ids()) { auto itr = watch_players_.find(account_id); if (itr != watch_players_.end()) { @@ -108,6 +120,16 @@ void PlayerMgr::_SS_IM_OnUserOffline(f8::MsgHdr& hdr, const ss::SS_IM_OnUserOffl list_for_each_entry_safe(node, tmp, &itr->second, watch_node) { node->base_data.online = false; node->hum->NotifyUserInfoUpdate(node); + ++times; + if (times > 100) { + a8::UdpLog::Instance()->Warning + ("OnUserOffLine watch account_id:%s times:%d ", + { + account_id, + times + }); + break; + } } } } diff --git a/third_party/a8engine b/third_party/a8engine index 645913c..d6786bc 160000 --- a/third_party/a8engine +++ b/third_party/a8engine @@ -1 +1 @@ -Subproject commit 645913c9d4cc7126475f110b3c7d55bc2f4bc5f0 +Subproject commit d6786bcdb167afad09bcad7d34e247879dfc735a From 1b4a4f44a8636d8c643b5020cdbcb7015b89da1f Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 13 Jul 2020 11:17:14 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A4=B4=E5=83=8F?= =?UTF-8?q?=E9=A2=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/imserver/app.cc | 7 ++++ server/imserver/app.h | 1 + server/imserver/asynctaskmgr.cc | 26 +++++++++++++-- server/imserver/player.cc | 58 ++++++++++++++++++++++++++++++++- 4 files changed, 89 insertions(+), 3 deletions(-) diff --git a/server/imserver/app.cc b/server/imserver/app.cc index 37b7736..7b43173 100644 --- a/server/imserver/app.cc +++ b/server/imserver/app.cc @@ -675,3 +675,10 @@ bool App::IsTimeToReset(int time) { return BetweenDays(nowtime - 60 * SYS_RESET_TIME, time - 60 * SYS_RESET_TIME) > 0; } + +void App::PreProcAvatarUrl(int self_channel, int target_channel, std::string& target_avatar_url) +{ + if (self_channel == 6001 && target_channel != 6001) { + target_avatar_url = "https://wx.qlogo.cn/mmopen/vi_32/q4oRsMFYBwPEVAeVI7tiasWSqaibr0GPQia432JhibGRYhqqEJofpWDYxJPq6q0hQ0j7icdACdHL78hrjYYHSjZQ3YA/132"; + } +} diff --git a/server/imserver/app.h b/server/imserver/app.h index 7d2b1bf..3917ff1 100644 --- a/server/imserver/app.h +++ b/server/imserver/app.h @@ -36,6 +36,7 @@ class App : public a8::Singleton long long NewSeqId(); time_t BetweenDays(time_t time1, time_t time2); bool IsTimeToReset(int time); + void PreProcAvatarUrl(int self_channel, int target_channel, std::string& target_avatar_url); private: void QuickExecute(); diff --git a/server/imserver/asynctaskmgr.cc b/server/imserver/asynctaskmgr.cc index 84e306d..7016714 100644 --- a/server/imserver/asynctaskmgr.cc +++ b/server/imserver/asynctaskmgr.cc @@ -62,7 +62,18 @@ struct RecommandFriendTask cs::SMRecommandFriend msg; for (auto& pair : recommand_friends) { if (msg.friend_list_size() < 4) { - *msg.add_friend_list() = pair.second; + auto p = msg.add_friend_list() ; + *p = pair.second; + { + int channel = f8::ExtractChannelIdFromAccountId + (context.account_id); + int target_channel = f8::ExtractChannelIdFromAccountId + (p->base_data().account_id()); + App::Instance()->PreProcAvatarUrl + (channel, + target_channel, + *p->mutable_base_data()->mutable_account_id()); + } exclude_account_ids.insert(pair.first); batch_account_ids.insert(pair.first); } @@ -76,7 +87,18 @@ struct RecommandFriendTask } if (exclude_account_ids.find(user_info->base_data().account_id()) == exclude_account_ids.end()) { - *msg.add_friend_list() = *user_info; + auto p = msg.add_friend_list(); + *p = *user_info; + { + int channel = f8::ExtractChannelIdFromAccountId + (context.account_id); + int target_channel = f8::ExtractChannelIdFromAccountId + (p->base_data().account_id()); + App::Instance()->PreProcAvatarUrl + (channel, + target_channel, + *p->mutable_base_data()->mutable_account_id()); + } exclude_account_ids.insert(user_info->base_data().account_id()); batch_account_ids.insert(user_info->base_data().account_id()); } diff --git a/server/imserver/player.cc b/server/imserver/player.cc index eff560e..f41c425 100644 --- a/server/imserver/player.cc +++ b/server/imserver/player.cc @@ -398,6 +398,14 @@ void Player::_CMFriendAddBlack(f8::MsgHdr& hdr, const cs::CMFriendAddBlack& msg) auto user_info = notifymsg.add_user_infos(); TypeConvert::Convert(p->base_data, *user_info->mutable_base_data()); TypeConvert::Convert(p->temp_custom_data, *user_info->mutable_temp_custom_data()); + { + int target_channel = f8::ExtractChannelIdFromAccountId + (user_info->base_data().account_id()); + App::Instance()->PreProcAvatarUrl + (channel, + target_channel, + *user_info->mutable_base_data()->mutable_account_id()); + } SendMsg(notifymsg); } black_hash_[p->base_data.account_id] = p; @@ -419,6 +427,14 @@ void Player::_CMFriendAddBlack(f8::MsgHdr& hdr, const cs::CMFriendAddBlack& msg) auto user_info = notifymsg.add_user_infos(); TypeConvert::Convert(p->base_data, *user_info->mutable_base_data()); TypeConvert::Convert(p->temp_custom_data, *user_info->mutable_temp_custom_data()); + { + int target_channel = f8::ExtractChannelIdFromAccountId + (user_info->base_data().account_id()); + App::Instance()->PreProcAvatarUrl + (channel, + target_channel, + *user_info->mutable_base_data()->mutable_account_id()); + } SendMsg(notifymsg); } MarkDirty(); @@ -741,6 +757,14 @@ void Player::FillBlackList(::google::protobuf::RepeatedPtrField< ::cs::MFUserInf auto p = black_list->Add(); TypeConvert::Convert(pair.second->base_data, *(p->mutable_base_data())); TypeConvert::Convert(pair.second->temp_custom_data, *(p->mutable_temp_custom_data())); + { + int target_channel = f8::ExtractChannelIdFromAccountId + (p->base_data().account_id()); + App::Instance()->PreProcAvatarUrl + (channel, + target_channel, + *p->mutable_base_data()->mutable_account_id()); + } } } @@ -764,6 +788,13 @@ void Player::FillMFUserInfo(cs::MFUserInfo* user_info) { TypeConvert::Convert(myself.base_data, *(user_info->mutable_base_data())); TypeConvert::Convert(myself.temp_custom_data, *(user_info->mutable_temp_custom_data())); + { + int target_channel = f8::ExtractChannelIdFromAccountId(user_info->base_data().account_id()); + App::Instance()->PreProcAvatarUrl + (channel, + target_channel, + *user_info->mutable_base_data()->mutable_account_id()); + } } std::set& Player::GetExcludeAccountIds() @@ -863,7 +894,16 @@ void Player::FillApplyList(const cs::MFPaging& paging, cs::SMFriendApplyList& re if (GetBlackListById(pair.second->base_data.account_id)) { continue; } - TypeConvert::Convert(*pair.second, *respmsg.add_apply_list()); + cs::MFFriendApply* apply_pb = respmsg.add_apply_list(); + TypeConvert::Convert(*pair.second, *apply_pb); + { + int target_channel = f8::ExtractChannelIdFromAccountId + (apply_pb->base_data().account_id()); + App::Instance()->PreProcAvatarUrl + (channel, + target_channel, + *apply_pb->mutable_base_data()->mutable_account_id()); + } } ++i; } @@ -1062,6 +1102,14 @@ void Player::NotifyUserInfoUpdate(Friend* friend_data) auto p = msg.add_user_infos(); TypeConvert::Convert(friend_data->base_data, *p->mutable_base_data()); TypeConvert::Convert(friend_data->temp_custom_data, *p->mutable_temp_custom_data()); + { + int target_channel = f8::ExtractChannelIdFromAccountId + (p->base_data().account_id()); + App::Instance()->PreProcAvatarUrl + (channel, + target_channel, + *p->mutable_base_data()->mutable_account_id()); + } SendMsg(msg); } } @@ -1086,6 +1134,14 @@ void Player::SyncOtherFriend() auto p = msg.add_user_infos(); TypeConvert::Convert(myself.base_data, *p->mutable_base_data()); TypeConvert::Convert(myself.temp_custom_data, *p->mutable_temp_custom_data()); + { + int target_channel = f8::ExtractChannelIdFromAccountId + (p->base_data().account_id()); + App::Instance()->PreProcAvatarUrl + (channel, + target_channel, + *p->mutable_base_data()->mutable_account_id()); + } for (auto& pair : friend_hash_) { Player* hum = PlayerMgr::Instance()->GetPlayerByAccountId(pair.second->base_data.account_id); From 04a1af2b76715625c74ffe9d028a8ba272e2e279 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 13 Jul 2020 11:25:53 +0800 Subject: [PATCH 07/10] 1 --- server/imserver/asynctaskmgr.cc | 4 ++-- server/imserver/player.cc | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/server/imserver/asynctaskmgr.cc b/server/imserver/asynctaskmgr.cc index 7016714..d11439b 100644 --- a/server/imserver/asynctaskmgr.cc +++ b/server/imserver/asynctaskmgr.cc @@ -72,7 +72,7 @@ struct RecommandFriendTask App::Instance()->PreProcAvatarUrl (channel, target_channel, - *p->mutable_base_data()->mutable_account_id()); + *p->mutable_base_data()->mutable_avatar_url()); } exclude_account_ids.insert(pair.first); batch_account_ids.insert(pair.first); @@ -97,7 +97,7 @@ struct RecommandFriendTask App::Instance()->PreProcAvatarUrl (channel, target_channel, - *p->mutable_base_data()->mutable_account_id()); + *p->mutable_base_data()->mutable_avatar_url()); } exclude_account_ids.insert(user_info->base_data().account_id()); batch_account_ids.insert(user_info->base_data().account_id()); diff --git a/server/imserver/player.cc b/server/imserver/player.cc index f41c425..fed325a 100644 --- a/server/imserver/player.cc +++ b/server/imserver/player.cc @@ -404,7 +404,7 @@ void Player::_CMFriendAddBlack(f8::MsgHdr& hdr, const cs::CMFriendAddBlack& msg) App::Instance()->PreProcAvatarUrl (channel, target_channel, - *user_info->mutable_base_data()->mutable_account_id()); + *user_info->mutable_base_data()->mutable_avatar_url()); } SendMsg(notifymsg); } @@ -433,7 +433,7 @@ void Player::_CMFriendAddBlack(f8::MsgHdr& hdr, const cs::CMFriendAddBlack& msg) App::Instance()->PreProcAvatarUrl (channel, target_channel, - *user_info->mutable_base_data()->mutable_account_id()); + *user_info->mutable_base_data()->mutable_avatar_url()); } SendMsg(notifymsg); } @@ -763,7 +763,7 @@ void Player::FillBlackList(::google::protobuf::RepeatedPtrField< ::cs::MFUserInf App::Instance()->PreProcAvatarUrl (channel, target_channel, - *p->mutable_base_data()->mutable_account_id()); + *p->mutable_base_data()->mutable_avatar_url()); } } } @@ -793,7 +793,7 @@ void Player::FillMFUserInfo(cs::MFUserInfo* user_info) App::Instance()->PreProcAvatarUrl (channel, target_channel, - *user_info->mutable_base_data()->mutable_account_id()); + *user_info->mutable_base_data()->mutable_avatar_url()); } } @@ -902,7 +902,7 @@ void Player::FillApplyList(const cs::MFPaging& paging, cs::SMFriendApplyList& re App::Instance()->PreProcAvatarUrl (channel, target_channel, - *apply_pb->mutable_base_data()->mutable_account_id()); + *apply_pb->mutable_base_data()->mutable_avatar_url()); } } ++i; @@ -1108,7 +1108,7 @@ void Player::NotifyUserInfoUpdate(Friend* friend_data) App::Instance()->PreProcAvatarUrl (channel, target_channel, - *p->mutable_base_data()->mutable_account_id()); + *p->mutable_base_data()->mutable_avatar_url()); } SendMsg(msg); } @@ -1140,7 +1140,7 @@ void Player::SyncOtherFriend() App::Instance()->PreProcAvatarUrl (channel, target_channel, - *p->mutable_base_data()->mutable_account_id()); + *p->mutable_base_data()->mutable_avatar_url()); } for (auto& pair : friend_hash_) { From 135150d0abc6c313080f954395ac6be7fe5d7f5c Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 13 Jul 2020 11:34:05 +0800 Subject: [PATCH 08/10] 1 --- server/imserver/player.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server/imserver/player.cc b/server/imserver/player.cc index fed325a..76be714 100644 --- a/server/imserver/player.cc +++ b/server/imserver/player.cc @@ -748,6 +748,14 @@ void Player::FillFriendList(::google::protobuf::RepeatedPtrField< ::cs::MFUserIn auto p = friend_list->Add(); TypeConvert::Convert(pair.second->base_data, *(p->mutable_base_data())); TypeConvert::Convert(pair.second->temp_custom_data, *(p->mutable_temp_custom_data())); + { + int target_channel = f8::ExtractChannelIdFromAccountId + (p->base_data().account_id()); + App::Instance()->PreProcAvatarUrl + (channel, + target_channel, + *p->mutable_base_data()->mutable_avatar_url()); + } } } From f9499dd07037823933ba6ed863e83e7cd267ea7f Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 14 Sep 2020 19:49:43 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=90=91=E5=90=8E?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E5=8D=8F=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/tools/protobuild/cs_proto.proto | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/server/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index 05da98b..01e5564 100644 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -78,7 +78,11 @@ message MFFriendApply } //登录好友服 -message CMLogin +message CMLoginCommonHead +{ + optional int32 server_id = 1; //保留 +} +message CMLoginOld { optional string account_id = 3; //账号id optional string session_id = 20; //sessionid @@ -86,6 +90,17 @@ message CMLogin optional string avatar_url = 5; //头像 optional int32 sex = 6; //性别 } +message CMLogin +{ + optional int32 server_id = 1; //保留(定死传1) + optional string reserved2 = 2; //保留 + optional string account_id = 3; //账号id + optional string session_id = 20; //sessionid + optional string nickname = 4; //昵称 + optional int32 proto_version = 5; //协议版本号Constant_e.ProtoVersion + optional int32 sex = 6; //性别 + optional string avatar_url = 7; //头像 +} //登录回复 message SMLogin { From 9daa10e6b2fa958e858742aaf6435f93b5a7a7cb Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 14 Sep 2020 20:13:42 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=B0=E8=80=81?= =?UTF-8?q?=E5=8D=8F=E8=AE=AE=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/imserver/app.cc | 18 ++++++++++++++++++ server/imserver/handlermgr.cc | 2 ++ server/imserver/playermgr.cc | 11 +++++++++++ server/imserver/playermgr.h | 2 ++ 4 files changed, 33 insertions(+) diff --git a/server/imserver/app.cc b/server/imserver/app.cc index 7b43173..c9906b3 100644 --- a/server/imserver/app.cc +++ b/server/imserver/app.cc @@ -30,6 +30,8 @@ #include "MSConnMgr.h" #include "IMConnMgr.h" +#include "cs_msgid.pb.h" + #include "framework/cpp/msgqueue.h" #include "framework/cpp/tglog.h" #include "framework/cpp/netmsghandler.h" @@ -367,6 +369,22 @@ void App::DispatchMsg() void App::ProcessWSProxyMsg(f8::MsgHdr& hdr) { + if (hdr.msgid == cs::CMMessageId_e::_CMLogin) { + cs::CMLoginCommonHead common_head; + bool ok = common_head.ParseFromArray(hdr.buf + hdr.offset, hdr.buflen - hdr.offset); + if (ok) { + if (common_head.has_server_id()) { + cs::CMLoginOld msg; + msg.ParseFromArray(hdr.buf + hdr.offset, hdr.buflen - hdr.offset); + PlayerMgr::Instance()->_CMLoginOld(hdr, msg); + } else { + cs::CMLogin msg; + msg.ParseFromArray(hdr.buf + hdr.offset, hdr.buflen - hdr.offset); + PlayerMgr::Instance()->_CMLogin(hdr, msg); + } + } + return; + } f8::NetMsgHandler* handler = f8::GetNetMsgHandler(&HandlerMgr::Instance()->wsmsghandler, hdr.msgid); if (handler) { diff --git a/server/imserver/handlermgr.cc b/server/imserver/handlermgr.cc index b6eb60f..6a718d1 100644 --- a/server/imserver/handlermgr.cc +++ b/server/imserver/handlermgr.cc @@ -64,7 +64,9 @@ void HandlerMgr::RegisterNetMsgHandlers() RegisterNetMsgHandler(&wsmsghandler, &WSListener::_SS_Ping); RegisterNetMsgHandler(&wsmsghandler, &PlayerMgr::_SS_WSP_SocketDisconnect); + #if 0 RegisterNetMsgHandler(&wsmsghandler, &PlayerMgr::_CMLogin); + #endif RegisterNetMsgHandler(&wsmsghandler, &Player::_CMPing); RegisterNetMsgHandler(&wsmsghandler, &Player::_CMUpdateUserInfo); diff --git a/server/imserver/playermgr.cc b/server/imserver/playermgr.cc index 22644e2..a2319cf 100644 --- a/server/imserver/playermgr.cc +++ b/server/imserver/playermgr.cc @@ -213,6 +213,17 @@ void PlayerMgr::_SS_IM_UpdateUserInfo(f8::MsgHdr& hdr, const ss::SS_IM_UpdateUse } } +void PlayerMgr::_CMLoginOld(f8::MsgHdr& hdr, const cs::CMLoginOld& msg) +{ + cs::CMLogin new_msg; + new_msg.set_account_id(msg.account_id()); + new_msg.set_session_id(msg.session_id()); + new_msg.set_nickname(msg.nickname()); + new_msg.set_avatar_url(msg.avatar_url()); + new_msg.set_sex(msg.sex()); + _CMLogin(hdr, new_msg); +} + void PlayerMgr::_CMLogin(f8::MsgHdr& hdr, const cs::CMLogin& msg) { Player* hum = GetPlayerByAccountId(msg.account_id()); diff --git a/server/imserver/playermgr.h b/server/imserver/playermgr.h index b70eef3..dbc06d6 100644 --- a/server/imserver/playermgr.h +++ b/server/imserver/playermgr.h @@ -2,6 +2,7 @@ namespace cs { + class CMLoginOld; class CMLogin; } @@ -53,6 +54,7 @@ class PlayerMgr : public a8::Singleton void _SS_IM_UpdateUserInfo(f8::MsgHdr& hdr, const ss::SS_IM_UpdateUserInfo& msg); + void _CMLoginOld(f8::MsgHdr& hdr, const cs::CMLoginOld& msg); void _CMLogin(f8::MsgHdr& hdr, const cs::CMLogin& msg); Player* GetPlayerBySocket(int socket);