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 | } |
Tom Joseph | 4173cf8 | 2017-03-16 19:08:13 +0530 | [diff] [blame] | 23 | break; |
Tom Joseph | f0ca513 | 2016-08-09 08:16:12 -0500 | [diff] [blame] | 24 | case State::ACTIVE: |
| 25 | if (elapsedSeconds < SESSION_INACTIVITY_TIMEOUT) |
| 26 | { |
| 27 | return true; |
| 28 | } |
Tom Joseph | 4173cf8 | 2017-03-16 19:08:13 +0530 | [diff] [blame] | 29 | break; |
Tom Joseph | f0ca513 | 2016-08-09 08:16:12 -0500 | [diff] [blame] | 30 | default: |
| 31 | return false; |
| 32 | } |
Tom Joseph | 4173cf8 | 2017-03-16 19:08:13 +0530 | [diff] [blame] | 33 | |
| 34 | return false; |
Tom Joseph | f0ca513 | 2016-08-09 08:16:12 -0500 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | } // namespace session |