2007-11-16 22:34:38 +00:00
|
|
|
/***************************************************************************
|
|
|
|
|
* Copyright (C) 2007 by Lothar May *
|
|
|
|
|
* *
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
|
* (at your option) any later version. *
|
|
|
|
|
* *
|
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
|
* *
|
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
/* Manager thread for the server. */
|
|
|
|
|
|
|
|
|
|
#ifndef _SERVERMANAGER_H_
|
|
|
|
|
#define _SERVERMANAGER_H_
|
|
|
|
|
|
2009-05-04 21:11:29 +00:00
|
|
|
#include <boost/asio.hpp>
|
2009-08-20 15:19:41 +00:00
|
|
|
#include <net/serveradminbot.h>
|
|
|
|
|
#include <net/serverlobbybot.h>
|
2007-11-16 22:34:38 +00:00
|
|
|
#include <string>
|
|
|
|
|
#include <list>
|
|
|
|
|
|
2009-05-07 22:36:51 +00:00
|
|
|
#include <game_defs.h>
|
|
|
|
|
#include <gui/guiinterface.h>
|
|
|
|
|
|
2007-11-16 22:34:38 +00:00
|
|
|
class ServerLobbyThread;
|
2009-08-20 11:02:05 +00:00
|
|
|
class IrcThread;
|
2009-05-10 22:21:20 +00:00
|
|
|
class ServerAcceptHelper;
|
2007-11-16 22:34:38 +00:00
|
|
|
class SenderThread;
|
|
|
|
|
class ConfigFile;
|
|
|
|
|
class AvatarManager;
|
|
|
|
|
|
2009-08-20 11:02:05 +00:00
|
|
|
class ServerManager
|
2007-11-16 22:34:38 +00:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
ServerManager(GuiInterface &gui, ConfigFile *config, AvatarManager &avatarManager);
|
|
|
|
|
virtual ~ServerManager();
|
|
|
|
|
|
|
|
|
|
// Set the parameters.
|
2009-11-08 09:48:01 +00:00
|
|
|
void Init(unsigned serverPort, bool ipv6, ServerTransportProtocol proto, ServerMode mode, const std::string &logDir, boost::shared_ptr<IrcThread> ircAdminThread, boost::shared_ptr<IrcThread> ircLobbyThread);
|
2007-11-16 22:34:38 +00:00
|
|
|
|
|
|
|
|
// Main start function.
|
|
|
|
|
void RunAll();
|
|
|
|
|
|
2008-11-02 21:25:42 +00:00
|
|
|
// Let the server manager perform processing.
|
|
|
|
|
void Process();
|
|
|
|
|
|
2007-11-16 22:34:38 +00:00
|
|
|
void SignalTerminationAll();
|
|
|
|
|
bool JoinAll(bool wait);
|
|
|
|
|
|
|
|
|
|
GuiInterface &GetGui();
|
2009-08-20 15:19:41 +00:00
|
|
|
ServerAdminBot &GetAdminBot();
|
|
|
|
|
ServerLobbyBot &GetLobbyBot();
|
2009-08-15 21:07:14 +00:00
|
|
|
|
2007-11-16 22:34:38 +00:00
|
|
|
protected:
|
2009-05-10 22:21:20 +00:00
|
|
|
typedef std::list<boost::shared_ptr<ServerAcceptHelper> > AcceptHelperList;
|
2007-11-16 22:34:38 +00:00
|
|
|
|
|
|
|
|
ServerLobbyThread &GetLobbyThread();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
GuiInterface &m_gui;
|
|
|
|
|
ConfigFile *m_playerConfig;
|
|
|
|
|
AvatarManager &m_avatarManager;
|
|
|
|
|
|
2009-05-04 21:11:29 +00:00
|
|
|
boost::shared_ptr<boost::asio::io_service> m_ioService;
|
2007-11-16 22:34:38 +00:00
|
|
|
boost::shared_ptr<ServerLobbyThread> m_lobbyThread;
|
2009-08-20 15:19:41 +00:00
|
|
|
boost::shared_ptr<ServerAdminBot> m_adminBot;
|
|
|
|
|
boost::shared_ptr<ServerLobbyBot> m_lobbyBot;
|
2009-05-10 22:21:20 +00:00
|
|
|
AcceptHelperList m_acceptHelperPool;
|
2007-11-16 22:34:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|