Files
pokerth/src/session.h
T

105 lines
3.5 KiB
C++
Raw Normal View History

2007-01-13 02:40:33 +00:00
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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. *
***************************************************************************/
#ifndef STDSESSION_H
#define STDSESSION_H
#include "gamedata.h"
#include "playerdata.h"
#include "game_defs.h"
2007-01-13 02:40:33 +00:00
#include <string>
#include <boost/shared_ptr.hpp>
2007-01-13 02:40:33 +00:00
class GuiInterface;
class Game;
2007-01-21 14:20:15 +00:00
class ConfigFile;
2007-02-18 13:45:56 +00:00
class ClientThread;
class ServerAcceptThread;
class IrcThread;
class AvatarManager;
2007-01-13 02:40:33 +00:00
class Session{
public:
2007-05-13 12:35:27 +00:00
Session(GuiInterface*, ConfigFile*);
2007-01-13 02:40:33 +00:00
~Session();
2007-01-13 02:40:33 +00:00
enum GameType { GAME_TYPE_NONE, GAME_TYPE_LOCAL, GAME_TYPE_NETWORK, GAME_TYPE_INTERNET };
// Only one of the two inits should be called.
2007-09-08 21:43:15 +00:00
bool init();
void init(boost::shared_ptr<AvatarManager> manager);
2007-09-08 21:43:15 +00:00
void startLocalGame(const GameData &gameData, const StartData &startData);
void startClientGame(boost::shared_ptr<Game> game);
2007-01-13 02:40:33 +00:00
Game *getCurrentGame();
2007-05-14 12:40:42 +00:00
GuiInterface *getGui();
GameType getGameType();
2007-05-14 12:40:42 +00:00
boost::shared_ptr<AvatarManager> getAvatarManager();
void startInternetClient();
2007-06-04 16:49:19 +00:00
void startNetworkClient(const std::string &serverAddress, unsigned serverPort, bool ipv6, bool sctp, const std::string &pwd);
void startNetworkClientForLocalServer(const GameData &gameData);
2007-02-18 13:45:56 +00:00
void terminateNetworkClient();
void clientCreateGame(const GameData &gameData, const std::string &name, const std::string &password);
void clientJoinGame(unsigned gameId, const std::string &password);
2007-02-18 13:45:56 +00:00
void startNetworkServer();
void sendLeaveCurrentGame();
void sendStartEvent(bool fillUpWithCpuPlayers);
void terminateNetworkServer();
2007-10-02 18:58:54 +00:00
bool waitForNetworkServer(unsigned timeoutMsec);
void sendIrcChatMessage(const std::string &message);
2007-05-23 22:31:56 +00:00
void sendClientPlayerAction();
void setCurrentGameID(int theValue) { currentGameID = theValue; }
int getCurrentGameID() const { return currentGameID; }
2007-01-21 14:20:15 +00:00
2007-05-25 16:03:12 +00:00
void sendChatMessage(const std::string &message);
void kickPlayer(unsigned playerId);
2007-05-25 00:09:51 +00:00
bool isNetworkClientRunning() const; // TODO hack
bool isNetworkServerRunning() const; // TODO hack
GameInfo getClientGameInfo(unsigned gameId);
PlayerInfo getClientPlayerInfo(unsigned playerId);
2007-01-13 02:40:33 +00:00
private:
2007-02-04 13:46:27 +00:00
int currentGameID;
2007-02-04 13:46:27 +00:00
2007-02-18 13:45:56 +00:00
ClientThread *myNetClient;
ServerAcceptThread *myNetServer;
IrcThread *myIrcThread;
boost::shared_ptr<AvatarManager> myAvatarManager;
2007-02-18 13:45:56 +00:00
boost::shared_ptr<Game> currentGame;
2007-01-13 02:40:33 +00:00
GuiInterface *myGui;
2007-01-21 14:20:15 +00:00
ConfigFile *myConfig;
GameType myGameType;
2007-01-13 02:40:33 +00:00
};
#endif