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:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user