Fixing server announcement. Gui callback still needed.

This commit is contained in:
lotodore
2009-11-08 09:48:01 +00:00
parent f1c213b707
commit 5424aed21e
9 changed files with 54 additions and 34 deletions
+16 -13
View File
@@ -138,10 +138,10 @@ private:
};
ServerLobbyThread::ServerLobbyThread(GuiInterface &gui, ServerIrcBotCallback &ircBotCb, ConfigFile *playerConfig, AvatarManager &avatarManager,
boost::shared_ptr<boost::asio::io_service> ioService)
ServerLobbyThread::ServerLobbyThread(GuiInterface &gui, ServerMode mode, ServerIrcBotCallback &ircBotCb, ConfigFile *playerConfig,
AvatarManager &avatarManager, boost::shared_ptr<boost::asio::io_service> ioService)
: m_ioService(ioService), m_authContext(NULL), m_gui(gui), m_ircBotCb(ircBotCb), m_avatarManager(avatarManager),
m_playerConfig(playerConfig), m_curGameId(0), m_curUniquePlayerId(0), m_curSessionId(INVALID_SESSION + 1),
m_mode(mode), m_playerConfig(playerConfig), m_curGameId(0), m_curUniquePlayerId(0), m_curSessionId(INVALID_SESSION + 1),
m_statDataChanged(false), m_removeGameTimer(*ioService), m_removePlayerTimer(*ioService),
m_sessionTimeoutTimer(*ioService), m_avatarCleanupTimer(*ioService),
m_saveStatisticsTimer(*ioService), m_avatarLockTimer(*ioService),
@@ -161,9 +161,8 @@ ServerLobbyThread::~ServerLobbyThread()
}
void
ServerLobbyThread::Init(const string &pwd, const string &logDir)
ServerLobbyThread::Init(const string &logDir)
{
m_password = pwd;
// Read previous server statistics.
if (!logDir.empty())
{
@@ -225,8 +224,18 @@ ServerLobbyThread::AddConnection(boost::shared_ptr<tcp::socket> sock)
netAnnounce->latestGameVersion.major = POKERTH_VERSION_MAJOR;
netAnnounce->latestGameVersion.minor = POKERTH_VERSION_MINOR;
netAnnounce->latestBetaRevision = POKERTH_BETA_REVISION;
// TODO
netAnnounce->serverType = serverType_serverTypeLAN;
switch (m_mode)
{
case SERVER_MODE_LAN:
netAnnounce->serverType = serverType_serverTypeLAN;
break;
case SERVER_MODE_INTERNET_NOAUTH:
netAnnounce->serverType = serverType_serverTypeInternetNoAuth;
break;
case SERVER_MODE_INTERNET_AUTH:
netAnnounce->serverType = serverType_serverTypeInternetAuth;
break;
}
GetSender().Send(sessionData, packet);
sock->async_read_some(
@@ -1894,12 +1903,6 @@ ServerLobbyThread::GetReceiver()
return *m_receiver;
}
bool
ServerLobbyThread::CheckPassword(const string &password) const
{
return (password == m_password);
}
InternalServerCallback &
ServerLobbyThread::GetSenderCallback()
{
+6 -5
View File
@@ -44,21 +44,22 @@ ServerManager::~ServerManager()
}
void
ServerManager::Init(unsigned serverPort, bool ipv6, ServerNetworkMode mode, const string &pwd, const string &logDir, boost::shared_ptr<IrcThread> ircAdminThread, boost::shared_ptr<IrcThread> ircLobbyThread)
ServerManager::Init(unsigned serverPort, bool ipv6, ServerTransportProtocol proto, ServerMode mode, const string &logDir, boost::shared_ptr<IrcThread> ircAdminThread, boost::shared_ptr<IrcThread> ircLobbyThread)
{
m_lobbyThread.reset(new ServerLobbyThread(GetGui(), *m_lobbyBot, m_playerConfig, m_avatarManager, m_ioService));
GetLobbyThread().Init(pwd, logDir);
m_lobbyThread.reset(new ServerLobbyThread(GetGui(), mode, *m_lobbyBot, m_playerConfig, m_avatarManager, m_ioService));
GetLobbyThread().Init(logDir);
m_adminBot->Init(m_lobbyThread, ircAdminThread);
m_lobbyBot->Init(m_lobbyThread, ircLobbyThread);
if (mode & NETWORK_MODE_TCP)
if (proto & TRANSPORT_PROTOCOL_TCP)
{
boost::shared_ptr<ServerAcceptHelper> tcpAcceptHelper(new ServerAcceptHelper(GetGui(), m_ioService));
tcpAcceptHelper->Listen(serverPort, ipv6, false, logDir, m_lobbyThread);
m_acceptHelperPool.push_back(tcpAcceptHelper);
}
/* if (mode & NETWORK_MODE_SCTP)
// TODO: Re-add SCTP support once asio supports SCTP.
/* if (mode & TRANSPORT_PROTOCOL_SCTP)
{
boost::shared_ptr<ServerAcceptHelper> sctpAcceptHelper(new ServerAcceptHelper(GetGui(), m_ioService));
sctpAcceptHelper->Listen(serverPort, ipv6, true, logDir, m_lobbyThread);
+3 -5
View File
@@ -53,11 +53,11 @@ struct Gsasl;
class ServerLobbyThread : public Thread, public boost::enable_shared_from_this<ServerLobbyThread>
{
public:
ServerLobbyThread(GuiInterface &gui, ServerIrcBotCallback &ircBotCb, ConfigFile *playerConfig, AvatarManager &avatarManager,
ServerLobbyThread(GuiInterface &gui, ServerMode mode, ServerIrcBotCallback &ircBotCb, ConfigFile *playerConfig, AvatarManager &avatarManager,
boost::shared_ptr<boost::asio::io_service> ioService);
virtual ~ServerLobbyThread();
void Init(const std::string &pwd, const std::string &logDir);
void Init(const std::string &logDir);
virtual void SignalTermination();
void AddConnection(boost::shared_ptr<boost::asio::ip::tcp::socket> sock);
@@ -176,8 +176,6 @@ protected:
ReceiverHelper &GetReceiver();
bool CheckPassword(const std::string &password) const;
InternalServerCallback &GetSenderCallback();
GuiInterface &GetGui();
ServerIrcBotCallback &GetIrcBotCallback();
@@ -220,7 +218,7 @@ private:
ServerIrcBotCallback &m_ircBotCb;
AvatarManager &m_avatarManager;
std::string m_password;
ServerMode m_mode;
std::string m_statisticsFileName;
ConfigFile *m_playerConfig;
u_int32_t m_curGameId;
+1 -1
View File
@@ -44,7 +44,7 @@ public:
virtual ~ServerManager();
// Set the parameters.
void Init(unsigned serverPort, bool ipv6, ServerNetworkMode mode, const std::string &pwd, const std::string &logDir, boost::shared_ptr<IrcThread> ircAdminThread, boost::shared_ptr<IrcThread> ircLobbyThread);
void Init(unsigned serverPort, bool ipv6, ServerTransportProtocol proto, ServerMode mode, const std::string &logDir, boost::shared_ptr<IrcThread> ircAdminThread, boost::shared_ptr<IrcThread> ircLobbyThread);
// Main start function.
void RunAll();