1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-12-22 10:24:26 +01:00

Some refactoring

This commit is contained in:
Ralf Ramsauer 2015-09-24 18:15:05 +02:00
parent deccb94cd5
commit 8b4be48811
2 changed files with 7 additions and 7 deletions

View File

@ -19,11 +19,11 @@ Logic::Logic(const chrono::seconds tokenTimeout,
const string &webPrefix,
const string &serDev,
const unsigned int baudrate,
condition_variable &onTokenUpdate) :
condition_variable &onClientUpdate) :
_logger(Logger::get()),
_door(serDev, baudrate),
_tokenTimeout(tokenTimeout),
_onTokenUpdate(onTokenUpdate),
_onClientUpdate(onClientUpdate),
_ldapUri(ldapUri),
_bindDN(bindDN),
_webPrefix(webPrefix)
@ -232,10 +232,10 @@ void Logic::_createNewToken(const bool stillValid)
message << "New Token generated: " << toHexString(_curToken) << " old Token: " << toHexString(_prevToken) << " is " << (_prevValid?"still":"not") << " valid";
_logger(message, LogLevel::info);
_onTokenUpdate.notify_all();
_onClientUpdate.notify_all();
}
std::string Logic::getCurrentToken() const
std::string Logic::getClientMessage() const
{
return _webPrefix + toHexString(_curToken);
}

View File

@ -28,14 +28,14 @@ public:
const std::string &webPrefix,
const std::string &serDev,
const unsigned int baudrate,
std::condition_variable &onTokenUpdate);
std::condition_variable &onClientUpdate);
~Logic();
// Parse incoming JSON Requests
Response parseRequest(const Json::Value &root);
// Returns the current Token
std::string getCurrentToken() const;
std::string getClientMessage() const;
private:
@ -82,7 +82,7 @@ private:
std::mutex _mutex = {};
// This variable gets notified on token updates
std::condition_variable &_onTokenUpdate;
std::condition_variable &_onClientUpdate;
// The URI of the ldap server
const std::string _ldapUri;