blob: 208dfd006676d79e6f97830cbdd1f48c1c98bfb8 [file] [log] [blame]
Tom Josephf0ca5132016-08-09 08:16:12 -05001#include "session.hpp"
2
3#include <ctime>
4
5#include "endian.hpp"
6
7namespace session
8{
9
10bool Session::isSessionActive()
11{
12 auto currentTime = std::chrono::steady_clock::now();
13 auto elapsedSeconds = std::chrono::duration_cast<std::chrono::seconds>
14 (currentTime - lastTime);
15
16 switch (state)
17 {
18 case State::SETUP_IN_PROGRESS:
19 if (elapsedSeconds < SESSION_SETUP_TIMEOUT)
20 {
21 return true;
22 }
Tom Joseph4173cf82017-03-16 19:08:13 +053023 break;
Tom Josephf0ca5132016-08-09 08:16:12 -050024 case State::ACTIVE:
25 if (elapsedSeconds < SESSION_INACTIVITY_TIMEOUT)
26 {
27 return true;
28 }
Tom Joseph4173cf82017-03-16 19:08:13 +053029 break;
Tom Josephf0ca5132016-08-09 08:16:12 -050030 default:
31 return false;
32 }
Tom Joseph4173cf82017-03-16 19:08:13 +053033
34 return false;
Tom Josephf0ca5132016-08-09 08:16:12 -050035}
36
37} // namespace session