First test version with network timeout. Only activity timeout and global timeout, no game admin timeout yet. Set to test values (will disconnect rapidly).

Modified method for init timeout (if session cannot be established) - now using one non-modifiable timer for each session, and an additional timer which is reset whenever session data is received.
This commit is contained in:
lotodore
2008-03-04 23:47:45 +00:00
parent 6d7e6d9a94
commit 9f0d204f56
21 changed files with 158 additions and 53 deletions
+39 -1
View File
@@ -20,7 +20,8 @@
#include <net/sessiondata.h>
SessionData::SessionData(SOCKET sockfd, SessionId id)
: m_sockfd(sockfd), m_id(id), m_state(SessionData::Init), m_readyFlag(false)
: m_sockfd(sockfd), m_id(id), m_state(SessionData::Init), m_readyFlag(false),
m_activityTimeoutNoticeSent(false)
{
}
@@ -100,3 +101,40 @@ SessionData::GetReceiveBuffer()
return m_receiveBuffer;
}
void
SessionData::ResetActivityTimer()
{
boost::mutex::scoped_lock lock(m_dataMutex);
m_activityTimeoutNoticeSent = false;
m_activityTimer.reset();
m_activityTimer.start();
}
unsigned
SessionData::GetActivityTimerElapsedSec() const
{
boost::mutex::scoped_lock lock(m_dataMutex);
return m_activityTimer.elapsed().total_seconds();
}
bool
SessionData::HasActivityNoticeBeenSent() const
{
boost::mutex::scoped_lock lock(m_dataMutex);
return m_activityTimeoutNoticeSent;
}
void
SessionData::MarkActivityNotice()
{
boost::mutex::scoped_lock lock(m_dataMutex);
m_activityTimeoutNoticeSent = true;
}
unsigned
SessionData::GetAutoDisconnectTimerElapsedSec() const
{
boost::mutex::scoped_lock lock(m_dataMutex);
return m_autoDisconnectTimer.elapsed().total_seconds();
}