1
This commit is contained in:
parent
61def457b1
commit
191c12cd03
@ -25,6 +25,7 @@
|
|||||||
#include "synchelper.h"
|
#include "synchelper.h"
|
||||||
#include "perfmonitor.h"
|
#include "perfmonitor.h"
|
||||||
#include "gamelog.h"
|
#include "gamelog.h"
|
||||||
|
#include "asynctaskmgr.h"
|
||||||
|
|
||||||
#include "MSConnMgr.h"
|
#include "MSConnMgr.h"
|
||||||
#include "IMConnMgr.h"
|
#include "IMConnMgr.h"
|
||||||
@ -101,6 +102,7 @@ bool App::Init(int argc, char* argv[])
|
|||||||
DBEngine::Instance()->Init();
|
DBEngine::Instance()->Init();
|
||||||
DBHelper::Instance()->Init();
|
DBHelper::Instance()->Init();
|
||||||
SyncHelper::Instance()->Init();
|
SyncHelper::Instance()->Init();
|
||||||
|
AsyncTaskMgr::Instance()->Init();
|
||||||
|
|
||||||
a8::UdpLog::Instance()->Info("friend_imserver starting instance_id:%d pid:%d ",
|
a8::UdpLog::Instance()->Info("friend_imserver starting instance_id:%d pid:%d ",
|
||||||
{
|
{
|
||||||
@ -135,6 +137,7 @@ bool App::Init(int argc, char* argv[])
|
|||||||
void App::UnInit()
|
void App::UnInit()
|
||||||
{
|
{
|
||||||
a8::XPrintf("friend_imserver terminating instance_id:%d pid:%d\n", {instance_id, getpid()});
|
a8::XPrintf("friend_imserver terminating instance_id:%d pid:%d\n", {instance_id, getpid()});
|
||||||
|
AsyncTaskMgr::Instance()->UnInit();
|
||||||
SyncHelper::Instance()->UnInit();
|
SyncHelper::Instance()->UnInit();
|
||||||
DBHelper::Instance()->UnInit();
|
DBHelper::Instance()->UnInit();
|
||||||
DBEngine::Instance()->UnInit();
|
DBEngine::Instance()->UnInit();
|
||||||
|
46
server/imserver/asynctaskmgr.cc
Normal file
46
server/imserver/asynctaskmgr.cc
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#include "precompile.h"
|
||||||
|
|
||||||
|
#include "asynctaskmgr.h"
|
||||||
|
#include "app.h"
|
||||||
|
#include "player.h"
|
||||||
|
|
||||||
|
#include "cs_proto.pb.h"
|
||||||
|
#include "ss_proto.pb.h"
|
||||||
|
|
||||||
|
struct QueryUserStatusTask
|
||||||
|
{
|
||||||
|
std::vector<std::string> account_ids;
|
||||||
|
};
|
||||||
|
|
||||||
|
void AsyncTaskMgr::Init()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void AsyncTaskMgr::UnInit()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void AsyncTaskMgr::CreateQueryUserStatusTask(Player* hum, std::vector<std::string>& account_ids)
|
||||||
|
{
|
||||||
|
long long seqid = App::Instance()->NewSeqId();
|
||||||
|
QueryUserStatusTask* task = new QueryUserStatusTask();
|
||||||
|
task->account_ids = account_ids;
|
||||||
|
query_user_status_tasks_[seqid] = task;
|
||||||
|
|
||||||
|
{
|
||||||
|
ss::SS_IM_QueryUserOnlineState msg;
|
||||||
|
hum->FillIMMsgConext(msg.mutable_context());
|
||||||
|
for (auto& account_id : account_ids) {
|
||||||
|
msg.add_account_ids(account_id);
|
||||||
|
}
|
||||||
|
hum->SendSSMsg(hum->myself, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void AsyncTaskMgr::_SS_IM_PushUserOnlineState(f8::MsgHdr& hdr, const ss::SS_IM_PushUserOnlineState& msg)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
32
server/imserver/asynctaskmgr.h
Normal file
32
server/imserver/asynctaskmgr.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace ss
|
||||||
|
{
|
||||||
|
class SS_IM_PushUserOnlineState;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum AsyncTaskType
|
||||||
|
{
|
||||||
|
kAttQueryUserStatus = 0,
|
||||||
|
kAttMax
|
||||||
|
};
|
||||||
|
|
||||||
|
struct QueryUserStatusTask;
|
||||||
|
class Player;
|
||||||
|
class AsyncTaskMgr : public a8::Singleton<AsyncTaskMgr>
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
AsyncTaskMgr() {};
|
||||||
|
friend class a8::Singleton<AsyncTaskMgr>;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void Init();
|
||||||
|
void UnInit();
|
||||||
|
|
||||||
|
void CreateQueryUserStatusTask(Player* hum, std::vector<std::string>& account_ids);
|
||||||
|
|
||||||
|
void _SS_IM_PushUserOnlineState(f8::MsgHdr& hdr, const ss::SS_IM_PushUserOnlineState& msg);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::map<long long, QueryUserStatusTask*> query_user_status_tasks_;
|
||||||
|
};
|
@ -16,6 +16,7 @@
|
|||||||
#include "typeconvert.h"
|
#include "typeconvert.h"
|
||||||
#include "playermgr.h"
|
#include "playermgr.h"
|
||||||
#include "gamelog.h"
|
#include "gamelog.h"
|
||||||
|
#include "asynctaskmgr.h"
|
||||||
|
|
||||||
#include "IMConn.h"
|
#include "IMConn.h"
|
||||||
#include "IMConnMgr.h"
|
#include "IMConnMgr.h"
|
||||||
@ -344,7 +345,6 @@ void Player::_CMFriendDelete(f8::MsgHdr& hdr, const cs::CMFriendDelete& msg)
|
|||||||
|
|
||||||
void Player::_CMFriendBlackList(f8::MsgHdr& hdr, const cs::CMFriendBlackList& msg)
|
void Player::_CMFriendBlackList(f8::MsgHdr& hdr, const cs::CMFriendBlackList& msg)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::_CMFriendAddBlack(f8::MsgHdr& hdr, const cs::CMFriendAddBlack& msg)
|
void Player::_CMFriendAddBlack(f8::MsgHdr& hdr, const cs::CMFriendAddBlack& msg)
|
||||||
@ -359,7 +359,11 @@ void Player::_CMFriendDeleteBlack(f8::MsgHdr& hdr, const cs::CMFriendDeleteBlack
|
|||||||
|
|
||||||
void Player::_CMQueryUserStatus(f8::MsgHdr& hdr, const cs::CMQueryUserStatus& msg)
|
void Player::_CMQueryUserStatus(f8::MsgHdr& hdr, const cs::CMQueryUserStatus& msg)
|
||||||
{
|
{
|
||||||
|
std::vector<std::string> account_ids;
|
||||||
|
for (auto& account_id : msg.user_list()) {
|
||||||
|
account_ids.push_back(account_id);
|
||||||
|
}
|
||||||
|
AsyncTaskMgr::Instance()->CreateQueryUserStatusTask(this, account_ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::_CMRecommandFriend(f8::MsgHdr& hdr, const cs::CMRecommandFriend& msg)
|
void Player::_CMRecommandFriend(f8::MsgHdr& hdr, const cs::CMRecommandFriend& msg)
|
||||||
@ -756,6 +760,7 @@ void Player::NotifyOnline()
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
ss::SS_IM_QueryUserOnlineState msg;
|
ss::SS_IM_QueryUserOnlineState msg;
|
||||||
|
FillIMMsgConext(msg.mutable_context());
|
||||||
for (auto& pair : friend_hash_) {
|
for (auto& pair : friend_hash_) {
|
||||||
msg.add_account_ids(pair.second->base_data.account_id);
|
msg.add_account_ids(pair.second->base_data.account_id);
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "IMListener.h"
|
#include "IMListener.h"
|
||||||
#include "typeconvert.h"
|
#include "typeconvert.h"
|
||||||
#include "perfmonitor.h"
|
#include "perfmonitor.h"
|
||||||
|
#include "asynctaskmgr.h"
|
||||||
|
|
||||||
#include "framework/cpp/utils.h"
|
#include "framework/cpp/utils.h"
|
||||||
|
|
||||||
@ -126,6 +127,7 @@ void PlayerMgr::_SS_IM_QueryUserOnlineState(f8::MsgHdr& hdr, const ss::SS_IM_Que
|
|||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
AsyncTaskMgr::Instance()->_SS_IM_PushUserOnlineState(hdr, msg);
|
||||||
for (auto& user_info : msg.user_infos()) {
|
for (auto& user_info : msg.user_infos()) {
|
||||||
auto itr = watch_players_.find(user_info.base_data().account_id());
|
auto itr = watch_players_.find(user_info.base_data().account_id());
|
||||||
if (itr != watch_players_.end()) {
|
if (itr != watch_players_.end()) {
|
||||||
|
@ -238,12 +238,14 @@ message SS_IM_FriendApply
|
|||||||
|
|
||||||
message SS_IM_QueryUserOnlineState
|
message SS_IM_QueryUserOnlineState
|
||||||
{
|
{
|
||||||
|
optional MFIMMsgConext context = 1;
|
||||||
repeated string account_ids = 3;
|
repeated string account_ids = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message SS_IM_PushUserOnlineState
|
message SS_IM_PushUserOnlineState
|
||||||
{
|
{
|
||||||
repeated cs.MFUserInfo user_infos = 1;
|
optional MFIMMsgConext context = 1;
|
||||||
|
repeated cs.MFUserInfo user_infos = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message SS_IM_OnUserOnline
|
message SS_IM_OnUserOnline
|
||||||
|
Loading…
x
Reference in New Issue
Block a user