NetMauMau
0.17.1
Client API
|
#include <abstractclient.h>
Client interface to communicate with the server
Public Types | |
typedef Connection::CAPABILITIES | CAPABILITIES |
Key/value map of the server capabilities. More... | |
typedef std::vector < Common::ICard * > | CARDS |
A vector of Common::ICard pointers. | |
typedef Connection::PLAYERINFOS | PLAYERINFOS |
List of currently registered player infos. More... | |
typedef Connection::PLAYERLIST | PLAYERLIST |
List of currently registered player names. More... | |
typedef std::vector< STAT > | STATS |
A vector with statistics about the other player's card count. More... | |
Server query methods | |
CAPABILITIES | capabilities (timeval *timeout=NULL) throw (NetMauMau::Common::Exception::SocketException) |
Returns the server capabilities. More... | |
PLAYERINFOS | playerList (bool playerPNG, timeval *timeout=NULL) throw (NetMauMau::Common::Exception::SocketException) |
Returns the list of currently registered player names. More... | |
PLAYERLIST | playerList (timeval *timeout=NULL) throw (NetMauMau::Common::Exception::SocketException) |
Returns the list of currently registered player names. More... | |
std::string | getPlayerName () const |
Gets the player's name. More... | |
static uint32_t | getClientProtocolVersion () |
Returns the version of the client's implemented protocol. More... | |
static uint32_t | getClientLibraryVersion () |
Returns the version of the client library. More... | |
static uint32_t | parseProtocolVersion (const std::string &version) |
Parses a version string and returns the resulting protocol version. More... | |
static bool | isPlayerImageUploadable (const unsigned char *pngData, std::size_t pngDataLen) |
Checks if an player image is uploadable to the server. More... | |
static uint16_t | getDefaultPort () |
Gets the default port of the server. More... | |
static const char * | getDefaultAIName () |
Gets the compiled in default AI player name. More... | |
Public Member Functions | |
void | disconnect () |
Disconnects the client from the server. | |
void | play (timeval *timeout=NULL) throw (NetMauMau::Common::Exception::SocketException) |
Attempt to start a game on the servers. More... | |
Protected Member Functions | |
AbstractClientV05 (const std::string &player, const std::string &server, uint16_t port) | |
Creates an AbstractClientV05 instance. More... | |
AbstractClientV05 (const std::string &player, const unsigned char *pngData, std::size_t pngDataLen, const std::string &server, uint16_t port) | |
Creates an AbstractClientV05 instance. More... | |
virtual void | unknownServerMessage (const std::string &msg) const =0 |
The server sent a message not understood by the client. More... | |
Server requests | |
virtual Common::ICard * | playCard (const CARDS &cards) const =0 |
The server requests a card to play. More... | |
virtual Common::ICard::SUIT | getJackSuitChoice () const =0 |
Gets the current Jack suit. More... | |
Server events | |
virtual void | message (const std::string &msg) const =0 |
The server send a general message. More... | |
virtual void | error (const std::string &msg) const =0 |
The server send a error message. More... | |
virtual void | turn (std::size_t turn) const =0 |
A new turn has started. More... | |
virtual void | stats (const STATS &stats) const =0 |
The server sent statistics about the other player's card count. More... | |
virtual void | gameOver () const =0 |
The server announced the game is over. | |
virtual void | playerJoined (const std::string &player, const unsigned char *pngData, std::size_t len) const =0 |
A new player joined the game. More... | |
virtual void | playerRejected (const std::string &player) const =0 |
A player got rejected to join the game. More... | |
virtual void | playerSuspends (const std::string &player) const =0 |
A player suspends this turn. More... | |
virtual void | playedCard (const std::string &player, const Common::ICard *card) const =0 |
A player played a card. More... | |
virtual void | playerWins (const std::string &player, std::size_t turn) const =0 |
A player has won the game. More... | |
virtual void | playerLost (const std::string &player, std::size_t turn, std::size_t points) const =0 |
A player has lost the game. More... | |
virtual void | playerPicksCard (const std::string &player, const Common::ICard *card) const =0 |
A player picks up a card. More... | |
virtual void | playerPicksCard (const std::string &player, std::size_t count) const =0 |
A player picks up an amount of cards. More... | |
virtual void | nextPlayer (const std::string &player) const =0 |
Name of the next player. More... | |
virtual void | enableSuspend (bool enable) const =0 |
Notes if suspending and taking a card possible. More... | |
virtual void | cardSet (const CARDS &cards) const =0 |
The card set distributed to the player, or if the player picked up cards off the talon. More... | |
virtual void | initialCard (const Common::ICard *card) const =0 |
The initial card. More... | |
virtual void | openCard (const Common::ICard *card, const std::string &jackSuit) const =0 |
The current open card. More... | |
virtual void | talonShuffled () const =0 |
The talon was empty and shuffled anew. More... | |
virtual void | cardRejected (const std::string &player, const Common::ICard *card) const =0 |
The player's played card got rejected. More... | |
virtual void | cardAccepted (const Common::ICard *card) const =0 |
The player's played card got accepted. More... | |
virtual void | jackSuit (Common::ICard::SUIT suit) const =0 |
The server announces a Jack suit. More... | |
Player image notifications | |
The notifications can be overloaded if the client is interested in events regarding the player pictures. This functions all do nothing at default. | |
virtual void | beginReceivePlayerPicture (const std::string &player) const throw () |
A download of a player image has started. More... | |
virtual void | endReceivePlayerPicture (const std::string &player) const throw () |
A download of a player image has ended. More... | |
virtual void | uploadSucceded (const std::string &player) const throw () |
The upload of the player image has succeded. More... | |
virtual void | uploadFailed (const std::string &player) const throw () |
The upload of the player image has failed. More... | |
struct NetMauMau::Client::AbstractClientV05::STAT |
Key/value map of the server capabilities.
Key | Value |
---|---|
ACEROUND | false if no ace rounds are enabled, else A , Q or K for the rank |
AI_NAME | name of the first AI player |
AI_OPPONENT | true if the AI opponent is enabled |
CUR_PLAYERS | amount of current players joined |
DIRCHANGE | true if direction changes are allowed, false otherwise |
HAVE_SCORES | true if the server can provide scores, false otherwise |
INITIAL_CARDS | if played with an amount of initial cards not equal to 5 contains the number of cards |
MAX_PLAYERS | amount of players needed to start the game |
MIN_VERSION | minimum version of client that can connect |
SERVER_VERSION | version of the server |
SERVER_VERSION_REL | version of the server (including release) |
TALON | if played with more than 1 card deck contains the number of cards |
ULTIMATE | true if running in ultimate mode, false otherwise |
List of currently registered player infos.
List of currently registered player names.
typedef std::vector<STAT> NetMauMau::Client::AbstractClientV05::STATS |
A vector with statistics about the other player's card count.
|
explicitprotected |
Creates an AbstractClientV05
instance.
Sets up all information to connect to a server
player | the player's name |
server | the server to connect to |
port | the server port to connect to |
|
explicitprotected |
Creates an AbstractClientV05
instance.
Sets up all information to connect to a server. Additionally a player picture can be submitted
player | the player's name |
pngData | pointer to a buffer containg PNG image data or NULL |
pngDataLen | length of the data in the buffer pointed to by pngData |
server | the server to connect to |
port | the server port to connect to |
|
protectedvirtual |
A download of a player image has started.
player | the player the image is downloaded for |
|
protectedpure virtual |
The player's played card got accepted.
card | the accepted card |
|
protectedpure virtual |
The player's played card got rejected.
player | the player's name |
card | the rejected card |
|
protectedpure virtual |
The card set distributed to the player, or if the player picked up cards off the talon.
cards | the card set given to the player |
|
protectedpure virtual |
Notes if suspending and taking a card possible.
If there are no more cards on the talon, except the open card, suspending and taking card a is not possible
enable | true if it is possible to take a card, false otherwise |
|
protectedvirtual |
A download of a player image has ended.
player | the player the image is downloaded for |
|
protectedpure virtual |
The server send a error message.
msg | the error message |
|
protectedpure virtual |
Gets the current Jack suit.
|
protectedpure virtual |
The initial card.
card | the initial card |
|
protectedpure virtual |
The server announces a Jack suit.
suit | the current Jack suit |
|
protectedpure virtual |
The server send a general message.
msg | the general message |
|
protectedpure virtual |
Name of the next player.
player | the next player's name |
|
protectedpure virtual |
The current open card.
If there is a suit chosen by a Jack the jackSuit contains it and can get converted to NetMauMau::Common::ICard::SUIT
by NetMauMau::Common::symbolToSuit, else it will be a empty string.
card | the current open card |
jackSuit | the current jack suit |
void AbstractClientV05::play | ( | timeval * | timeout = NULL | ) | |
throw | ( | NetMauMau::Common::Exception::SocketException | |||
) |
Attempt to start a game on the servers.
timeout | the time to wait for a connection, if NULL there will be no timeout |
Common::Exception::SocketException | if the connection failed |
Client::Exception::TimeoutException | if the connection attempt timed out |
Client::Exception::ProtocolErrorException | if there was a aprotocol error |
Client::Exception::ConnectionRejectedException | if the connection got rejected |
Client::Exception::NoNetMauMauServerException | if the remote host is no NetMauMau server |
Client::Exception::ShutdownException | if the server is shutting down |
Client::Exception::VersionMismatchException | if the client is not supported |
|
protectedpure virtual |
The server requests a card to play.
cards | playable cards, which will get accepted by the server |
NULL
if the player cannot play a card and/or suspends the turn or the illegal card Implemented in NetMauMau::Client::AbstractClientV08.
|
protectedpure virtual |
A player played a card.
player | the player's name |
card | the card the player played |
|
protectedpure virtual |
A new player joined the game.
Transmits a PNG picture of the player if available
player | the new player's name |
pngData | PNG data of the players picture or 0L |
pngDataLen | length of the PNG data |
|
protectedpure virtual |
A player has lost the game.
player | the player's name |
turn | the number of the turn the player has lost |
points | the points the loosing player had in hand |
|
protectedpure virtual |
A player picks up a card.
NULL
if the player is a remote playerplayer | the player's name |
card | the card the player picked up |
|
protectedpure virtual |
A player picks up an amount of cards.
player | the player's name |
count | the count of picked up cards |
|
protectedpure virtual |
A player got rejected to join the game.
player | the rejected player's name |
|
protectedpure virtual |
A player suspends this turn.
player | the suspending player's name |
|
protectedpure virtual |
A player has won the game.
player | the player's name |
turn | the number of the turn the player has won |
|
protectedpure virtual |
The server sent statistics about the other player's card count.
stats | the statistics about the other player's card count |
|
protectedpure virtual |
The talon was empty and shuffled anew.
All played cards, except the open top card are shuffled and added to the Talon.
This event can be used for displaying an shuffle animation.
|
protectedpure virtual |
A new turn has started.
turn | number of the current turn |
|
protectedpure virtual |
The server sent a message not understood by the client.
message | the unknown message |
|
protectedvirtual |
The upload of the player image has failed.
player | the player the image is uploaded for |
|
protectedvirtual |
The upload of the player image has succeded.
player | the player the image is uploaded for |