Switching from asio deadline_timer to asio steady_timer in order to fix #55. This requires the (boost or native) chrono lib.

This commit is contained in:
lotodore
2017-04-05 14:07:36 +02:00
committed by Kai Philipp
parent 94ea0e6c2f
commit 0ed986399f
17 changed files with 137 additions and 78 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ Linux:
- libgsasl version >= 1.4 --> http://www.gnu.org/software/gsasl/ - libgsasl version >= 1.4 --> http://www.gnu.org/software/gsasl/
- libboost_thread, libboost_filesystem, libboost_datetime, libboost_program_options, - libboost_thread, libboost_filesystem, libboost_datetime, libboost_program_options,
libboost_iostreams, libboost_asio, libboost_regex, libboost_random, libboost_uuid libboost_iostreams, libboost_asio, libboost_regex, libboost_random, libboost_uuid
(version >= 1.44, latest always recommended) --> http://www.boost.org/ (version >= 1.49, latest always recommended) --> http://www.boost.org/
- libSDL_mixer, libSDL --> http://www.libsdl.org/ - libSDL_mixer, libSDL --> http://www.libsdl.org/
- libSQLite3 --> http://sqlite.org/ - libSQLite3 --> http://sqlite.org/
- libtinyxml > 2.0 --> http://www.sourceforge.net/projects/tinyxml - libtinyxml > 2.0 --> http://www.sourceforge.net/projects/tinyxml
+4 -3
View File
@@ -35,6 +35,7 @@
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <boost/asio.hpp> #include <boost/asio.hpp>
#include <boost/asio/steady_timer.hpp>
#include <boost/enable_shared_from_this.hpp> #include <boost/enable_shared_from_this.hpp>
#include <string> #include <string>
#include <algorithm> #include <algorithm>
@@ -218,7 +219,7 @@ protected:
ClientState &GetState(); ClientState &GetState();
void SetState(ClientState &newState); void SetState(ClientState &newState);
boost::asio::deadline_timer &GetStateTimer(); boost::asio::steady_timer &GetStateTimer();
SenderHelper &GetSender(); SenderHelper &GetSender();
@@ -341,8 +342,8 @@ private:
mutable boost::mutex m_pingDataMutex; mutable boost::mutex m_pingDataMutex;
PingData m_pingData; PingData m_pingData;
boost::asio::deadline_timer m_stateTimer; boost::asio::steady_timer m_stateTimer;
boost::asio::deadline_timer m_avatarTimer; boost::asio::steady_timer m_avatarTimer;
friend class AbstractClientStateReceiving; friend class AbstractClientStateReceiving;
friend class ClientStateInit; friend class ClientStateInit;
+15 -9
View File
@@ -60,6 +60,12 @@
using namespace std; using namespace std;
using namespace boost::filesystem; using namespace boost::filesystem;
#ifdef BOOST_ASIO_HAS_STD_CHRONO
using namespace std::chrono;
#else
using namespace boost::chrono;
#endif
#define CLIENT_WAIT_TIMEOUT_MSEC 50 #define CLIENT_WAIT_TIMEOUT_MSEC 50
#define CLIENT_CONNECT_TIMEOUT_SEC 10 #define CLIENT_CONNECT_TIMEOUT_SEC 10
@@ -238,7 +244,7 @@ void
ClientStateDownloadingServerList::Enter(boost::shared_ptr<ClientThread> client) ClientStateDownloadingServerList::Enter(boost::shared_ptr<ClientThread> client)
{ {
client->GetStateTimer().expires_from_now( client->GetStateTimer().expires_from_now(
boost::posix_time::milliseconds(CLIENT_WAIT_TIMEOUT_MSEC)); milliseconds(CLIENT_WAIT_TIMEOUT_MSEC));
client->GetStateTimer().async_wait( client->GetStateTimer().async_wait(
boost::bind( boost::bind(
&ClientStateDownloadingServerList::TimerLoop, this, boost::asio::placeholders::error, client)); &ClientStateDownloadingServerList::TimerLoop, this, boost::asio::placeholders::error, client));
@@ -265,7 +271,7 @@ ClientStateDownloadingServerList::TimerLoop(const boost::system::error_code& ec,
client->SetState(ClientStateReadingServerList::Instance()); client->SetState(ClientStateReadingServerList::Instance());
} else { } else {
client->GetStateTimer().expires_from_now( client->GetStateTimer().expires_from_now(
boost::posix_time::milliseconds(CLIENT_WAIT_TIMEOUT_MSEC)); milliseconds(CLIENT_WAIT_TIMEOUT_MSEC));
client->GetStateTimer().async_wait( client->GetStateTimer().async_wait(
boost::bind( boost::bind(
&ClientStateDownloadingServerList::TimerLoop, this, boost::asio::placeholders::error, client)); &ClientStateDownloadingServerList::TimerLoop, this, boost::asio::placeholders::error, client));
@@ -409,7 +415,7 @@ void
ClientStateWaitChooseServer::Enter(boost::shared_ptr<ClientThread> client) ClientStateWaitChooseServer::Enter(boost::shared_ptr<ClientThread> client)
{ {
client->GetStateTimer().expires_from_now( client->GetStateTimer().expires_from_now(
boost::posix_time::milliseconds(CLIENT_WAIT_TIMEOUT_MSEC)); milliseconds(CLIENT_WAIT_TIMEOUT_MSEC));
client->GetStateTimer().async_wait( client->GetStateTimer().async_wait(
boost::bind( boost::bind(
&ClientStateWaitChooseServer::TimerLoop, this, boost::asio::placeholders::error, client)); &ClientStateWaitChooseServer::TimerLoop, this, boost::asio::placeholders::error, client));
@@ -432,7 +438,7 @@ ClientStateWaitChooseServer::TimerLoop(const boost::system::error_code& ec, boos
client->SetState(ClientStateStartResolve::Instance()); client->SetState(ClientStateStartResolve::Instance());
} else { } else {
client->GetStateTimer().expires_from_now( client->GetStateTimer().expires_from_now(
boost::posix_time::milliseconds(CLIENT_WAIT_TIMEOUT_MSEC)); milliseconds(CLIENT_WAIT_TIMEOUT_MSEC));
client->GetStateTimer().async_wait( client->GetStateTimer().async_wait(
boost::bind( boost::bind(
&ClientStateWaitChooseServer::TimerLoop, this, boost::asio::placeholders::error, client)); &ClientStateWaitChooseServer::TimerLoop, this, boost::asio::placeholders::error, client));
@@ -461,7 +467,7 @@ void
ClientStateStartConnect::Enter(boost::shared_ptr<ClientThread> client) ClientStateStartConnect::Enter(boost::shared_ptr<ClientThread> client)
{ {
client->GetStateTimer().expires_from_now( client->GetStateTimer().expires_from_now(
boost::posix_time::seconds(CLIENT_CONNECT_TIMEOUT_SEC)); seconds(CLIENT_CONNECT_TIMEOUT_SEC));
client->GetStateTimer().async_wait( client->GetStateTimer().async_wait(
boost::bind( boost::bind(
&ClientStateStartConnect::TimerTimeout, this, boost::asio::placeholders::error, client)); &ClientStateStartConnect::TimerTimeout, this, boost::asio::placeholders::error, client));
@@ -986,7 +992,7 @@ void
ClientStateWaitEnterLogin::Enter(boost::shared_ptr<ClientThread> client) ClientStateWaitEnterLogin::Enter(boost::shared_ptr<ClientThread> client)
{ {
client->GetStateTimer().expires_from_now( client->GetStateTimer().expires_from_now(
boost::posix_time::milliseconds(CLIENT_WAIT_TIMEOUT_MSEC)); milliseconds(CLIENT_WAIT_TIMEOUT_MSEC));
client->GetStateTimer().async_wait( client->GetStateTimer().async_wait(
boost::bind( boost::bind(
&ClientStateWaitEnterLogin::TimerLoop, this, boost::asio::placeholders::error, client)); &ClientStateWaitEnterLogin::TimerLoop, this, boost::asio::placeholders::error, client));
@@ -1065,7 +1071,7 @@ ClientStateWaitEnterLogin::TimerLoop(const boost::system::error_code& ec, boost:
} }
} else { } else {
client->GetStateTimer().expires_from_now( client->GetStateTimer().expires_from_now(
boost::posix_time::milliseconds(CLIENT_WAIT_TIMEOUT_MSEC)); milliseconds(CLIENT_WAIT_TIMEOUT_MSEC));
client->GetStateTimer().async_wait( client->GetStateTimer().async_wait(
boost::bind( boost::bind(
&ClientStateWaitEnterLogin::TimerLoop, this, boost::asio::placeholders::error, client)); &ClientStateWaitEnterLogin::TimerLoop, this, boost::asio::placeholders::error, client));
@@ -1399,7 +1405,7 @@ void
ClientStateSynchronizeStart::Enter(boost::shared_ptr<ClientThread> client) ClientStateSynchronizeStart::Enter(boost::shared_ptr<ClientThread> client)
{ {
client->GetStateTimer().expires_from_now( client->GetStateTimer().expires_from_now(
boost::posix_time::milliseconds(CLIENT_WAIT_TIMEOUT_MSEC)); milliseconds(CLIENT_WAIT_TIMEOUT_MSEC));
client->GetStateTimer().async_wait( client->GetStateTimer().async_wait(
boost::bind( boost::bind(
&ClientStateSynchronizeStart::TimerLoop, this, boost::asio::placeholders::error, client)); &ClientStateSynchronizeStart::TimerLoop, this, boost::asio::placeholders::error, client));
@@ -1429,7 +1435,7 @@ ClientStateSynchronizeStart::TimerLoop(const boost::system::error_code& ec, boos
client->SetState(ClientStateWaitStart::Instance()); client->SetState(ClientStateWaitStart::Instance());
} else { } else {
client->GetStateTimer().expires_from_now( client->GetStateTimer().expires_from_now(
boost::posix_time::milliseconds(CLIENT_WAIT_TIMEOUT_MSEC)); milliseconds(CLIENT_WAIT_TIMEOUT_MSEC));
client->GetStateTimer().async_wait( client->GetStateTimer().async_wait(
boost::bind( boost::bind(
&ClientStateSynchronizeStart::TimerLoop, this, boost::asio::placeholders::error, client)); &ClientStateSynchronizeStart::TimerLoop, this, boost::asio::placeholders::error, client));
+9 -3
View File
@@ -66,6 +66,12 @@ using namespace std;
using namespace boost::filesystem; using namespace boost::filesystem;
using boost::asio::ip::tcp; using boost::asio::ip::tcp;
#ifdef BOOST_ASIO_HAS_STD_CHRONO
using namespace std::chrono;
#else
using namespace boost::chrono;
#endif
ClientThread::ClientThread(GuiInterface &gui, AvatarManager &avatarManager, Log *myLog) ClientThread::ClientThread(GuiInterface &gui, AvatarManager &avatarManager, Log *myLog)
: m_ioService(new boost::asio::io_service), m_clientLog(myLog), m_curState(NULL), m_gui(gui), : m_ioService(new boost::asio::io_service), m_clientLog(myLog), m_curState(NULL), m_gui(gui),
m_avatarManager(avatarManager), m_isServerSelected(false), m_avatarManager(avatarManager), m_isServerSelected(false),
@@ -586,7 +592,7 @@ void
ClientThread::RegisterTimers() ClientThread::RegisterTimers()
{ {
m_avatarTimer.expires_from_now( m_avatarTimer.expires_from_now(
boost::posix_time::milliseconds(CLIENT_AVATAR_LOOP_MSEC)); milliseconds(CLIENT_AVATAR_LOOP_MSEC));
m_avatarTimer.async_wait( m_avatarTimer.async_wait(
boost::bind( boost::bind(
&ClientThread::TimerCheckAvatarDownloads, shared_from_this(), boost::asio::placeholders::error)); &ClientThread::TimerCheckAvatarDownloads, shared_from_this(), boost::asio::placeholders::error));
@@ -910,7 +916,7 @@ ClientThread::TimerCheckAvatarDownloads(const boost::system::error_code& ec)
PassAvatarFileToManager(playerId, tmpAvatar); PassAvatarFileToManager(playerId, tmpAvatar);
} }
m_avatarTimer.expires_from_now( m_avatarTimer.expires_from_now(
boost::posix_time::milliseconds(CLIENT_AVATAR_LOOP_MSEC)); milliseconds(CLIENT_AVATAR_LOOP_MSEC));
m_avatarTimer.async_wait( m_avatarTimer.async_wait(
boost::bind( boost::bind(
&ClientThread::TimerCheckAvatarDownloads, shared_from_this(), boost::asio::placeholders::error)); &ClientThread::TimerCheckAvatarDownloads, shared_from_this(), boost::asio::placeholders::error));
@@ -1022,7 +1028,7 @@ ClientThread::SetState(ClientState &newState)
m_curState->Enter(shared_from_this()); m_curState->Enter(shared_from_this());
} }
boost::asio::deadline_timer & boost::asio::steady_timer &
ClientThread::GetStateTimer() ClientThread::GetStateTimer()
{ {
return m_stateTimer; return m_stateTimer;
+12 -6
View File
@@ -49,6 +49,12 @@
using namespace std; using namespace std;
using namespace boost::filesystem; using namespace boost::filesystem;
#ifdef BOOST_ASIO_HAS_STD_CHRONO
using namespace std::chrono;
#else
using namespace boost::chrono;
#endif
ServerAdminBot::ServerAdminBot(boost::shared_ptr<boost::asio::io_service> ioService) ServerAdminBot::ServerAdminBot(boost::shared_ptr<boost::asio::io_service> ioService)
: m_notifyTimeoutMinutes(0), m_notifyIntervalMinutes(0), m_notifyCounter(0), : m_notifyTimeoutMinutes(0), m_notifyIntervalMinutes(0), m_notifyCounter(0),
m_notifyTimer(boost::posix_time::time_duration(0, 0, 0), boost::timers::portable::second_timer::manual_start), m_notifyTimer(boost::posix_time::time_duration(0, 0, 0), boost::timers::portable::second_timer::manual_start),
@@ -272,17 +278,17 @@ ServerAdminBot::Run()
if (m_ircAdminThread) { if (m_ircAdminThread) {
// Initialise the timers. // Initialise the timers.
m_reconnectTimer.expires_from_now( m_reconnectTimer.expires_from_now(
boost::posix_time::seconds(SERVER_RESTART_IRC_BOT_INTERVAL_SEC)); seconds(SERVER_RESTART_IRC_BOT_INTERVAL_SEC));
m_reconnectTimer.async_wait( m_reconnectTimer.async_wait(
boost::bind( boost::bind(
&ServerAdminBot::ReconnectHandler, shared_from_this(), boost::asio::placeholders::error)); &ServerAdminBot::ReconnectHandler, shared_from_this(), boost::asio::placeholders::error));
m_notifyLoopTimer.expires_from_now( m_notifyLoopTimer.expires_from_now(
boost::posix_time::seconds(SERVER_NOTIFY_IRC_BOT_INTERVAL_SEC)); seconds(SERVER_NOTIFY_IRC_BOT_INTERVAL_SEC));
m_notifyLoopTimer.async_wait( m_notifyLoopTimer.async_wait(
boost::bind( boost::bind(
&ServerAdminBot::NotifyLoop, shared_from_this(), boost::asio::placeholders::error)); &ServerAdminBot::NotifyLoop, shared_from_this(), boost::asio::placeholders::error));
m_checkFileTimer.expires_from_now( m_checkFileTimer.expires_from_now(
boost::posix_time::seconds(SERVER_CHECK_IRC_BOT_INTERVAL_SEC)); seconds(SERVER_CHECK_IRC_BOT_INTERVAL_SEC));
m_checkFileTimer.async_wait( m_checkFileTimer.async_wait(
boost::bind( boost::bind(
&ServerAdminBot::CheckFileHandler, shared_from_this(), boost::asio::placeholders::error)); &ServerAdminBot::CheckFileHandler, shared_from_this(), boost::asio::placeholders::error));
@@ -298,7 +304,7 @@ ServerAdminBot::ReconnectHandler(const boost::system::error_code& ec)
Reconnect(); Reconnect();
m_reconnectTimer.expires_from_now( m_reconnectTimer.expires_from_now(
boost::posix_time::seconds(SERVER_RESTART_IRC_BOT_INTERVAL_SEC)); seconds(SERVER_RESTART_IRC_BOT_INTERVAL_SEC));
m_reconnectTimer.async_wait( m_reconnectTimer.async_wait(
boost::bind( boost::bind(
&ServerAdminBot::ReconnectHandler, shared_from_this(), boost::asio::placeholders::error)); &ServerAdminBot::ReconnectHandler, shared_from_this(), boost::asio::placeholders::error));
@@ -330,7 +336,7 @@ ServerAdminBot::CheckFileHandler(const boost::system::error_code& ec)
Reconnect(); Reconnect();
} }
m_checkFileTimer.expires_from_now( m_checkFileTimer.expires_from_now(
boost::posix_time::seconds(SERVER_CHECK_IRC_BOT_INTERVAL_SEC)); seconds(SERVER_CHECK_IRC_BOT_INTERVAL_SEC));
m_checkFileTimer.async_wait( m_checkFileTimer.async_wait(
boost::bind( boost::bind(
&ServerAdminBot::CheckFileHandler, shared_from_this(), boost::asio::placeholders::error)); &ServerAdminBot::CheckFileHandler, shared_from_this(), boost::asio::placeholders::error));
@@ -386,7 +392,7 @@ ServerAdminBot::NotifyLoop(const boost::system::error_code& ec)
} }
} }
m_notifyLoopTimer.expires_from_now( m_notifyLoopTimer.expires_from_now(
boost::posix_time::seconds(SERVER_NOTIFY_IRC_BOT_INTERVAL_SEC)); seconds(SERVER_NOTIFY_IRC_BOT_INTERVAL_SEC));
m_notifyLoopTimer.async_wait( m_notifyLoopTimer.async_wait(
boost::bind( boost::bind(
&ServerAdminBot::NotifyLoop, shared_from_this(), boost::asio::placeholders::error)); &ServerAdminBot::NotifyLoop, shared_from_this(), boost::asio::placeholders::error));
+12 -7
View File
@@ -34,6 +34,11 @@
using namespace std; using namespace std;
#ifdef BOOST_ASIO_HAS_STD_CHRONO
using namespace std::chrono;
#else
using namespace boost::chrono;
#endif
ServerBanManager::ServerBanManager(boost::shared_ptr<boost::asio::io_service> ioService) ServerBanManager::ServerBanManager(boost::shared_ptr<boost::asio::io_service> ioService)
: m_ioService(ioService), m_curBanId(0) : m_ioService(ioService), m_curBanId(0)
@@ -126,7 +131,7 @@ ServerBanManager::GetBanList(list<string> &list) const
banText << (*i_nick).first << ": (nickStr) - " << (*i_nick).second.nameStr; banText << (*i_nick).first << ": (nickStr) - " << (*i_nick).second.nameStr;
if ((*i_nick).second.timer) if ((*i_nick).second.timer)
banText << " duration: " << (*i_nick).second.timer->expires_from_now().hours() << "h"; banText << " duration: " << duration_cast<hours>((*i_nick).second.timer->expires_from_now()).count() << "h";
list.push_back(banText.str()); list.push_back(banText.str());
++i_nick; ++i_nick;
} }
@@ -136,7 +141,7 @@ ServerBanManager::GetBanList(list<string> &list) const
ostringstream banText; ostringstream banText;
banText << (*i_ip).first << ": (IP) - " << (*i_ip).second.ipAddress; banText << (*i_ip).first << ": (IP) - " << (*i_ip).second.ipAddress;
if ((*i_ip).second.timer) if ((*i_ip).second.timer)
banText << " duration: " << (*i_ip).second.timer->expires_from_now().hours() << "h"; banText << " duration: " << duration_cast<hours>((*i_ip).second.timer->expires_from_now()).count() << "h";
list.push_back(banText.str()); list.push_back(banText.str());
++i_ip; ++i_ip;
} }
@@ -235,14 +240,14 @@ ServerBanManager::IsBadGameName(const std::string &name) const
return retVal; return retVal;
} }
boost::shared_ptr<boost::asio::deadline_timer> boost::shared_ptr<boost::asio::steady_timer>
ServerBanManager::InternalRegisterTimedBan(unsigned timerId, unsigned durationHours) ServerBanManager::InternalRegisterTimedBan(unsigned timerId, unsigned durationHours)
{ {
boost::shared_ptr<boost::asio::deadline_timer> tmpTimer; boost::shared_ptr<boost::asio::steady_timer> tmpTimer;
if (durationHours) { if (durationHours) {
tmpTimer.reset(new boost::asio::deadline_timer(*m_ioService)); tmpTimer.reset(new boost::asio::steady_timer(*m_ioService));
tmpTimer->expires_from_now( tmpTimer->expires_from_now(
boost::posix_time::hours(durationHours)); hours(durationHours));
tmpTimer->async_wait( tmpTimer->async_wait(
boost::bind( boost::bind(
&ServerBanManager::TimerRemoveBan, shared_from_this(), boost::asio::placeholders::error, timerId, tmpTimer)); &ServerBanManager::TimerRemoveBan, shared_from_this(), boost::asio::placeholders::error, timerId, tmpTimer));
@@ -251,7 +256,7 @@ ServerBanManager::InternalRegisterTimedBan(unsigned timerId, unsigned durationHo
} }
void void
ServerBanManager::TimerRemoveBan(const boost::system::error_code &ec, unsigned banId, boost::shared_ptr<boost::asio::deadline_timer> timer) ServerBanManager::TimerRemoveBan(const boost::system::error_code &ec, unsigned banId, boost::shared_ptr<boost::asio::steady_timer> timer)
{ {
if (!ec && timer) if (!ec && timer)
UnBan(banId); UnBan(banId);
+10 -4
View File
@@ -53,6 +53,12 @@
using namespace std; using namespace std;
#ifdef BOOST_ASIO_HAS_STD_CHRONO
using namespace std::chrono;
#else
using namespace boost::chrono;
#endif
static bool LessThanPlayerHandStartMoney(const boost::shared_ptr<PlayerInterface> p1, const boost::shared_ptr<PlayerInterface> p2) static bool LessThanPlayerHandStartMoney(const boost::shared_ptr<PlayerInterface> p1, const boost::shared_ptr<PlayerInterface> p2)
{ {
return p1->getMyRoundStartCash() < p2->getMyRoundStartCash(); return p1->getMyRoundStartCash() < p2->getMyRoundStartCash();
@@ -276,7 +282,7 @@ ServerGame::TimerVoteKick(const boost::system::error_code &ec)
m_voteKickData.reset(); m_voteKickData.reset();
} }
m_voteKickTimer.expires_from_now( m_voteKickTimer.expires_from_now(
boost::posix_time::milliseconds(SERVER_CHECK_VOTE_KICK_INTERVAL_MSEC)); milliseconds(SERVER_CHECK_VOTE_KICK_INTERVAL_MSEC));
m_voteKickTimer.async_wait( m_voteKickTimer.async_wait(
boost::bind( boost::bind(
&ServerGame::TimerVoteKick, shared_from_this(), boost::asio::placeholders::error)); &ServerGame::TimerVoteKick, shared_from_this(), boost::asio::placeholders::error));
@@ -515,7 +521,7 @@ ServerGame::InternalAskVoteKick(boost::shared_ptr<SessionData> byWhom, unsigned
SendToAllPlayers(packet, SessionData::Game); SendToAllPlayers(packet, SessionData::Game);
m_voteKickTimer.expires_from_now( m_voteKickTimer.expires_from_now(
boost::posix_time::milliseconds(SERVER_CHECK_VOTE_KICK_INTERVAL_MSEC)); milliseconds(SERVER_CHECK_VOTE_KICK_INTERVAL_MSEC));
m_voteKickTimer.async_wait( m_voteKickTimer.async_wait(
boost::bind( boost::bind(
&ServerGame::TimerVoteKick, shared_from_this(), boost::asio::placeholders::error)); &ServerGame::TimerVoteKick, shared_from_this(), boost::asio::placeholders::error));
@@ -1073,13 +1079,13 @@ ServerGame::SetState(ServerGameState &newState)
m_curState->Enter(shared_from_this()); m_curState->Enter(shared_from_this());
} }
boost::asio::deadline_timer & boost::asio::steady_timer &
ServerGame::GetStateTimer1() ServerGame::GetStateTimer1()
{ {
return m_stateTimer1; return m_stateTimer1;
} }
boost::asio::deadline_timer & boost::asio::steady_timer &
ServerGame::GetStateTimer2() ServerGame::GetStateTimer2()
{ {
return m_stateTimer2; return m_stateTimer2;
+19 -13
View File
@@ -52,6 +52,12 @@
using namespace std; using namespace std;
#ifdef BOOST_ASIO_HAS_STD_CHRONO
using namespace std::chrono;
#else
using namespace boost::chrono;
#endif
//#define POKERTH_SERVER_TEST //#define POKERTH_SERVER_TEST
#ifdef POKERTH_SERVER_TEST #ifdef POKERTH_SERVER_TEST
@@ -575,7 +581,7 @@ ServerGameStateInit::RegisterAdminTimer(boost::shared_ptr<ServerGame> server)
// No admin timeout in LAN or ranking games. // No admin timeout in LAN or ranking games.
if (server->GetLobbyThread().GetServerMode() != SERVER_MODE_LAN && server->GetGameData().gameType != GAME_TYPE_RANKING) { if (server->GetLobbyThread().GetServerMode() != SERVER_MODE_LAN && server->GetGameData().gameType != GAME_TYPE_RANKING) {
server->GetStateTimer1().expires_from_now( server->GetStateTimer1().expires_from_now(
boost::posix_time::seconds(SERVER_GAME_ADMIN_TIMEOUT_SEC - SERVER_GAME_ADMIN_WARNING_REMAINING_SEC)); seconds(SERVER_GAME_ADMIN_TIMEOUT_SEC - SERVER_GAME_ADMIN_WARNING_REMAINING_SEC));
server->GetStateTimer1().async_wait( server->GetStateTimer1().async_wait(
boost::bind( boost::bind(
&ServerGameStateInit::TimerAdminWarning, this, boost::asio::placeholders::error, server)); &ServerGameStateInit::TimerAdminWarning, this, boost::asio::placeholders::error, server));
@@ -594,7 +600,7 @@ ServerGameStateInit::RegisterAutoStartTimer(boost::shared_ptr<ServerGame> server
// No autostart in LAN games. // No autostart in LAN games.
if (server->GetLobbyThread().GetServerMode() != SERVER_MODE_LAN) { if (server->GetLobbyThread().GetServerMode() != SERVER_MODE_LAN) {
server->GetStateTimer2().expires_from_now( server->GetStateTimer2().expires_from_now(
boost::posix_time::seconds(SERVER_AUTOSTART_GAME_DELAY_SEC)); seconds(SERVER_AUTOSTART_GAME_DELAY_SEC));
server->GetStateTimer2().async_wait( server->GetStateTimer2().async_wait(
boost::bind( boost::bind(
&ServerGameStateInit::TimerAutoStart, this, boost::asio::placeholders::error, server)); &ServerGameStateInit::TimerAutoStart, this, boost::asio::placeholders::error, server));
@@ -632,7 +638,7 @@ ServerGameStateInit::TimerAdminWarning(const boost::system::error_code &ec, boos
} }
// Start timeout timer. // Start timeout timer.
server->GetStateTimer1().expires_from_now( server->GetStateTimer1().expires_from_now(
boost::posix_time::seconds(SERVER_GAME_ADMIN_WARNING_REMAINING_SEC)); seconds(SERVER_GAME_ADMIN_WARNING_REMAINING_SEC));
server->GetStateTimer1().async_wait( server->GetStateTimer1().async_wait(
boost::bind( boost::bind(
&ServerGameStateInit::TimerAdminTimeout, this, boost::asio::placeholders::error, server)); &ServerGameStateInit::TimerAdminTimeout, this, boost::asio::placeholders::error, server));
@@ -767,7 +773,7 @@ void
ServerGameStateStartGame::Enter(boost::shared_ptr<ServerGame> server) ServerGameStateStartGame::Enter(boost::shared_ptr<ServerGame> server)
{ {
server->GetStateTimer1().expires_from_now( server->GetStateTimer1().expires_from_now(
boost::posix_time::seconds(SERVER_START_GAME_TIMEOUT_SEC)); seconds(SERVER_START_GAME_TIMEOUT_SEC));
server->GetStateTimer1().async_wait( server->GetStateTimer1().async_wait(
boost::bind( boost::bind(
&ServerGameStateStartGame::TimerTimeout, this, boost::asio::placeholders::error, server)); &ServerGameStateStartGame::TimerTimeout, this, boost::asio::placeholders::error, server));
@@ -930,7 +936,7 @@ void
ServerGameStateHand::Enter(boost::shared_ptr<ServerGame> server) ServerGameStateHand::Enter(boost::shared_ptr<ServerGame> server)
{ {
server->GetStateTimer1().expires_from_now( server->GetStateTimer1().expires_from_now(
boost::posix_time::milliseconds(SERVER_LOOP_DELAY_MSEC)); milliseconds(SERVER_LOOP_DELAY_MSEC));
server->GetStateTimer1().async_wait( server->GetStateTimer1().async_wait(
boost::bind( boost::bind(
&ServerGameStateHand::TimerLoop, this, boost::asio::placeholders::error, server)); &ServerGameStateHand::TimerLoop, this, boost::asio::placeholders::error, server));
@@ -1007,7 +1013,7 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr<ServerGame> server)
curGame.getCurrentHand()->setCardsShown(true); curGame.getCurrentHand()->setCardsShown(true);
server->GetStateTimer1().expires_from_now( server->GetStateTimer1().expires_from_now(
boost::posix_time::seconds(SERVER_SHOW_CARDS_DELAY_SEC)); seconds(SERVER_SHOW_CARDS_DELAY_SEC));
server->GetStateTimer1().async_wait( server->GetStateTimer1().async_wait(
boost::bind( boost::bind(
&ServerGameStateHand::TimerShowCards, this, boost::asio::placeholders::error, server)); &ServerGameStateHand::TimerShowCards, this, boost::asio::placeholders::error, server));
@@ -1015,7 +1021,7 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr<ServerGame> server)
SendNewRoundCards(*server, curGame, newRound); SendNewRoundCards(*server, curGame, newRound);
server->GetStateTimer1().expires_from_now( server->GetStateTimer1().expires_from_now(
boost::posix_time::seconds(GetDealCardsDelaySec(*server))); seconds(GetDealCardsDelaySec(*server)));
server->GetStateTimer1().async_wait( server->GetStateTimer1().async_wait(
boost::bind( boost::bind(
&ServerGameStateHand::TimerLoop, this, boost::asio::placeholders::error, server)); &ServerGameStateHand::TimerLoop, this, boost::asio::placeholders::error, server));
@@ -1043,7 +1049,7 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr<ServerGame> server)
// If the player is computer controlled, let the engine act. // If the player is computer controlled, let the engine act.
if (curPlayer->getMyType() == PLAYER_TYPE_COMPUTER) { if (curPlayer->getMyType() == PLAYER_TYPE_COMPUTER) {
server->GetStateTimer1().expires_from_now( server->GetStateTimer1().expires_from_now(
boost::posix_time::seconds(SERVER_COMPUTER_ACTION_DELAY_SEC)); seconds(SERVER_COMPUTER_ACTION_DELAY_SEC));
server->GetStateTimer1().async_wait( server->GetStateTimer1().async_wait(
boost::bind( boost::bind(
&ServerGameStateHand::TimerComputerAction, this, boost::asio::placeholders::error, server)); &ServerGameStateHand::TimerComputerAction, this, boost::asio::placeholders::error, server));
@@ -1054,7 +1060,7 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr<ServerGame> server)
PerformPlayerAction(*server, curPlayer, PLAYER_ACTION_FOLD, 0); PerformPlayerAction(*server, curPlayer, PLAYER_ACTION_FOLD, 0);
server->GetStateTimer1().expires_from_now( server->GetStateTimer1().expires_from_now(
boost::posix_time::milliseconds(SERVER_LOOP_DELAY_MSEC)); milliseconds(SERVER_LOOP_DELAY_MSEC));
server->GetStateTimer1().async_wait( server->GetStateTimer1().async_wait(
boost::bind( boost::bind(
&ServerGameStateHand::TimerLoop, this, boost::asio::placeholders::error, server)); &ServerGameStateHand::TimerLoop, this, boost::asio::placeholders::error, server));
@@ -1122,7 +1128,7 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr<ServerGame> server)
// View a dialog for a new game - delayed. // View a dialog for a new game - delayed.
server->GetStateTimer1().expires_from_now( server->GetStateTimer1().expires_from_now(
boost::posix_time::seconds(SERVER_DELAY_NEXT_GAME_SEC)); seconds(SERVER_DELAY_NEXT_GAME_SEC));
server->GetStateTimer1().async_wait( server->GetStateTimer1().async_wait(
boost::bind( boost::bind(
&ServerGameStateHand::TimerNextGame, this, boost::asio::placeholders::error, server, winnerPlayer->getMyUniqueID())); &ServerGameStateHand::TimerNextGame, this, boost::asio::placeholders::error, server, winnerPlayer->getMyUniqueID()));
@@ -1141,7 +1147,7 @@ ServerGameStateHand::TimerShowCards(const boost::system::error_code &ec, boost::
SendNewRoundCards(*server, curGame, curGame.getCurrentHand()->getCurrentRound()); SendNewRoundCards(*server, curGame, curGame.getCurrentHand()->getCurrentRound());
server->GetStateTimer1().expires_from_now( server->GetStateTimer1().expires_from_now(
boost::posix_time::seconds(GetDealCardsDelaySec(*server))); seconds(GetDealCardsDelaySec(*server)));
server->GetStateTimer1().async_wait( server->GetStateTimer1().async_wait(
boost::bind( boost::bind(
&ServerGameStateHand::TimerLoop, this, boost::asio::placeholders::error, server)); &ServerGameStateHand::TimerLoop, this, boost::asio::placeholders::error, server));
@@ -1512,7 +1518,7 @@ ServerGameStateWaitPlayerAction::Enter(boost::shared_ptr<ServerGame> server)
int timeoutSec = server->GetGameData().playerActionTimeoutSec + SERVER_PLAYER_TIMEOUT_ADD_DELAY_SEC; int timeoutSec = server->GetGameData().playerActionTimeoutSec + SERVER_PLAYER_TIMEOUT_ADD_DELAY_SEC;
#endif #endif
server->GetStateTimer1().expires_from_now(boost::posix_time::seconds(timeoutSec)); server->GetStateTimer1().expires_from_now(seconds(timeoutSec));
server->GetStateTimer1().async_wait( server->GetStateTimer1().async_wait(
boost::bind( boost::bind(
&ServerGameStateWaitPlayerAction::TimerTimeout, this, boost::asio::placeholders::error, server)); &ServerGameStateWaitPlayerAction::TimerTimeout, this, boost::asio::placeholders::error, server));
@@ -1646,7 +1652,7 @@ ServerGameStateWaitNextHand::Enter(boost::shared_ptr<ServerGame> server)
#endif #endif
server->GetStateTimer1().expires_from_now( server->GetStateTimer1().expires_from_now(
boost::posix_time::seconds(timeoutSec)); seconds(timeoutSec));
server->GetStateTimer1().async_wait( server->GetStateTimer1().async_wait(
boost::bind( boost::bind(
+8 -2
View File
@@ -45,6 +45,12 @@
using namespace std; using namespace std;
#ifdef BOOST_ASIO_HAS_STD_CHRONO
using namespace std::chrono;
#else
using namespace boost::chrono;
#endif
ServerLobbyBot::ServerLobbyBot(boost::shared_ptr<boost::asio::io_service> ioService) ServerLobbyBot::ServerLobbyBot(boost::shared_ptr<boost::asio::io_service> ioService)
: m_reconnectTimer(*ioService) : m_reconnectTimer(*ioService)
{ {
@@ -110,7 +116,7 @@ ServerLobbyBot::Run()
if (m_ircLobbyThread) { if (m_ircLobbyThread) {
// Initialise the reconnect timer. // Initialise the reconnect timer.
m_reconnectTimer.expires_from_now( m_reconnectTimer.expires_from_now(
boost::posix_time::seconds(SERVER_RESTART_IRC_BOT_INTERVAL_SEC)); seconds(SERVER_RESTART_IRC_BOT_INTERVAL_SEC));
m_reconnectTimer.async_wait( m_reconnectTimer.async_wait(
boost::bind( boost::bind(
&ServerLobbyBot::Reconnect, shared_from_this(), boost::asio::placeholders::error)); &ServerLobbyBot::Reconnect, shared_from_this(), boost::asio::placeholders::error));
@@ -132,7 +138,7 @@ ServerLobbyBot::Reconnect(const boost::system::error_code& ec)
} }
} }
m_reconnectTimer.expires_from_now( m_reconnectTimer.expires_from_now(
boost::posix_time::seconds(SERVER_RESTART_IRC_BOT_INTERVAL_SEC)); seconds(SERVER_RESTART_IRC_BOT_INTERVAL_SEC));
m_reconnectTimer.async_wait( m_reconnectTimer.async_wait(
boost::bind( boost::bind(
&ServerLobbyBot::Reconnect, shared_from_this(), boost::asio::placeholders::error)); &ServerLobbyBot::Reconnect, shared_from_this(), boost::asio::placeholders::error));
+11 -6
View File
@@ -95,6 +95,11 @@
using namespace std; using namespace std;
using boost::asio::ip::tcp; using boost::asio::ip::tcp;
#ifdef BOOST_ASIO_HAS_STD_CHRONO
using namespace std::chrono;
#else
using namespace boost::chrono;
#endif
class InternalServerCallback : public SessionDataCallback, public ChatCleanerCallback, public ServerDBCallback class InternalServerCallback : public SessionDataCallback, public ChatCleanerCallback, public ServerDBCallback
{ {
@@ -860,19 +865,19 @@ ServerLobbyThread::RegisterTimers()
{ {
// Remove closed games. // Remove closed games.
m_removeGameTimer.expires_from_now( m_removeGameTimer.expires_from_now(
boost::posix_time::milliseconds(SERVER_REMOVE_GAME_INTERVAL_MSEC)); milliseconds(SERVER_REMOVE_GAME_INTERVAL_MSEC));
m_removeGameTimer.async_wait( m_removeGameTimer.async_wait(
boost::bind( boost::bind(
&ServerLobbyThread::TimerRemoveGame, shared_from_this(), boost::asio::placeholders::error)); &ServerLobbyThread::TimerRemoveGame, shared_from_this(), boost::asio::placeholders::error));
// Update the statistics file. // Update the statistics file.
m_saveStatisticsTimer.expires_from_now( m_saveStatisticsTimer.expires_from_now(
boost::posix_time::seconds(SERVER_SAVE_STATISTICS_INTERVAL_SEC)); seconds(SERVER_SAVE_STATISTICS_INTERVAL_SEC));
m_saveStatisticsTimer.async_wait( m_saveStatisticsTimer.async_wait(
boost::bind( boost::bind(
&ServerLobbyThread::TimerSaveStatisticsFile, shared_from_this(), boost::asio::placeholders::error)); &ServerLobbyThread::TimerSaveStatisticsFile, shared_from_this(), boost::asio::placeholders::error));
// Update the avatar upload locks. // Update the avatar upload locks.
m_loginLockTimer.expires_from_now( m_loginLockTimer.expires_from_now(
boost::posix_time::milliseconds(SERVER_UPDATE_LOGIN_LOCK_INTERVAL_MSEC)); milliseconds(SERVER_UPDATE_LOGIN_LOCK_INTERVAL_MSEC));
m_loginLockTimer.async_wait( m_loginLockTimer.async_wait(
boost::bind( boost::bind(
&ServerLobbyThread::TimerUpdateClientLoginLock, shared_from_this(), boost::asio::placeholders::error)); &ServerLobbyThread::TimerUpdateClientLoginLock, shared_from_this(), boost::asio::placeholders::error));
@@ -1872,7 +1877,7 @@ ServerLobbyThread::TimerRemoveGame(const boost::system::error_code &ec)
} }
// Restart timer // Restart timer
m_removeGameTimer.expires_from_now( m_removeGameTimer.expires_from_now(
boost::posix_time::milliseconds(SERVER_REMOVE_GAME_INTERVAL_MSEC)); milliseconds(SERVER_REMOVE_GAME_INTERVAL_MSEC));
m_removeGameTimer.async_wait( m_removeGameTimer.async_wait(
boost::bind( boost::bind(
&ServerLobbyThread::TimerRemoveGame, shared_from_this(), boost::asio::placeholders::error)); &ServerLobbyThread::TimerRemoveGame, shared_from_this(), boost::asio::placeholders::error));
@@ -1897,7 +1902,7 @@ ServerLobbyThread::TimerUpdateClientLoginLock(const boost::system::error_code &e
} }
// Restart timer // Restart timer
m_loginLockTimer.expires_from_now( m_loginLockTimer.expires_from_now(
boost::posix_time::milliseconds(SERVER_UPDATE_LOGIN_LOCK_INTERVAL_MSEC)); milliseconds(SERVER_UPDATE_LOGIN_LOCK_INTERVAL_MSEC));
m_loginLockTimer.async_wait( m_loginLockTimer.async_wait(
boost::bind( boost::bind(
&ServerLobbyThread::TimerUpdateClientLoginLock, shared_from_this(), boost::asio::placeholders::error)); &ServerLobbyThread::TimerUpdateClientLoginLock, shared_from_this(), boost::asio::placeholders::error));
@@ -2244,7 +2249,7 @@ ServerLobbyThread::TimerSaveStatisticsFile(const boost::system::error_code &ec)
} }
// Restart timer // Restart timer
m_saveStatisticsTimer.expires_from_now( m_saveStatisticsTimer.expires_from_now(
boost::posix_time::seconds(SERVER_SAVE_STATISTICS_INTERVAL_SEC)); seconds(SERVER_SAVE_STATISTICS_INTERVAL_SEC));
m_saveStatisticsTimer.async_wait( m_saveStatisticsTimer.async_wait(
boost::bind( boost::bind(
&ServerLobbyThread::TimerSaveStatisticsFile, shared_from_this(), boost::asio::placeholders::error)); &ServerLobbyThread::TimerSaveStatisticsFile, shared_from_this(), boost::asio::placeholders::error));
+11 -5
View File
@@ -41,6 +41,12 @@
using namespace std; using namespace std;
using boost::asio::ip::tcp; using boost::asio::ip::tcp;
#ifdef BOOST_ASIO_HAS_STD_CHRONO
using namespace std::chrono;
#else
using namespace boost::chrono;
#endif
SessionData::SessionData(boost::shared_ptr<boost::asio::ip::tcp::socket> sock, SessionId id, SessionDataCallback &cb, boost::asio::io_service &ioService) SessionData::SessionData(boost::shared_ptr<boost::asio::ip::tcp::socket> sock, SessionId id, SessionDataCallback &cb, boost::asio::io_service &ioService)
: m_socket(sock), m_id(id), m_state(SessionData::Init), m_readyFlag(false), m_wantsLobbyMsg(true), : m_socket(sock), m_id(id), m_state(SessionData::Init), m_readyFlag(false), m_wantsLobbyMsg(true),
m_activityTimeoutSec(0), m_activityWarningRemainingSec(0), m_initTimeoutTimer(ioService), m_globalTimeoutTimer(ioService), m_activityTimeoutSec(0), m_activityWarningRemainingSec(0), m_initTimeoutTimer(ioService), m_globalTimeoutTimer(ioService),
@@ -236,7 +242,7 @@ SessionData::TimerActivityWarning(const boost::system::error_code &ec)
m_callback.SessionTimeoutWarning(shared_from_this(), m_activityWarningRemainingSec); m_callback.SessionTimeoutWarning(shared_from_this(), m_activityWarningRemainingSec);
m_activityTimeoutTimer.expires_from_now( m_activityTimeoutTimer.expires_from_now(
boost::posix_time::seconds(m_activityWarningRemainingSec)); seconds(m_activityWarningRemainingSec));
m_activityTimeoutTimer.async_wait( m_activityTimeoutTimer.async_wait(
boost::bind( boost::bind(
&SessionData::TimerSessionTimeout, shared_from_this(), boost::asio::placeholders::error)); &SessionData::TimerSessionTimeout, shared_from_this(), boost::asio::placeholders::error));
@@ -327,7 +333,7 @@ SessionData::ResetActivityTimer()
{ {
boost::mutex::scoped_lock lock(m_dataMutex); boost::mutex::scoped_lock lock(m_dataMutex);
m_activityTimeoutTimer.expires_from_now( m_activityTimeoutTimer.expires_from_now(
boost::posix_time::seconds(m_activityTimeoutSec - m_activityWarningRemainingSec)); seconds(m_activityTimeoutSec - m_activityWarningRemainingSec));
m_activityTimeoutTimer.async_wait( m_activityTimeoutTimer.async_wait(
boost::bind( boost::bind(
&SessionData::TimerActivityWarning, shared_from_this(), boost::asio::placeholders::error)); &SessionData::TimerActivityWarning, shared_from_this(), boost::asio::placeholders::error));
@@ -338,7 +344,7 @@ SessionData::StartTimerInitTimeout(unsigned timeoutSec)
{ {
boost::mutex::scoped_lock lock(m_dataMutex); boost::mutex::scoped_lock lock(m_dataMutex);
m_initTimeoutTimer.expires_from_now( m_initTimeoutTimer.expires_from_now(
boost::posix_time::seconds(timeoutSec)); seconds(timeoutSec));
m_initTimeoutTimer.async_wait( m_initTimeoutTimer.async_wait(
boost::bind( boost::bind(
&SessionData::TimerInitTimeout, shared_from_this(), boost::asio::placeholders::error)); &SessionData::TimerInitTimeout, shared_from_this(), boost::asio::placeholders::error));
@@ -349,7 +355,7 @@ SessionData::StartTimerGlobalTimeout(unsigned timeoutSec)
{ {
boost::mutex::scoped_lock lock(m_dataMutex); boost::mutex::scoped_lock lock(m_dataMutex);
m_globalTimeoutTimer.expires_from_now( m_globalTimeoutTimer.expires_from_now(
boost::posix_time::seconds(timeoutSec)); seconds(timeoutSec));
m_globalTimeoutTimer.async_wait( m_globalTimeoutTimer.async_wait(
boost::bind( boost::bind(
&SessionData::TimerSessionTimeout, shared_from_this(), boost::asio::placeholders::error)); &SessionData::TimerSessionTimeout, shared_from_this(), boost::asio::placeholders::error));
@@ -363,7 +369,7 @@ SessionData::StartTimerActivityTimeout(unsigned timeoutSec, unsigned warningRema
m_activityWarningRemainingSec = warningRemainingSec; m_activityWarningRemainingSec = warningRemainingSec;
m_activityTimeoutTimer.expires_from_now( m_activityTimeoutTimer.expires_from_now(
boost::posix_time::seconds(timeoutSec - warningRemainingSec)); seconds(timeoutSec - warningRemainingSec));
m_activityTimeoutTimer.async_wait( m_activityTimeoutTimer.async_wait(
boost::bind( boost::bind(
&SessionData::TimerActivityWarning, shared_from_this(), boost::asio::placeholders::error)); &SessionData::TimerActivityWarning, shared_from_this(), boost::asio::placeholders::error));
+4 -3
View File
@@ -34,6 +34,7 @@
#define _SERVERADMINBOT_H_ #define _SERVERADMINBOT_H_
#include <boost/asio.hpp> #include <boost/asio.hpp>
#include <boost/asio/steady_timer.hpp>
#include <boost/thread.hpp> #include <boost/thread.hpp>
#include <boost/enable_shared_from_this.hpp> #include <boost/enable_shared_from_this.hpp>
#include <third_party/boost/timers.hpp> #include <third_party/boost/timers.hpp>
@@ -96,9 +97,9 @@ private:
boost::shared_ptr<IrcThread> m_ircAdminThread; boost::shared_ptr<IrcThread> m_ircAdminThread;
boost::timers::portable::second_timer m_notifyTimer; boost::timers::portable::second_timer m_notifyTimer;
boost::asio::deadline_timer m_reconnectTimer; boost::asio::steady_timer m_reconnectTimer;
boost::asio::deadline_timer m_notifyLoopTimer; boost::asio::steady_timer m_notifyLoopTimer;
boost::asio::deadline_timer m_checkFileTimer; boost::asio::steady_timer m_checkFileTimer;
}; };
#endif #endif
+5 -4
View File
@@ -35,6 +35,7 @@
#include <db/dbdefs.h> #include <db/dbdefs.h>
#include <boost/asio.hpp> #include <boost/asio.hpp>
#include <boost/asio/steady_timer.hpp>
#include <boost/regex.hpp> #include <boost/regex.hpp>
#include <boost/thread.hpp> #include <boost/thread.hpp>
#include <boost/enable_shared_from_this.hpp> #include <boost/enable_shared_from_this.hpp>
@@ -67,12 +68,12 @@ public:
protected: protected:
struct TimedPlayerBan { struct TimedPlayerBan {
boost::shared_ptr<boost::asio::deadline_timer> timer; boost::shared_ptr<boost::asio::steady_timer> timer;
std::string nameStr; std::string nameStr;
boost::regex nameRegex; boost::regex nameRegex;
}; };
struct TimedIPBan { struct TimedIPBan {
boost::shared_ptr<boost::asio::deadline_timer> timer; boost::shared_ptr<boost::asio::steady_timer> timer;
std::string ipAddress; std::string ipAddress;
}; };
@@ -81,8 +82,8 @@ protected:
typedef std::list<boost::regex> RegexList; typedef std::list<boost::regex> RegexList;
typedef std::vector<DB_id> DBPlayerIdList; typedef std::vector<DB_id> DBPlayerIdList;
boost::shared_ptr<boost::asio::deadline_timer> InternalRegisterTimedBan(unsigned timerId, unsigned durationHours); boost::shared_ptr<boost::asio::steady_timer> InternalRegisterTimedBan(unsigned timerId, unsigned durationHours);
void TimerRemoveBan(const boost::system::error_code &ec, unsigned banId, boost::shared_ptr<boost::asio::deadline_timer> timer); void TimerRemoveBan(const boost::system::error_code &ec, unsigned banId, boost::shared_ptr<boost::asio::steady_timer> timer);
boost::shared_ptr<boost::asio::io_service> m_ioService; boost::shared_ptr<boost::asio::io_service> m_ioService;
+6 -5
View File
@@ -34,6 +34,7 @@
#define _SERVERGAME_H_ #define _SERVERGAME_H_
#include <boost/enable_shared_from_this.hpp> #include <boost/enable_shared_from_this.hpp>
#include <boost/asio/steady_timer.hpp>
#include <third_party/boost/timers.hpp> #include <third_party/boost/timers.hpp>
#include <map> #include <map>
@@ -180,8 +181,8 @@ protected:
ServerGameState &GetState(); ServerGameState &GetState();
void SetState(ServerGameState &newState); void SetState(ServerGameState &newState);
boost::asio::deadline_timer &GetStateTimer1(); boost::asio::steady_timer &GetStateTimer1();
boost::asio::deadline_timer &GetStateTimer2(); boost::asio::steady_timer &GetStateTimer2();
const StartData &GetStartData() const; const StartData &GetStartData() const;
void SetStartData(const StartData &startData); void SetStartData(const StartData &startData);
@@ -242,9 +243,9 @@ private:
ConfigFile &m_playerConfig; ConfigFile &m_playerConfig;
unsigned m_gameNum; unsigned m_gameNum;
unsigned m_curPetitionId; unsigned m_curPetitionId;
boost::asio::deadline_timer m_voteKickTimer; boost::asio::steady_timer m_voteKickTimer;
boost::asio::deadline_timer m_stateTimer1; boost::asio::steady_timer m_stateTimer1;
boost::asio::deadline_timer m_stateTimer2; boost::asio::steady_timer m_stateTimer2;
bool m_isNameReported; bool m_isNameReported;
friend class ServerLobbyThread; friend class ServerLobbyThread;
+2 -1
View File
@@ -34,6 +34,7 @@
#define _SERVERLOBBYBOT_H_ #define _SERVERLOBBYBOT_H_
#include <boost/asio.hpp> #include <boost/asio.hpp>
#include <boost/asio/steady_timer.hpp>
#include <boost/enable_shared_from_this.hpp> #include <boost/enable_shared_from_this.hpp>
#include <string> #include <string>
#include <list> #include <list>
@@ -86,7 +87,7 @@ private:
boost::shared_ptr<ServerLobbyThread> m_lobbyThread; boost::shared_ptr<ServerLobbyThread> m_lobbyThread;
boost::shared_ptr<IrcThread> m_ircLobbyThread; boost::shared_ptr<IrcThread> m_ircLobbyThread;
boost::asio::deadline_timer m_reconnectTimer; boost::asio::steady_timer m_reconnectTimer;
}; };
#endif #endif
+4 -3
View File
@@ -34,6 +34,7 @@
#define _SERVERLOBBYTHREAD_H_ #define _SERVERLOBBYTHREAD_H_
#include <boost/asio.hpp> #include <boost/asio.hpp>
#include <boost/asio/steady_timer.hpp>
#include <boost/enable_shared_from_this.hpp> #include <boost/enable_shared_from_this.hpp>
#include <boost/uuid/uuid_generators.hpp> #include <boost/uuid/uuid_generators.hpp>
@@ -268,9 +269,9 @@ private:
boost::shared_ptr<ChatCleanerManager> m_chatCleanerManager; boost::shared_ptr<ChatCleanerManager> m_chatCleanerManager;
boost::shared_ptr<ServerDBInterface> m_database; boost::shared_ptr<ServerDBInterface> m_database;
boost::asio::deadline_timer m_removeGameTimer; boost::asio::steady_timer m_removeGameTimer;
boost::asio::deadline_timer m_saveStatisticsTimer; boost::asio::steady_timer m_saveStatisticsTimer;
boost::asio::deadline_timer m_loginLockTimer; boost::asio::steady_timer m_loginLockTimer;
boost::uuids::random_generator m_sessionIdGenerator; boost::uuids::random_generator m_sessionIdGenerator;
+4 -3
View File
@@ -36,6 +36,7 @@
typedef unsigned SessionId; typedef unsigned SessionId;
#include <boost/asio.hpp> #include <boost/asio.hpp>
#include <boost/asio/steady_timer.hpp>
#include <boost/thread.hpp> #include <boost/thread.hpp>
#include <boost/enable_shared_from_this.hpp> #include <boost/enable_shared_from_this.hpp>
#include <string> #include <string>
@@ -144,9 +145,9 @@ private:
bool m_wantsLobbyMsg; bool m_wantsLobbyMsg;
unsigned m_activityTimeoutSec; unsigned m_activityTimeoutSec;
unsigned m_activityWarningRemainingSec; unsigned m_activityWarningRemainingSec;
boost::asio::deadline_timer m_initTimeoutTimer; boost::asio::steady_timer m_initTimeoutTimer;
boost::asio::deadline_timer m_globalTimeoutTimer; boost::asio::steady_timer m_globalTimeoutTimer;
boost::asio::deadline_timer m_activityTimeoutTimer; boost::asio::steady_timer m_activityTimeoutTimer;
SessionDataCallback &m_callback; SessionDataCallback &m_callback;
Gsasl_session *m_authSession; Gsasl_session *m_authSession;
int m_curAuthStep; int m_curAuthStep;