1
This commit is contained in:
parent
c7281f28a8
commit
46ebf950b2
@ -169,6 +169,7 @@ void Player::_CMFriendApply(f8::MsgHdr& hdr, const cs::CMFriendApply& msg)
|
|||||||
}
|
}
|
||||||
++role_data.today_apply_times;
|
++role_data.today_apply_times;
|
||||||
SendMsg(respmsg);
|
SendMsg(respmsg);
|
||||||
|
QueryUserOnline({msg.friend_id()});
|
||||||
DBHelper::Instance()->AddFriendApply(this, msg.friend_id());
|
DBHelper::Instance()->AddFriendApply(this, msg.friend_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -488,6 +489,7 @@ void Player::_SS_IM_FriendAgreeRequest(f8::MsgHdr& hdr, const ss::SS_IM_FriendAg
|
|||||||
delete friendobj;
|
delete friendobj;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
QueryUserOnline({friendobj->base_data.account_id});
|
||||||
}
|
}
|
||||||
RemoveHandledApply();
|
RemoveHandledApply();
|
||||||
f8::MsgHdr* hdr_copy = hdr.Clone();
|
f8::MsgHdr* hdr_copy = hdr.Clone();
|
||||||
@ -1060,6 +1062,7 @@ void Player::OnFriendAgreeEvent(Event& event)
|
|||||||
user_db.ParseFromString(event.event_data);
|
user_db.ParseFromString(event.event_data);
|
||||||
TypeConvert::Convert(user_db.base_data(), friendobj->base_data);
|
TypeConvert::Convert(user_db.base_data(), friendobj->base_data);
|
||||||
}
|
}
|
||||||
|
QueryUserOnline({friendobj->base_data.account_id});
|
||||||
friendobj->base_data.account_id = event.sender_id;
|
friendobj->base_data.account_id = event.sender_id;
|
||||||
AddFriend(friendobj);
|
AddFriend(friendobj);
|
||||||
}
|
}
|
||||||
@ -1195,3 +1198,12 @@ void Player::RemoveHandledApply()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::QueryUserOnline(std::vector<std::string> account_ids)
|
||||||
|
{
|
||||||
|
ss::SS_IM_QueryUserOnlineState msg;
|
||||||
|
for (auto& account_id : account_ids) {
|
||||||
|
msg.add_account_ids(account_id);
|
||||||
|
}
|
||||||
|
SendSSMsg(myself, msg);
|
||||||
|
}
|
||||||
|
@ -135,6 +135,7 @@ private:
|
|||||||
void ClearApplyByTarget(const std::string& target_id);
|
void ClearApplyByTarget(const std::string& target_id);
|
||||||
void RefreshFriendData();
|
void RefreshFriendData();
|
||||||
void RemoveHandledApply();
|
void RemoveHandledApply();
|
||||||
|
void QueryUserOnline(std::vector<std::string> account_ids);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool dirty_ = false;
|
bool dirty_ = false;
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "WSListener.h"
|
#include "WSListener.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include "gamelog.h"
|
#include "gamelog.h"
|
||||||
|
#include "IMListener.h"
|
||||||
|
|
||||||
#include "framework/cpp/utils.h"
|
#include "framework/cpp/utils.h"
|
||||||
|
|
||||||
@ -83,22 +84,57 @@ 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)
|
void PlayerMgr::_SS_IM_OnUserOnline(f8::MsgHdr& hdr, const ss::SS_IM_OnUserOnline& msg)
|
||||||
{
|
{
|
||||||
|
for (auto& account_id : msg.account_ids()) {
|
||||||
|
auto itr = watch_players_.find(account_id);
|
||||||
|
if (itr != watch_players_.end()) {
|
||||||
|
struct Friend *node, *tmp;
|
||||||
|
list_for_each_entry_safe(node, tmp, &itr->second, watch_node) {
|
||||||
|
node->base_data.online = true;
|
||||||
|
node->hum->NotifyUserInfoUpdate(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerMgr::_SS_IM_OnUserOffline(f8::MsgHdr& hdr, const ss::SS_IM_OnUserOffline& msg)
|
void PlayerMgr::_SS_IM_OnUserOffline(f8::MsgHdr& hdr, const ss::SS_IM_OnUserOffline& msg)
|
||||||
{
|
{
|
||||||
|
for (auto& account_id : msg.account_ids()) {
|
||||||
|
auto itr = watch_players_.find(account_id);
|
||||||
|
if (itr != watch_players_.end()) {
|
||||||
|
struct Friend *node, *tmp;
|
||||||
|
list_for_each_entry_safe(node, tmp, &itr->second, watch_node) {
|
||||||
|
node->base_data.online = false;
|
||||||
|
node->hum->NotifyUserInfoUpdate(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerMgr::_SS_IM_QueryUserOnlineState(f8::MsgHdr& hdr, const ss::SS_IM_QueryUserOnlineState& msg)
|
void PlayerMgr::_SS_IM_QueryUserOnlineState(f8::MsgHdr& hdr, const ss::SS_IM_QueryUserOnlineState& msg)
|
||||||
{
|
{
|
||||||
|
ss::SS_IM_PushUserOnlineState respmsg;
|
||||||
|
for (auto& account_id : msg.account_ids()) {
|
||||||
|
if (GetPlayerByAccountId(account_id)) {
|
||||||
|
respmsg.add_online_account_ids(account_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IMListener::Instance()->SendMsg(hdr.socket_handle, respmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerMgr::_SS_IM_PushUserOnlineState(f8::MsgHdr& hdr, const ss::SS_IM_PushUserOnlineState& msg)
|
void PlayerMgr::_SS_IM_PushUserOnlineState(f8::MsgHdr& hdr, const ss::SS_IM_PushUserOnlineState& msg)
|
||||||
{
|
{
|
||||||
|
for (auto& account_id : msg.online_account_ids()) {
|
||||||
|
auto itr = watch_players_.find(account_id);
|
||||||
|
if (itr != watch_players_.end()) {
|
||||||
|
struct Friend *node, *tmp;
|
||||||
|
list_for_each_entry_safe(node, tmp, &itr->second, watch_node) {
|
||||||
|
if (!node->base_data.online) {
|
||||||
|
node->base_data.online = true;
|
||||||
|
node->hum->NotifyUserInfoUpdate(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerMgr::_SS_IM_UpdateUserInfo(f8::MsgHdr& hdr, const ss::SS_IM_UpdateUserInfo& msg)
|
void PlayerMgr::_SS_IM_UpdateUserInfo(f8::MsgHdr& hdr, const ss::SS_IM_UpdateUserInfo& msg)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user