summaryrefslogtreecommitdiffstats
path: root/session.hpp
diff options
context:
space:
mode:
authorVernon Mauery <vernon.mauery@linux.intel.com>2018-10-24 13:11:23 -0700
committerTom Joseph <tomjoseph@in.ibm.com>2018-11-14 14:52:40 +0000
commit07e5b28c142abc0d2f1a94d6ce9ef21446226f5e (patch)
tree29c42e09144e0161f440d6ebe89c2fd03bd423df /session.hpp
parentcc7b1cba79ba2eea6b0020058fa7990c71d0643c (diff)
downloadphosphor-net-ipmid-07e5b28c142abc0d2f1a94d6ce9ef21446226f5e.tar.gz
phosphor-net-ipmid-07e5b28c142abc0d2f1a94d6ce9ef21446226f5e.zip
netipmid: make session a header-only situation
The Session class is a fairly simple class, no need for an external cpp file; make it all header-only and allow the compiler to do its job. Change-Id: Ibbe7e963762926ec04c75ab187a5b8045de851f4 Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
Diffstat (limited to 'session.hpp')
-rw-r--r--session.hpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/session.hpp b/session.hpp
index 338a815..4ba3fa6 100644
--- a/session.hpp
+++ b/session.hpp
@@ -231,7 +231,31 @@ class Session
* transaction time is compared against the session inactivity timeout.
*
*/
- bool isSessionActive();
+ bool isSessionActive()
+ {
+ auto currentTime = std::chrono::steady_clock::now();
+ auto elapsedSeconds = std::chrono::duration_cast<std::chrono::seconds>(
+ currentTime - lastTime);
+
+ switch (state)
+ {
+ case State::SETUP_IN_PROGRESS:
+ if (elapsedSeconds < SESSION_SETUP_TIMEOUT)
+ {
+ return true;
+ }
+ break;
+ case State::ACTIVE:
+ if (elapsedSeconds < SESSION_INACTIVITY_TIMEOUT)
+ {
+ return true;
+ }
+ break;
+ default:
+ return false;
+ }
+ return false;
+ }
/**
* @brief Session's Current Privilege Level
OpenPOWER on IntegriCloud