Force reconnect of the irc bot by creating a file in the cache folder.

This commit is contained in:
lotodore
2012-03-03 14:16:45 +00:00
parent 93236dcc8d
commit 06145f30e9
11 changed files with 142 additions and 87 deletions
+15 -6
View File
@@ -22,6 +22,7 @@
#include <boost/asio.hpp>
#include <boost/thread.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <third_party/boost/timers.hpp>
#include <string>
#include <list>
@@ -36,19 +37,23 @@ class ConfigFile;
class AvatarManager;
class IrcThread;
class ServerAdminBot : public IrcCallback
class ServerAdminBot : public IrcCallback, public boost::enable_shared_from_this<ServerAdminBot>
{
public:
ServerAdminBot();
ServerAdminBot(boost::shared_ptr<boost::asio::io_service> ioService);
virtual ~ServerAdminBot();
void Init(boost::shared_ptr<ServerLobbyThread> lobbyThread, boost::shared_ptr<IrcThread> ircAdminThread);
void Init(boost::shared_ptr<ServerLobbyThread> lobbyThread, boost::shared_ptr<IrcThread> ircAdminThread, const std::string &cacheDir);
// Main start function.
void Run();
// Perform processing.
void Process();
// Reconnect the bot.
void ReconnectHandler(const boost::system::error_code& ec);
void Reconnect();
void CheckFileHandler(const boost::system::error_code& ec);
void NotifyLoop(const boost::system::error_code& ec);
void SignalTermination();
bool Join(bool wait);
@@ -68,6 +73,7 @@ protected:
private:
std::string m_ircNick;
std::string m_cacheDir;
mutable boost::mutex m_notifyMutex;
int m_notifyTimeoutMinutes;
int m_notifyIntervalMinutes;
@@ -75,8 +81,11 @@ private:
boost::shared_ptr<ServerLobbyThread> m_lobbyThread;
boost::shared_ptr<IrcThread> m_ircAdminThread;
boost::timers::portable::second_timer m_ircRestartTimer;
boost::timers::portable::second_timer m_notifyTimer;
boost::asio::deadline_timer m_reconnectTimer;
boost::asio::deadline_timer m_notifyLoopTimer;
boost::asio::deadline_timer m_checkFileTimer;
};
#endif