This commit is contained in:
aozhiwei 2020-06-22 14:42:01 +08:00
parent 4cac4e510c
commit 605d1f4527
2 changed files with 35 additions and 3 deletions

View File

@ -778,6 +778,7 @@ void Player::RemoveFriend(const std::string& account_id)
void Player::Update(long long tick)
{
last_run_tick_ = tick;
ProcessEvent();
}
const std::string Player::AccountId()
@ -864,7 +865,7 @@ void Player::ProcessEventTimerFunc()
long long last_event_idx = param.param2;
Player* hum = PlayerMgr::Instance()->GetPlayerByAccountId(account_id);
if (hum) {
hum->ProcessEvent(curr_max_event_idx, data_set);
hum->OnFetchEvent(curr_max_event_idx, data_set);
}
};
auto on_error =
@ -894,7 +895,7 @@ void Player::ProcessEventTimerFunc()
);
}
void Player::ProcessEvent(long long max_event_idx, const f8::DataSet* data_set)
void Player::OnFetchEvent(long long max_event_idx, const f8::DataSet* data_set)
{
curr_max_event_idx_ = max_event_idx;
if (data_set) {
@ -914,3 +915,31 @@ void Player::ProcessEvent(long long max_event_idx, const f8::DataSet* data_set)
}
}
}
void Player::ProcessEvent()
{
if (event_hash_.empty()) {
return;
}
std::vector<long long> processed_events;
processed_events.reserve(100);
for (auto& pair : event_hash_) {
if (processed_events.size() > 100) {
break;
}
processed_events.push_back(pair.first);
}
for (long long event_id : processed_events) {
event_hash_.erase(event_id);
}
}
void Player::OnFriendAgreeEvent(Event& event)
{
}
void Player::OnFriendDeleteEvent(Event& event)
{
}

View File

@ -121,7 +121,10 @@ private:
void PushFriendList();
void SyncOtherFriend();
void ProcessEventTimerFunc();
void ProcessEvent(long long max_event_idx, const f8::DataSet* data_set);
void OnFetchEvent(long long max_event_idx, const f8::DataSet* data_set);
void ProcessEvent();
void OnFriendAgreeEvent(Event& event);
void OnFriendDeleteEvent(Event& event);
private:
bool dirty_ = false;