More steps towards supporting multiple games per server. Player rights still broken, so starting the game is not possible. Games are not yet terminated after all players have left.
This commit is contained in:
@@ -111,6 +111,8 @@ void ServerGuiWrapper::SignalNetClientError(int errorID, int osErrorID) { if (my
|
||||
void ServerGuiWrapper::SignalNetClientSelfJoined(const string &playerName, PlayerRights rights) { if (myClientcb) myClientcb->SignalNetClientSelfJoined(playerName, rights); }
|
||||
void ServerGuiWrapper::SignalNetClientPlayerJoined(const string &playerName, PlayerRights rights) { if (myClientcb) myClientcb->SignalNetClientPlayerJoined(playerName, rights); }
|
||||
void ServerGuiWrapper::SignalNetClientPlayerLeft(const string &playerName) { if (myClientcb) myClientcb->SignalNetClientPlayerLeft(playerName); }
|
||||
void ServerGuiWrapper::SignalNetClientGameListNew(const string &gameName) { if (myClientcb) myClientcb->SignalNetClientGameListNew(gameName); }
|
||||
void ServerGuiWrapper::SignalNetClientGameListRemove(const string &gameName) { if (myClientcb) myClientcb->SignalNetClientGameListRemove(gameName); }
|
||||
void ServerGuiWrapper::SignalNetClientGameStart(boost::shared_ptr<Game> game) { if (myClientcb) myClientcb->SignalNetClientGameStart(game); }
|
||||
void ServerGuiWrapper::SignalNetClientChatMsg(const string &playerName, const string &msg) { if (myClientcb) myClientcb->SignalNetClientChatMsg(playerName, msg); }
|
||||
void ServerGuiWrapper::SignalNetClientWaitDialog() { if (myClientcb) myClientcb->SignalNetClientWaitDialog(); }
|
||||
|
||||
@@ -98,6 +98,8 @@ public:
|
||||
void SignalNetClientChatMsg(const std::string &playerName, const std::string &msg);
|
||||
void SignalNetClientWaitDialog();
|
||||
|
||||
void SignalNetClientGameListNew(const std::string &gameName);
|
||||
void SignalNetClientGameListRemove(const std::string &gameName);
|
||||
void SignalNetClientGameStart(boost::shared_ptr<Game> game);
|
||||
|
||||
void SignalNetServerSuccess(int actionID);
|
||||
|
||||
@@ -10,12 +10,17 @@
|
||||
//
|
||||
//
|
||||
#include "gamelobbydialogimpl.h"
|
||||
#include "session.h"
|
||||
#include "configfile.h"
|
||||
#include "gamedata.h"
|
||||
|
||||
gameLobbyDialogImpl::gameLobbyDialogImpl(QWidget *parent, ConfigFile *c)
|
||||
: QDialog(parent), myConfig(c)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
connect( pushButton_CreateGame, SIGNAL( clicked() ), this, SLOT( createGame() ) );
|
||||
connect( pushButton_JoinGame, SIGNAL( clicked() ), this, SLOT( joinGame() ) );
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::exec()
|
||||
@@ -29,4 +34,50 @@ gameLobbyDialogImpl::~gameLobbyDialogImpl()
|
||||
{
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::setSession(Session *session)
|
||||
{
|
||||
mySession = session;
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::createGame()
|
||||
{
|
||||
assert(mySession);
|
||||
|
||||
// TODO: don't use hardcoded values
|
||||
GameData gameData;
|
||||
// Set Game Data
|
||||
gameData.maxNumberOfPlayers = myConfig->readConfigInt("NumberOfPlayers");
|
||||
gameData.startMoney = myConfig->readConfigInt("StartCash");
|
||||
gameData.smallBlind = myConfig->readConfigInt("SmallBlind");
|
||||
gameData.handsBeforeRaise = myConfig->readConfigInt("HandsBeforeRaiseSmallBlind");
|
||||
//Speeds
|
||||
gameData.guiSpeed = myConfig->readConfigInt("GameSpeed");
|
||||
|
||||
mySession->clientCreateGame(gameData, "default", "");
|
||||
|
||||
accept();
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::joinGame()
|
||||
{
|
||||
assert(mySession);
|
||||
|
||||
mySession->clientJoinGame("default", "");
|
||||
|
||||
accept();
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::addGame(QString gameName)
|
||||
{
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget_GameList,0);
|
||||
item->setData(0, 0, gameName);
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::removeGame(QString gameName)
|
||||
{
|
||||
QList<QTreeWidgetItem *> list = treeWidget_GameList->findItems(gameName, Qt::MatchExactly, 0);
|
||||
if(!list.empty()) {
|
||||
treeWidget_GameList->takeTopLevelItem(treeWidget_GameList->indexOfTopLevelItem(list[0]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,29 +13,39 @@
|
||||
#define GAMELOBBYDIALOGIMPL_H
|
||||
|
||||
#include <ui_gamelobbydialog.h>
|
||||
#include "configfile.h"
|
||||
|
||||
#include <QtGui>
|
||||
#include <QtCore>
|
||||
|
||||
class Session;
|
||||
class ConfigFile;
|
||||
|
||||
/**
|
||||
@author FThauer FHammer <webmaster@pokerth.net>
|
||||
*/
|
||||
class gameLobbyDialogImpl: public QDialog, public Ui::gameLobbyDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
gameLobbyDialogImpl(QWidget *parent = 0, ConfigFile* = 0);
|
||||
gameLobbyDialogImpl(QWidget *parent = 0, ConfigFile* = 0);
|
||||
|
||||
~gameLobbyDialogImpl();
|
||||
|
||||
~gameLobbyDialogImpl();
|
||||
|
||||
void exec();
|
||||
|
||||
void setSession(Session *session);
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
|
||||
ConfigFile *myConfig;
|
||||
void createGame();
|
||||
void joinGame();
|
||||
|
||||
void addGame(QString gameName);
|
||||
void removeGame(QString gameName);
|
||||
|
||||
private:
|
||||
|
||||
ConfigFile *myConfig;
|
||||
Session *mySession;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -119,6 +119,10 @@ void GuiWrapper::SignalNetClientPlayerLeft(const string &playerName)
|
||||
myW->signalNetClientPlayerLeft(tmpName);
|
||||
myLog->signalLogPlayerLeftMsg(tmpName);
|
||||
}
|
||||
|
||||
void GuiWrapper::SignalNetClientGameListNew(const string &gameName) { myW->signalNetClientGameListNew(QString::fromUtf8(gameName.c_str())); }
|
||||
void GuiWrapper::SignalNetClientGameListRemove(const string &gameName) { myW->signalNetClientGameListRemove(QString::fromUtf8(gameName.c_str())); }
|
||||
|
||||
void GuiWrapper::SignalNetClientGameStart(boost::shared_ptr<Game> game) { myW->signalNetClientGameStart(game); }
|
||||
void GuiWrapper::SignalNetClientChatMsg(const string &playerName, const string &msg) { myChat->signalChatMessage(QString::fromUtf8(playerName.c_str()), QString::fromUtf8(msg.c_str())); }
|
||||
void GuiWrapper::SignalNetClientWaitDialog() { myW->signalShowNetworkStartDialog(); }
|
||||
|
||||
@@ -105,6 +105,9 @@ public:
|
||||
void SignalNetClientChatMsg(const std::string &playerName, const std::string &msg);
|
||||
void SignalNetClientWaitDialog();
|
||||
|
||||
void SignalNetClientGameListNew(const std::string &gameName);
|
||||
void SignalNetClientGameListRemove(const std::string &gameName);
|
||||
|
||||
void SignalNetClientGameStart(boost::shared_ptr<Game> game);
|
||||
|
||||
void SignalNetServerSuccess(int actionID);
|
||||
|
||||
@@ -652,6 +652,8 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent)
|
||||
connect(this, SIGNAL(signalNetClientSelfJoined(QString, int)), myStartNetworkGameDialog, SLOT(joinedNetworkGame(QString, int)));
|
||||
connect(this, SIGNAL(signalNetClientPlayerJoined(QString, int)), myStartNetworkGameDialog, SLOT(addConnectedPlayer(QString, int)));
|
||||
connect(this, SIGNAL(signalNetClientPlayerLeft(QString)), myStartNetworkGameDialog, SLOT(removePlayer(QString)));
|
||||
connect(this, SIGNAL(signalNetClientGameListNew(QString)), myGameLobbyDialog, SLOT(addGame(QString)));
|
||||
connect(this, SIGNAL(signalNetClientGameListRemove(QString)), myGameLobbyDialog, SLOT(removeGame(QString)));
|
||||
|
||||
// Errors are handled globally, not within one dialog.
|
||||
connect(this, SIGNAL(signalNetClientError(int, int)), this, SLOT(networkError(int, int)));
|
||||
@@ -808,7 +810,22 @@ void mainWindowImpl::callJoinNetworkGameDialog() {
|
||||
|
||||
void mainWindowImpl::callGameLobbyDialog() {
|
||||
|
||||
mySession->terminateNetworkClient();
|
||||
if (myServerGuiInterface.get())
|
||||
myServerGuiInterface->getSession().terminateNetworkServer();
|
||||
|
||||
myGameLobbyDialog->setSession(&getSession());
|
||||
myGameLobbyDialog->treeWidget_GameList->clear();
|
||||
|
||||
// Just for testing
|
||||
mySession->startNetworkClientForLocalServer();
|
||||
|
||||
myGameLobbyDialog->exec();
|
||||
|
||||
if (myGameLobbyDialog->result() == QDialog::Accepted)
|
||||
{
|
||||
showNetworkStartDialog();
|
||||
}
|
||||
}
|
||||
|
||||
void mainWindowImpl::callSettingsDialog() {
|
||||
|
||||
@@ -129,6 +129,8 @@ signals:
|
||||
void signalNetClientSelfJoined(QString playerName, int rights);
|
||||
void signalNetClientPlayerJoined(QString playerName, int rights);
|
||||
void signalNetClientPlayerLeft(QString playerName);
|
||||
void signalNetClientGameListNew(QString gameName);
|
||||
void signalNetClientGameListRemove(QString gameName);
|
||||
void signalNetClientGameStart(boost::shared_ptr<Game> game);
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <net/socket_msg.h>
|
||||
|
||||
startNetworkGameDialogImpl::startNetworkGameDialogImpl(QWidget *parent, ConfigFile *config)
|
||||
: QDialog(parent), myConfig(config), isAdmin(false), myW(0)
|
||||
: QDialog(parent), myW(NULL), isAdmin(false), myConfig(config), mySession(NULL)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
|
||||
@@ -35,6 +35,8 @@ Q_OBJECT
|
||||
public:
|
||||
startNetworkGameDialogImpl(QWidget *parent = 0, ConfigFile *config = 0);
|
||||
|
||||
void setSession(Session *session);
|
||||
|
||||
public slots:
|
||||
|
||||
void setMyW ( mainWindowImpl* theValue ) { myW = theValue; }
|
||||
@@ -50,8 +52,6 @@ public slots:
|
||||
void kickPlayer();
|
||||
void checkPlayerQuantity();
|
||||
|
||||
void setSession(Session *session);
|
||||
|
||||
void keyPressEvent ( QKeyEvent*);
|
||||
|
||||
void setMaxPlayerNumber ( int theValue ) { maxPlayerNumber = theValue; label_maxPlayerNumber->setText(QString::number(theValue,10)); }
|
||||
|
||||
@@ -36,6 +36,9 @@ public:
|
||||
virtual void SignalNetClientGameInfo(int actionID) = 0;
|
||||
virtual void SignalNetClientError(int errorID, int osErrorID) = 0;
|
||||
|
||||
virtual void SignalNetClientGameListNew(const std::string &gameName) = 0;
|
||||
virtual void SignalNetClientGameListRemove(const std::string &gameName) = 0;
|
||||
|
||||
virtual void SignalNetClientGameStart(boost::shared_ptr<Game> game) = 0;
|
||||
virtual void SignalNetClientSelfJoined(const std::string &playerName, PlayerRights rights) = 0;
|
||||
virtual void SignalNetClientPlayerJoined(const std::string &playerName, PlayerRights rights) = 0;
|
||||
|
||||
@@ -56,14 +56,14 @@ public:
|
||||
void SendStartEvent();
|
||||
void SendPlayerAction();
|
||||
void SendChatMessage(const std::string &msg);
|
||||
void SendJoinGame(const std::string &name);
|
||||
void SendCreateGame(const GameData &gameData);
|
||||
void SendJoinGame(const std::string &name, const std::string &password);
|
||||
void SendCreateGame(const GameData &gameData, const std::string &name, const std::string &password);
|
||||
|
||||
ClientCallback &GetCallback();
|
||||
GuiInterface &GetGui();
|
||||
|
||||
protected:
|
||||
typedef std::map<unsigned, std::string> PlayerMap;
|
||||
typedef std::map<std::string, unsigned> GameMap;
|
||||
|
||||
// Main function of the thread.
|
||||
virtual void Main();
|
||||
@@ -97,6 +97,9 @@ protected:
|
||||
|
||||
void RemoveDisconnectedPlayers();
|
||||
|
||||
unsigned GetGameIdByName(const std::string &name) const;
|
||||
void AddGameInformation(const std::string &name, unsigned id);
|
||||
|
||||
private:
|
||||
|
||||
std::auto_ptr<ClientContext> m_context;
|
||||
@@ -111,6 +114,9 @@ private:
|
||||
StartData m_startData;
|
||||
PlayerDataList m_playerDataList;
|
||||
|
||||
GameMap m_gameMap;
|
||||
mutable boost::mutex m_gameMapMutex;
|
||||
|
||||
boost::shared_ptr<Game> m_game;
|
||||
|
||||
unsigned m_curGameId;
|
||||
|
||||
@@ -477,7 +477,14 @@ ClientStateWaitJoin::InternalProcess(ClientThread &client, boost::shared_ptr<Net
|
||||
{
|
||||
int retVal = MSG_SOCK_INTERNAL_PENDING;
|
||||
|
||||
if (packet->ToNetPacketJoinGameAck())
|
||||
if (packet->ToNetPacketGameListNew())
|
||||
{
|
||||
// A new game was created on the server.
|
||||
NetPacketGameListNew::Data gameListNewData;
|
||||
packet->ToNetPacketGameListNew()->GetData(gameListNewData);
|
||||
client.AddGameInformation(gameListNewData.gameName, gameListNewData.gameId);
|
||||
}
|
||||
else if (packet->ToNetPacketJoinGameAck())
|
||||
{
|
||||
// Successfully joined a game.
|
||||
NetPacketJoinGameAck::Data joinGameAckData;
|
||||
|
||||
@@ -147,15 +147,42 @@ ClientThread::SendChatMessage(const std::string &msg)
|
||||
}
|
||||
|
||||
void
|
||||
ClientThread::SendJoinGame(const std::string &name)
|
||||
ClientThread::SendJoinGame(const std::string &name, const std::string &password)
|
||||
{
|
||||
// TODO
|
||||
// Warning: This function is called in the context of the GUI thread.
|
||||
// Create a network packet to request joining a game.
|
||||
boost::shared_ptr<NetPacket> join(new NetPacketJoinGame);
|
||||
NetPacketJoinGame::Data joinData;
|
||||
joinData.password = password;
|
||||
try
|
||||
{
|
||||
joinData.gameId = GetGameIdByName(name);
|
||||
static_cast<NetPacketJoinGame *>(join.get())->SetData(joinData);
|
||||
GetSender().Send(GetContext().GetSocket(), join);
|
||||
} catch (const NetException &)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ClientThread::SendCreateGame(const GameData &gameData)
|
||||
ClientThread::SendCreateGame(const GameData &gameData, const std::string &name, const std::string &password)
|
||||
{
|
||||
// TODO
|
||||
// Warning: This function is called in the context of the GUI thread.
|
||||
// Create a network packet to request creating a new game.
|
||||
boost::shared_ptr<NetPacket> create(new NetPacketCreateGame);
|
||||
NetPacketCreateGame::Data createData;
|
||||
createData.gameData = gameData;
|
||||
createData.gameName = name;
|
||||
createData.password = password;
|
||||
try
|
||||
{
|
||||
static_cast<NetPacketCreateGame *>(create.get())->SetData(createData);
|
||||
GetSender().Send(GetContext().GetSocket(), create);
|
||||
} catch (const NetException &)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
ClientCallback &
|
||||
@@ -444,3 +471,25 @@ ClientThread::RemoveDisconnectedPlayers()
|
||||
}
|
||||
}
|
||||
|
||||
unsigned
|
||||
ClientThread::GetGameIdByName(const std::string &name) const
|
||||
{
|
||||
// Find the game.
|
||||
bool retVal = false;
|
||||
boost::mutex::scoped_lock lock(m_gameMapMutex);
|
||||
GameMap::const_iterator pos = m_gameMap.find(name);
|
||||
if (pos == m_gameMap.end())
|
||||
throw NetException(ERR_NET_UNKNOWN_GAME, 0);
|
||||
return pos->second;
|
||||
}
|
||||
|
||||
void
|
||||
ClientThread::AddGameInformation(const std::string &name, unsigned id)
|
||||
{
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_gameMapMutex);
|
||||
m_gameMap.insert(GameMap::value_type(name, id));
|
||||
}
|
||||
GetCallback().SignalNetClientGameListNew(name);
|
||||
}
|
||||
|
||||
|
||||
@@ -273,7 +273,7 @@ ServerGameStateInit::InternalProcess(ServerGameThread &server, SessionWrapper se
|
||||
if (packet->ToNetPacketStartEvent())
|
||||
{
|
||||
server.ResetComputerPlayerList();
|
||||
int remainingSlots = server.GetGameData().maxNumberOfPlayers - server.GetCurNumberOfPlayers();
|
||||
/* int remainingSlots = server.GetGameData().maxNumberOfPlayers - server.GetCurNumberOfPlayers();
|
||||
for (int i = 1; i <= remainingSlots; i++)
|
||||
{
|
||||
boost::shared_ptr<PlayerData> tmpPlayerData(
|
||||
@@ -286,7 +286,7 @@ ServerGameStateInit::InternalProcess(ServerGameThread &server, SessionWrapper se
|
||||
// Send "Player Joined" to other fully connected clients.
|
||||
server.SendToAllPlayers(CreateNetPacketPlayerJoined(*tmpPlayerData));
|
||||
server.AddComputerPlayer(tmpPlayerData);
|
||||
}
|
||||
}*/
|
||||
|
||||
server.InternalStartGame();
|
||||
server.SetState(SERVER_START_GAME_STATE::Instance());
|
||||
|
||||
@@ -137,6 +137,9 @@ ServerLobbyThread::Main()
|
||||
{
|
||||
GetCallback().SignalNetServerError(e.GetErrorId(), e.GetOsErrorCode());
|
||||
}
|
||||
|
||||
TerminateGames();
|
||||
|
||||
GetSender().SignalTermination();
|
||||
GetSender().Join(SENDER_THREAD_TERMINATE_TIMEOUT);
|
||||
|
||||
@@ -239,13 +242,13 @@ ServerLobbyThread::HandleNetPacketInit(SessionWrapper session, const NetPacketIn
|
||||
GetSender().Send(session.sessionData->GetSocket(), initAck);
|
||||
|
||||
// Send the game list to the client.
|
||||
/*GameThreadList::iterator game_i = m_gameList.begin();
|
||||
GameThreadList::iterator game_end = m_gameList.end();
|
||||
GameMap::const_iterator game_i = m_gameMap.begin();
|
||||
GameMap::const_iterator game_end = m_gameMap.end();
|
||||
while (game_i != game_end)
|
||||
{
|
||||
GetSender().Send(session.sessionData->GetSocket(), CreateNetPacketGameListUpdate(*(*game_i)));
|
||||
GetSender().Send(session.sessionData->GetSocket(), CreateNetPacketGameListNew(*game_i->second));
|
||||
++game_i;
|
||||
}*/
|
||||
}
|
||||
|
||||
// Set player data for session.
|
||||
m_sessionManager.SetSessionPlayerData(session.sessionData->GetSocket(), tmpPlayerData);
|
||||
@@ -317,6 +320,21 @@ ServerLobbyThread::CloseSessionLoop()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ServerLobbyThread::TerminateGames()
|
||||
{
|
||||
GameMap::iterator i = m_gameMap.begin();
|
||||
GameMap::iterator end = m_gameMap.end();
|
||||
|
||||
while (i != end)
|
||||
{
|
||||
i->second->SignalTermination();
|
||||
i->second->Join(GAME_THREAD_TERMINATE_TIMEOUT);
|
||||
++i;
|
||||
}
|
||||
m_gameMap.clear();
|
||||
}
|
||||
|
||||
void
|
||||
ServerLobbyThread::HandleNewConnection(boost::shared_ptr<ConnectData> connData)
|
||||
{
|
||||
@@ -409,3 +427,15 @@ ServerLobbyThread::GetGui()
|
||||
return m_gui;
|
||||
}
|
||||
|
||||
boost::shared_ptr<NetPacket>
|
||||
ServerLobbyThread::CreateNetPacketGameListNew(const ServerGameThread &game)
|
||||
{
|
||||
boost::shared_ptr<NetPacket> packet(new NetPacketGameListNew);
|
||||
NetPacketGameListNew::Data packetData;
|
||||
packetData.gameId = game.GetId();
|
||||
packetData.gameMode = GAME_MODE_CREATED;
|
||||
packetData.gameName = game.GetName();
|
||||
static_cast<NetPacketGameListNew *>(packet.get())->SetData(packetData);
|
||||
return packet;
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ private:
|
||||
StartData m_startData;
|
||||
std::auto_ptr<Game> m_game;
|
||||
const u_int32_t m_id;
|
||||
std::string m_name;
|
||||
const std::string m_name;
|
||||
std::string m_password;
|
||||
ConfigFile *m_playerConfig;
|
||||
ServerGameState *m_curState;
|
||||
|
||||
@@ -72,6 +72,7 @@ protected:
|
||||
void HandleNetPacketCreateGame(SessionWrapper session, const NetPacketCreateGame &tmpPacket);
|
||||
void HandleNetPacketJoinGame(SessionWrapper session, const NetPacketJoinGame &tmpPacket);
|
||||
void CloseSessionLoop();
|
||||
void TerminateGames();
|
||||
|
||||
void HandleNewConnection(boost::shared_ptr<ConnectData> connData);
|
||||
|
||||
@@ -91,6 +92,8 @@ protected:
|
||||
ServerSenderCallback &GetSenderCallback();
|
||||
GuiInterface &GetGui();
|
||||
|
||||
static boost::shared_ptr<NetPacket> CreateNetPacketGameListNew(const ServerGameThread &game);
|
||||
|
||||
private:
|
||||
|
||||
ConnectQueue m_connectQueue;
|
||||
|
||||
@@ -52,12 +52,13 @@
|
||||
#define ERR_NET_INVALID_PLAYER_CARDS 108
|
||||
#define ERR_NET_INVALID_PLAYER_RESULTS 109
|
||||
#define ERR_NET_INVALID_GAME_NAME 110
|
||||
#define ERR_NET_INVALID_CHAT_TEXT 111
|
||||
#define ERR_NET_UNKNOWN_PLAYER_ID 112
|
||||
#define ERR_NET_INVALID_ROUND 113
|
||||
#define ERR_NET_PLAYER_KICKED 114
|
||||
#define ERR_NET_INVALID_PLAYER_COUNT 115
|
||||
#define ERR_NET_PLAYER_NOT_IN_GAME 116
|
||||
#define ERR_NET_UNKNOWN_GAME 111
|
||||
#define ERR_NET_INVALID_CHAT_TEXT 112
|
||||
#define ERR_NET_UNKNOWN_PLAYER_ID 113
|
||||
#define ERR_NET_INVALID_ROUND 114
|
||||
#define ERR_NET_PLAYER_KICKED 115
|
||||
#define ERR_NET_INVALID_PLAYER_COUNT 116
|
||||
#define ERR_NET_PLAYER_NOT_IN_GAME 117
|
||||
|
||||
// This is an internal message which is not reported.
|
||||
#define MSG_SOCK_INTERNAL_PENDING 0
|
||||
|
||||
@@ -157,6 +157,20 @@ void Session::terminateNetworkClient()
|
||||
myNetClient = 0;
|
||||
}
|
||||
|
||||
void Session::clientCreateGame(const GameData &gameData, const string &name, const string &password)
|
||||
{
|
||||
if (!myNetClient)
|
||||
return; // only act if client is running.
|
||||
myNetClient->SendCreateGame(gameData, name, password);
|
||||
}
|
||||
|
||||
void Session::clientJoinGame(const std::string &name, const std::string &password)
|
||||
{
|
||||
if (!myNetClient)
|
||||
return; // only act if client is running.
|
||||
myNetClient->SendJoinGame(name, password);
|
||||
}
|
||||
|
||||
void Session::startNetworkServer(const GameData &gameData)
|
||||
{
|
||||
if (myNetServer)
|
||||
|
||||
@@ -48,6 +48,8 @@ public:
|
||||
void startNetworkClient(const std::string &serverAddress, unsigned serverPort, bool ipv6, bool sctp, const std::string &pwd);
|
||||
void startNetworkClientForLocalServer();
|
||||
void terminateNetworkClient();
|
||||
void clientCreateGame(const GameData &gameData, const std::string &name, const std::string &password);
|
||||
void clientJoinGame(const std::string &name, const std::string &password);
|
||||
|
||||
void startNetworkServer(const GameData &gameData);
|
||||
void sendStartEvent();
|
||||
|
||||
Reference in New Issue
Block a user