blob: b80f51aec04f7fbca2ab50fc57353cda1ae6c028 [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 }
23 case State::ACTIVE:
24 if (elapsedSeconds < SESSION_INACTIVITY_TIMEOUT)
25 {
26 return true;
27 }
28 default:
29 return false;
30 }
31}
32
33} // namespace session