Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Includes
- #include <iostream>
- using namespace std;
- //Local Project Includes
- #include "Timer.h"
- //Boost
- #include <boost/thread/thread.hpp>
- #include <boost/exception/all.hpp>
- #include <boost/bind.hpp>
- class Timer {
- private:
- bool UserLoginStatus;
- public:
- void StartTimer();
- void SetLoginStatus(bool LoginStatus);
- };
- //Starts the Timer
- void Timer::StartTimer() {
- //While The User Is Logged in
- while(this->UserLoginStatus == true) {
- try { //Try to sleep for 15 minutes
- boost::this_thread::sleep( boost::posix_time::seconds((60 * 15))); //Sleep For 15 Minutes
- //logout() Logout User
- }
- catch(NotIdleException except) { //This is Thrown if the user enters a command (is not idle)
- }
- }
- }
- //Change User Login LoginStatus
- void Timer::SetLoginStatus(bool LoginStatus) {
- this->UserLoginStatus = LoginStatus;
- }
- class NotIdleException {
- public:
- NotIdleException(const char* pStr = "There's a problem") : pMessage(pStr) {
- }
- const char* what() const {
- return pMessage;
- }
- private:
- const char* pMessage;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement