NetMauMau
0.24.0
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. | |
typedef std::vector < Common::ICard * > | CARDS |
A vector of Common::ICard pointers. | |
typedef Connection::PLAYERINFOS | PLAYERINFOS |
List of currently registered player infos. | |
typedef Connection::PLAYERLIST | PLAYERLIST |
List of currently registered player names. | |
typedef Connection::SCORE | SCORE |
the score | |
typedef Connection::SCORE_TYPE | SCORE_TYPE |
The type of scores. | |
typedef Connection::SCORES | SCORES |
a vector of scores | |
typedef std::vector< STAT > | STATS |
A vector with statistics about the other player's card count. |
Server query methods | |
static uint32_t | getClientProtocolVersion () |
Returns the version of the client's implemented protocol. | |
static uint32_t | getClientLibraryVersion () |
Returns the version of the client library. | |
static uint32_t | parseProtocolVersion (const std::string &version) |
Parses a version string and returns the resulting protocol version. | |
static bool | isPlayerImageUploadable (const unsigned char *pngData, std::size_t pngDataLen) |
Checks if an player image is uploadable to the server. | |
static uint16_t | getDefaultPort () |
Gets the default port of the server. | |
static const char * | getDefaultAIName () |
Gets the compiled in default AI player name. | |
CAPABILITIES | capabilities (timeval *timeout=NULL) throw (NetMauMau::Common::Exception::SocketException) |
Returns the server capabilities. | |
PLAYERINFOS | playerList (bool playerPNG, timeval *timeout=NULL) throw (NetMauMau::Common::Exception::SocketException) |
Returns the list of currently registered player names. | |
PLAYERLIST | playerList (timeval *timeout=NULL) throw (NetMauMau::Common::Exception::SocketException) |
Returns the list of currently registered player names. | |
std::string | getPlayerName () const |
Gets the player's name. |
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. | |
Server query methods | |
SCORES | getScores (SCORE_TYPE::_scoreType type=SCORE_TYPE::ABS, std::size_t limit=10, timeval *timeout=0L) throw (NetMauMau::Common::Exception::SocketException) |
Gets the scores from the server. | |
SCORES | getScores (timeval *timeout) throw (NetMauMau::Common::Exception::SocketException) |
Static Public Member Functions | |
Server query methods | |
static bool | isPlayerImageUploadable (const unsigned char *pngData, std::size_t pngDataLen, const IBase64 *base64) |
Checks if an player image is uploadable to the server. |
Protected Member Functions | |
AbstractClientV11 (const std::string &player, const std::string &server, uint16_t port, uint32_t clientVersion) | |
Creates an AbstractClientV11 instance. | |
AbstractClientV11 (const std::string &player, const std::string &server, uint16_t port, uint32_t clientVersion, const IBase64 *base64) | |
Creates an AbstractClientV11 instance. | |
AbstractClientV11 (const std::string &player, const unsigned char *pngData, std::size_t pngDataLen, const std::string &server, uint16_t port, uint32_t clientVersion, const IBase64 *base64) | |
Creates an AbstractClientV11 instance. | |
AbstractClientV11 (const std::string &player, const unsigned char *pngData, std::size_t pngDataLen, const std::string &server, uint16_t port, uint32_t clientVersion) | |
Creates an AbstractClientV11 instance. | |
virtual Common::ICard * | playCard (const CARDS &cards) const |
The server requests a card to play. | |
virtual void | unknownServerMessage (const std::string &msg) const =0 |
The server sent a message not understood by the client. | |
Server requests | |
virtual Common::ICard * | playCard (const CARDS &cards, std::size_t takeCount) const =0 |
The server requests a card to play. | |
Server requests | |
This requests require a client of at least version 0.7 | |
virtual bool | getAceRoundChoice () const =0 |
Gets the choice if an ace round should be started. | |
Server events | |
This events require a client of at least version 0.7 | |
virtual void | aceRoundStarted (const std::string &player) const =0 |
An ace round was started by a player. | |
virtual void | aceRoundEnded (const std::string &player) const =0 |
An ace round was ended by a player. | |
Server requests | |
virtual Common::ICard::SUIT | getJackSuitChoice () const =0 |
Gets the current Jack suit. | |
Server events | |
virtual void | message (const std::string &msg) const =0 |
The server send a general message. | |
virtual void | error (const std::string &msg) const =0 |
The server send a error message. | |
virtual void | turn (std::size_t turn) const =0 |
A new turn has started. | |
virtual void | stats (const STATS &stats) const =0 |
The server sent statistics about the other player's card count. | |
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. | |
virtual void | playerRejected (const std::string &player) const =0 |
A player got rejected to join the game. | |
virtual void | playerSuspends (const std::string &player) const =0 |
A player suspends this turn. | |
virtual void | playedCard (const std::string &player, const Common::ICard *card) const =0 |
A player played a card. | |
virtual void | playerWins (const std::string &player, std::size_t turn) const =0 |
A player has won the game. | |
virtual void | playerLost (const std::string &player, std::size_t turn, std::size_t points) const =0 |
A player has lost the game. | |
virtual void | playerPicksCard (const std::string &player, const Common::ICard *card) const =0 |
A player picks up a card. | |
virtual void | playerPicksCard (const std::string &player, std::size_t count) const =0 |
A player picks up an amount of cards. | |
virtual void | nextPlayer (const std::string &player) const =0 |
Name of the next player. | |
virtual void | enableSuspend (bool enable) const =0 |
Notes if suspending and taking a card possible. | |
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. | |
virtual void | initialCard (const Common::ICard *card) const =0 |
The initial card. | |
virtual void | openCard (const Common::ICard *card, const std::string &jackSuit) const =0 |
The current open card. | |
virtual void | talonShuffled () const =0 |
The talon was empty and shuffled anew. | |
virtual void | cardRejected (const std::string &player, const Common::ICard *card) const =0 |
The player's played card got rejected. | |
virtual void | cardAccepted (const Common::ICard *card) const =0 |
The player's played card got accepted. | |
virtual void | jackSuit (Common::ICard::SUIT suit) const =0 |
The server announces a Jack suit. | |
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. | |
virtual void | endReceivePlayerPicture (const std::string &player) const throw () |
A download of a player image has ended. | |
virtual void | uploadSucceded (const std::string &player) const throw () |
The upload of the player image has succeeded. | |
virtual void | uploadFailed (const std::string &player) const throw () |
The upload of the player image has failed. |
|
inherited |
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 |
WEBSERVER_URL | if the webserver is started it contains the URL of it |
|
inherited |
List of currently registered player infos.
|
inherited |
List of currently registered player names.
|
inherited |
the score
|
inherited |
The type of scores.
|
inherited |
a vector
of scores
|
inherited |
A vector with statistics about the other player's card count.
|
explicitprotected |
Creates an AbstractClientV11
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 |
clientVersion | the protocol version the client understands |
|
explicitprotected |
Creates an AbstractClientV11
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 |
clientVersion | the protocol version the client understands |
base64 | interface to a custom implementation of IBase64 |
|
explicitprotected |
Creates an AbstractClientV11
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 |
clientVersion | the protocol version the client understands |
base64 | interface to a custom implementation of IBase64 |
|
protected |
Creates an AbstractClientV11
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 |
clientVersion | the protocol version the client understands |
|
protectedpure virtualinherited |
An ace round was ended by a player.
player | the player ending the ace round |
|
protectedpure virtualinherited |
An ace round was started by a player.
player | the player starting the ace round |
|
protectedvirtualinherited |
A download of a player image has started.
player | the player the image is downloaded for |
|
protectedpure virtualinherited |
The player's played card got accepted.
card | the accepted card |
|
protectedpure virtualinherited |
The player's played card got rejected.
player | the player's name |
card | the rejected card |
|
protectedpure virtualinherited |
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 virtualinherited |
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 |
|
protectedvirtualinherited |
A download of a player image has ended.
player | the player the image is downloaded for |
|
protectedpure virtualinherited |
The server send a error message.
msg | the error message |
|
protectedpure virtualinherited |
Gets the choice if an ace round should be started.
true
to start an ace round, false
otherwise
|
protectedpure virtualinherited |
Gets the current Jack suit.
|
inherited |
Gets the scores from the server.
Example usage code:
type | type of scores |
limit | limit the result, 0 disables the limit |
timeout | throw a Exception::TimeoutException on exceeding timeout |
|
inherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
protectedpure virtualinherited |
The initial card.
card | the initial card |
|
protectedpure virtualinherited |
The server announces a Jack suit.
suit | the current Jack suit |
|
protectedpure virtualinherited |
The server send a general message.
msg | the general message |
|
protectedpure virtualinherited |
Name of the next player.
player | the next player's name |
|
protectedpure virtualinherited |
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 |
|
inherited |
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 |
|
protectedvirtualinherited |
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 Implements NetMauMau::Client::AbstractClientV05.
|
protectedpure virtualinherited |
The server requests a card to play.
If takeCount
is > 0
the client can use Common::getIllegalCard
to retrive the cards first
takeCount | the amount of cards the player has to take |
|
protectedpure virtualinherited |
A player played a card.
player | the player's name |
card | the card the player played |
|
protectedpure virtualinherited |
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 virtualinherited |
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 losing player had in hand |
|
protectedpure virtualinherited |
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 virtualinherited |
A player picks up an amount of cards.
player | the player's name |
count | the count of picked up cards |
|
protectedpure virtualinherited |
A player got rejected to join the game.
player | the rejected player's name |
|
protectedpure virtualinherited |
A player suspends this turn.
player | the suspending player's name |
|
protectedpure virtualinherited |
A player has won the game.
player | the player's name |
turn | the number of the turn the player has won |
|
protectedpure virtualinherited |
The server sent statistics about the other player's card count.
stats | the statistics about the other player's card count |
|
protectedpure virtualinherited |
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 virtualinherited |
A new turn has started.
turn | number of the current turn |
|
protectedpure virtualinherited |
The server sent a message not understood by the client.
message | the unknown message |
|
protectedvirtualinherited |
The upload of the player image has failed.
player | the player the image is uploaded for |
|
protectedvirtualinherited |
The upload of the player image has succeeded.
player | the player the image is uploaded for |