Skip to content

Commit

Permalink
Always use async call for CheckAccess
Browse files Browse the repository at this point in the history
  • Loading branch information
BradleyMarie committed Dec 8, 2021
1 parent d83a0c7 commit 3b2ec8b
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions extension/extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,25 +424,20 @@ void AuthBySteamGroup::AllowJoin(int client_id, std::string group_id,
void AuthBySteamGroup::CheckAccess(int client_id, std::string group_id,
std::string steam_key) {
int user_id = GetUserIdByClientId(client_id);
auto async_op = std::async(
std::launch::async,
[this, user_id, group_id, steam_key]() -> std::function<void()> {
auto is_group_member =
CheckGroupMembership(user_id, group_id, steam_key);
if (!is_group_member.get()) {
return std::bind(&AuthBySteamGroup::CheckAccessFails, this, user_id);
}

auto check_membership = [this, user_id, group_id,
steam_key]() -> std::function<void()> {
auto is_group_member = CheckGroupMembership(user_id, group_id, steam_key);
if (!is_group_member.get()) {
return std::bind(&AuthBySteamGroup::CheckAccessFails, this, user_id);
}

return std::bind(&AuthBySteamGroup::CheckAccessSucceeds, this, user_id);
};
return std::bind(&AuthBySteamGroup::CheckAccessSucceeds, this, user_id);
});

std::lock_guard<std::mutex> lock(m_plugin_lock);
if (m_player_manager->GetNumPlayers() <= 1) {
check_membership()();
return;
}

m_async_operations.push_back(
std::async(std::launch::async, std::move(check_membership)));
m_async_operations.push_back(std::move(async_op));
}

void AuthBySteamGroup::PrintKickList(int client_id, std::string group_id,
Expand Down

0 comments on commit 3b2ec8b

Please sign in to comment.