Skip to content
Snippets Groups Projects
Commit 43c4c185 authored by Olivier Dion's avatar Olivier Dion
Browse files

agent: Make activate work

Change-Id: I08dc1c58529872c031ce9e5c36706173857f3f83
parent 66d5d955
No related branches found
No related tags found
No related merge requests found
...@@ -229,42 +229,13 @@ Agent::setDetails(const std::map<std::string, std::string>& details) ...@@ -229,42 +229,13 @@ Agent::setDetails(const std::map<std::string, std::string>& details)
} }
void void
Agent::activate(bool state) Agent::activate(bool enable)
{ {
LOG_AGENT_STATE(); LOG_AGENT_STATE();
std::mutex mtx; DRing::sendRegister(accountID_, enable);
std::condition_variable cv;
bool done = false;
onVolatileDetailsChanged_.add([&](const std::string& accountID,
const std::map<std::string, std::string>& details) {
if (accountID_ != accountID) {
return true;
}
AGENT_INFO("Account is %s",
details.at(DRing::Account::VolatileProperties::ACTIVE).c_str());
std::unique_lock lk(mtx);
done = true;
cv.notify_one();
return false;
});
DRing::setAccountActive(accountID_, state);
std::unique_lock lk(mtx);
cv.wait_for(lk, std::chrono::seconds(10), [&]{
return done;
});
if (state) { if (enable) {
waitForAnnouncement(); waitForAnnouncement();
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment