Fixing server announcement. Gui callback still needed.
This commit is contained in:
+10
-4
@@ -38,10 +38,16 @@
|
|||||||
#define POKERTH_GT_STYLE_FILE_VERSION 1
|
#define POKERTH_GT_STYLE_FILE_VERSION 1
|
||||||
#define POKERTH_CD_STYLE_FILE_VERSION 1
|
#define POKERTH_CD_STYLE_FILE_VERSION 1
|
||||||
|
|
||||||
enum ServerNetworkMode {
|
enum ServerMode {
|
||||||
NETWORK_MODE_TCP = 1,
|
SERVER_MODE_LAN,
|
||||||
NETWORK_MODE_SCTP = 2,
|
SERVER_MODE_INTERNET_NOAUTH,
|
||||||
NETWORK_MODE_TCP_SCTP = 3};
|
SERVER_MODE_INTERNET_AUTH
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ServerTransportProtocol {
|
||||||
|
TRANSPORT_PROTOCOL_TCP = 1,
|
||||||
|
TRANSPORT_PROTOCOL_SCTP = 2,
|
||||||
|
TRANSPORT_PROTOCOL_TCP_SCTP = 3};
|
||||||
|
|
||||||
enum GameState {
|
enum GameState {
|
||||||
GAME_STATE_PREFLOP = 0,
|
GAME_STATE_PREFLOP = 0,
|
||||||
|
|||||||
@@ -400,7 +400,7 @@ void startWindowImpl::callCreateNetworkGameDialog() {
|
|||||||
// Clear network game dialog.
|
// Clear network game dialog.
|
||||||
myStartNetworkGameDialog->clearDialog();
|
myStartNetworkGameDialog->clearDialog();
|
||||||
|
|
||||||
myServerGuiInterface->getSession()->startNetworkServer();
|
myServerGuiInterface->getSession()->startNetworkServer(false);
|
||||||
mySession->startNetworkClientForLocalServer(gameData);
|
mySession->startNetworkClientForLocalServer(gameData);
|
||||||
|
|
||||||
myStartNetworkGameDialog->setMaxPlayerNumber(gameData.maxNumberOfPlayers);
|
myStartNetworkGameDialog->setMaxPlayerNumber(gameData.maxNumberOfPlayers);
|
||||||
|
|||||||
@@ -138,10 +138,10 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
ServerLobbyThread::ServerLobbyThread(GuiInterface &gui, ServerIrcBotCallback &ircBotCb, ConfigFile *playerConfig, AvatarManager &avatarManager,
|
ServerLobbyThread::ServerLobbyThread(GuiInterface &gui, ServerMode mode, ServerIrcBotCallback &ircBotCb, ConfigFile *playerConfig,
|
||||||
boost::shared_ptr<boost::asio::io_service> ioService)
|
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_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_statDataChanged(false), m_removeGameTimer(*ioService), m_removePlayerTimer(*ioService),
|
||||||
m_sessionTimeoutTimer(*ioService), m_avatarCleanupTimer(*ioService),
|
m_sessionTimeoutTimer(*ioService), m_avatarCleanupTimer(*ioService),
|
||||||
m_saveStatisticsTimer(*ioService), m_avatarLockTimer(*ioService),
|
m_saveStatisticsTimer(*ioService), m_avatarLockTimer(*ioService),
|
||||||
@@ -161,9 +161,8 @@ ServerLobbyThread::~ServerLobbyThread()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ServerLobbyThread::Init(const string &pwd, const string &logDir)
|
ServerLobbyThread::Init(const string &logDir)
|
||||||
{
|
{
|
||||||
m_password = pwd;
|
|
||||||
// Read previous server statistics.
|
// Read previous server statistics.
|
||||||
if (!logDir.empty())
|
if (!logDir.empty())
|
||||||
{
|
{
|
||||||
@@ -225,8 +224,18 @@ ServerLobbyThread::AddConnection(boost::shared_ptr<tcp::socket> sock)
|
|||||||
netAnnounce->latestGameVersion.major = POKERTH_VERSION_MAJOR;
|
netAnnounce->latestGameVersion.major = POKERTH_VERSION_MAJOR;
|
||||||
netAnnounce->latestGameVersion.minor = POKERTH_VERSION_MINOR;
|
netAnnounce->latestGameVersion.minor = POKERTH_VERSION_MINOR;
|
||||||
netAnnounce->latestBetaRevision = POKERTH_BETA_REVISION;
|
netAnnounce->latestBetaRevision = POKERTH_BETA_REVISION;
|
||||||
// TODO
|
switch (m_mode)
|
||||||
netAnnounce->serverType = serverType_serverTypeLAN;
|
{
|
||||||
|
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);
|
GetSender().Send(sessionData, packet);
|
||||||
|
|
||||||
sock->async_read_some(
|
sock->async_read_some(
|
||||||
@@ -1894,12 +1903,6 @@ ServerLobbyThread::GetReceiver()
|
|||||||
return *m_receiver;
|
return *m_receiver;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
ServerLobbyThread::CheckPassword(const string &password) const
|
|
||||||
{
|
|
||||||
return (password == m_password);
|
|
||||||
}
|
|
||||||
|
|
||||||
InternalServerCallback &
|
InternalServerCallback &
|
||||||
ServerLobbyThread::GetSenderCallback()
|
ServerLobbyThread::GetSenderCallback()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -44,21 +44,22 @@ ServerManager::~ServerManager()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
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));
|
m_lobbyThread.reset(new ServerLobbyThread(GetGui(), mode, *m_lobbyBot, m_playerConfig, m_avatarManager, m_ioService));
|
||||||
GetLobbyThread().Init(pwd, logDir);
|
GetLobbyThread().Init(logDir);
|
||||||
|
|
||||||
m_adminBot->Init(m_lobbyThread, ircAdminThread);
|
m_adminBot->Init(m_lobbyThread, ircAdminThread);
|
||||||
m_lobbyBot->Init(m_lobbyThread, ircLobbyThread);
|
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));
|
boost::shared_ptr<ServerAcceptHelper> tcpAcceptHelper(new ServerAcceptHelper(GetGui(), m_ioService));
|
||||||
tcpAcceptHelper->Listen(serverPort, ipv6, false, logDir, m_lobbyThread);
|
tcpAcceptHelper->Listen(serverPort, ipv6, false, logDir, m_lobbyThread);
|
||||||
m_acceptHelperPool.push_back(tcpAcceptHelper);
|
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));
|
boost::shared_ptr<ServerAcceptHelper> sctpAcceptHelper(new ServerAcceptHelper(GetGui(), m_ioService));
|
||||||
sctpAcceptHelper->Listen(serverPort, ipv6, true, logDir, m_lobbyThread);
|
sctpAcceptHelper->Listen(serverPort, ipv6, true, logDir, m_lobbyThread);
|
||||||
|
|||||||
@@ -53,11 +53,11 @@ struct Gsasl;
|
|||||||
class ServerLobbyThread : public Thread, public boost::enable_shared_from_this<ServerLobbyThread>
|
class ServerLobbyThread : public Thread, public boost::enable_shared_from_this<ServerLobbyThread>
|
||||||
{
|
{
|
||||||
public:
|
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);
|
boost::shared_ptr<boost::asio::io_service> ioService);
|
||||||
virtual ~ServerLobbyThread();
|
virtual ~ServerLobbyThread();
|
||||||
|
|
||||||
void Init(const std::string &pwd, const std::string &logDir);
|
void Init(const std::string &logDir);
|
||||||
virtual void SignalTermination();
|
virtual void SignalTermination();
|
||||||
|
|
||||||
void AddConnection(boost::shared_ptr<boost::asio::ip::tcp::socket> sock);
|
void AddConnection(boost::shared_ptr<boost::asio::ip::tcp::socket> sock);
|
||||||
@@ -176,8 +176,6 @@ protected:
|
|||||||
|
|
||||||
ReceiverHelper &GetReceiver();
|
ReceiverHelper &GetReceiver();
|
||||||
|
|
||||||
bool CheckPassword(const std::string &password) const;
|
|
||||||
|
|
||||||
InternalServerCallback &GetSenderCallback();
|
InternalServerCallback &GetSenderCallback();
|
||||||
GuiInterface &GetGui();
|
GuiInterface &GetGui();
|
||||||
ServerIrcBotCallback &GetIrcBotCallback();
|
ServerIrcBotCallback &GetIrcBotCallback();
|
||||||
@@ -220,7 +218,7 @@ private:
|
|||||||
ServerIrcBotCallback &m_ircBotCb;
|
ServerIrcBotCallback &m_ircBotCb;
|
||||||
AvatarManager &m_avatarManager;
|
AvatarManager &m_avatarManager;
|
||||||
|
|
||||||
std::string m_password;
|
ServerMode m_mode;
|
||||||
std::string m_statisticsFileName;
|
std::string m_statisticsFileName;
|
||||||
ConfigFile *m_playerConfig;
|
ConfigFile *m_playerConfig;
|
||||||
u_int32_t m_curGameId;
|
u_int32_t m_curGameId;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public:
|
|||||||
virtual ~ServerManager();
|
virtual ~ServerManager();
|
||||||
|
|
||||||
// Set the parameters.
|
// 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.
|
// Main start function.
|
||||||
void RunAll();
|
void RunAll();
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ main(int argc, char *argv[])
|
|||||||
LOG_ERROR("Missing files - please check your directory settings!");
|
LOG_ERROR("Missing files - please check your directory settings!");
|
||||||
myServerGuiInterface->setSession(session);
|
myServerGuiInterface->setSession(session);
|
||||||
|
|
||||||
myServerGuiInterface->getSession()->startNetworkServer();
|
myServerGuiInterface->getSession()->startNetworkServer(true);
|
||||||
while (!g_pokerthTerminate)
|
while (!g_pokerthTerminate)
|
||||||
{
|
{
|
||||||
Thread::Msleep(100);
|
Thread::Msleep(100);
|
||||||
|
|||||||
+15
-3
@@ -266,7 +266,7 @@ void Session::clientJoinGame(unsigned gameId, const std::string &password)
|
|||||||
myNetClient->SendJoinGame(gameId, password);
|
myNetClient->SendJoinGame(gameId, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::startNetworkServer()
|
void Session::startNetworkServer(bool dedicated)
|
||||||
{
|
{
|
||||||
if (myNetServer)
|
if (myNetServer)
|
||||||
{
|
{
|
||||||
@@ -304,11 +304,23 @@ void Session::startNetworkServer()
|
|||||||
myConfig->readConfigString("LobbyIRCChannelPassword"));
|
myConfig->readConfigString("LobbyIRCChannelPassword"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ServerMode mode;
|
||||||
|
if (dedicated)
|
||||||
|
{
|
||||||
|
#ifdef POKERTH_OFFICIAL_SERVER
|
||||||
|
mode = SERVER_MODE_INTERNET_AUTH;
|
||||||
|
#else
|
||||||
|
mode = SERVER_MODE_INTERNET_NOAUTH;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mode = SERVER_MODE_LAN;
|
||||||
|
|
||||||
myNetServer->Init(
|
myNetServer->Init(
|
||||||
myConfig->readConfigInt("ServerPort"),
|
myConfig->readConfigInt("ServerPort"),
|
||||||
myConfig->readConfigInt("ServerUseIpv6") == 1,
|
myConfig->readConfigInt("ServerUseIpv6") == 1,
|
||||||
myConfig->readConfigInt("ServerUseSctp") == 1 ? NETWORK_MODE_TCP_SCTP : NETWORK_MODE_TCP,
|
myConfig->readConfigInt("ServerUseSctp") == 1 ? TRANSPORT_PROTOCOL_TCP_SCTP : TRANSPORT_PROTOCOL_TCP,
|
||||||
myConfig->readConfigString("ServerPassword"),
|
mode,
|
||||||
myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("LogDir")),
|
myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("LogDir")),
|
||||||
tmpIrcAdminThread,
|
tmpIrcAdminThread,
|
||||||
tmpIrcLobbyThread
|
tmpIrcLobbyThread
|
||||||
|
|||||||
+1
-1
@@ -69,7 +69,7 @@ public:
|
|||||||
void clientCreateGame(const GameData &gameData, const std::string &name, const std::string &password);
|
void clientCreateGame(const GameData &gameData, const std::string &name, const std::string &password);
|
||||||
void clientJoinGame(unsigned gameId, const std::string &password);
|
void clientJoinGame(unsigned gameId, const std::string &password);
|
||||||
|
|
||||||
void startNetworkServer();
|
void startNetworkServer(bool dedicated);
|
||||||
void sendLeaveCurrentGame();
|
void sendLeaveCurrentGame();
|
||||||
void sendStartEvent(bool fillUpWithCpuPlayers);
|
void sendStartEvent(bool fillUpWithCpuPlayers);
|
||||||
void terminateNetworkServer();
|
void terminateNetworkServer();
|
||||||
|
|||||||
Reference in New Issue
Block a user