This commit is contained in:
aozhiwei 2021-07-08 19:17:47 +08:00
parent 929ac197fd
commit ed0f3dfbac
2 changed files with 14 additions and 5 deletions

View File

@ -35,7 +35,7 @@ struct AsyncTaskContext
struct QueryUserStatusTask struct QueryUserStatusTask
{ {
AsyncTaskContext context; AsyncTaskContext context;
std::map<std::string, bool> users; std::map<std::string, cs::MFUserStatus> users;
void Done() void Done()
{ {
@ -43,8 +43,12 @@ struct QueryUserStatusTask
cs::SMQueryUserStatus msg; cs::SMQueryUserStatus msg;
for (auto& pair : users) { for (auto& pair : users) {
cs::MFUserStatus* user = msg.add_status_list(); cs::MFUserStatus* user = msg.add_status_list();
#if 1
*user = pair.second;
#else
user->set_account_id(pair.first); user->set_account_id(pair.first);
user->set__online(pair.second ? 1 : 0); user->set__online(pair.second ? 1 : 0);
#endif
} }
context.hum->SendMsg(msg); context.hum->SendMsg(msg);
} }
@ -161,7 +165,10 @@ void AsyncTaskMgr::CreateQueryUserStatusTask(Player* hum, std::vector<std::strin
hum->SendSSMsg(hum->myself, msg); hum->SendSSMsg(hum->myself, msg);
for (auto& account_id : account_ids) { for (auto& account_id : account_ids) {
task->users[account_id] = false; cs::MFUserStatus status;
status.set_account_id(account_id);
status.set__online(0);
task->users[account_id] = status;
} }
FillAsyncTaskContext(hum, &task->context, msg.context().seqid()); FillAsyncTaskContext(hum, &task->context, msg.context().seqid());
query_user_status_tasks_[task->context.seqid] = task; query_user_status_tasks_[task->context.seqid] = task;
@ -221,9 +228,10 @@ void AsyncTaskMgr::_SS_IM_PushUserOnlineState(f8::MsgHdr& hdr, const ss::SS_IM_P
QueryUserStatusTask* task = GetQueryUserStatusTask(msg.context().seqid()); QueryUserStatusTask* task = GetQueryUserStatusTask(msg.context().seqid());
if (task) { if (task) {
for (auto& user : msg.user_infos()) { for (auto& user : msg.user_infos()) {
if (task->users.find(user.base_data().account_id()) != auto itr = task->users.find(user.base_data().account_id());
task->users.end()) { if (itr != task->users.end()) {
task->users[user.base_data().account_id()] = true; itr->second.set__online(1);
*itr->second.mutable_temp_custom_data() = user.temp_custom_data();
} }
} }
} }

View File

@ -94,6 +94,7 @@ message MFUserStatus
{ {
optional string account_id = 1; //id optional string account_id = 1; //id
optional int32 _online = 2; //线 optional int32 _online = 2; //线
optional MFUserTempCustomData temp_custom_data = 3; //
} }
// //