Tom Joseph | f0ca513 | 2016-08-09 08:16:12 -0500 | [diff] [blame] | 1 | #include "session.hpp" |
| 2 | |
| 3 | #include <ctime> |
| 4 | |
| 5 | #include "endian.hpp" |
| 6 | |
| 7 | namespace session |
| 8 | { |
| 9 | |
| 10 | bool 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 |