libkdegames/kggzmod
KGGZMod::Module Class Reference
#include <module.h>

Detailed Description
GGZ Gaming Zone game client to core client interface.Any game client intended to run on GGZ should instanciate exactly one object of this class and connect its signals to the game protocol handler. GGZ core client events are delivered by signalEvent but can be ignored. If needed, the Event class provides more information. Messages from the game server are emitted by signalNetwork. This signal can either lead to a networking routine within the game or to an instance of a ggzcommgen-generated protocol handler class, which itself provides signals for the game. The third signal, signalError, should terminate the network gaming with an appropriate error message. When signalError is emitted, the internal GGZ network connections have already been disconnected.
In addition to the signals, the current game state can be queried, as can the list of players and game spectators as Player objects.
Finally, the object of this class is used to send request to GGZ, for changing the state, retrieving player information and similar actions. The Request class has more details.
Definition at line 82 of file module.h.
Public Types | |
| enum | State { created, connected, waiting, playing, done } |
Signals | |
| void | signalError () |
| void | signalEvent (const KGGZMod::Event &event) |
| void | signalNetwork (int fd) |
Public Member Functions | |
| Module (const QString &name) | |
| QList< Player * > | players () const |
| Player * | self () const |
| void | sendRequest (Request request) |
| QList< Player * > | spectators () const |
| State | state () const |
| ~Module () | |
Static Public Member Functions | |
| static Module * | instance () |
| static bool | isGGZ () |
Member Enumeration Documentation
The state a GGZ game can be in.
These states are controlled by the GGZ server (for created, connected and waiting) and afterwards by the game server which toggles between waiting and playing until finally reaching done.
Constructor & Destructor Documentation
| Module::Module | ( | const QString & | name | ) |
Initialisation of online gaming through GGZ.
Before online gaming is activated, the validity of the GGZ environment should be checked with the static isGGZ method.
- Parameters:
-
name Name of the game client
Definition at line 46 of file module.cpp.
| Module::~Module | ( | ) |
Definition at line 75 of file module.cpp.
Member Function Documentation
| Module * Module::instance | ( | ) | [static] |
Returns the single instance of this class.
If no instance exists yet, null is returned. However, if multiple instances exist, this method might return one of the existing instances, but also null, i.e. the behaviour is undefined. In most scenarios, there will be exactly one instance.
- Returns:
- Module instance, or null if not applicable
Definition at line 626 of file module.cpp.
| bool Module::isGGZ | ( | ) | [static] |
Checks if the game is started in a GGZ environment.
Calling Module should only be done in case a GGZ environment has been detected.
- Returns:
- true if the game runs on GGZ, false otherwise
Definition at line 615 of file module.cpp.
Returns the list of seats on the table.
This includes all active players, bots, open seats and abandoned/reserved seats.
Definition at line 88 of file module.cpp.
| Player * Module::self | ( | ) | const |
Returns information about the player who is running the game client.
- Returns:
- player information, or null if not available yet
Definition at line 621 of file module.cpp.
| void Module::sendRequest | ( | Request | request | ) |
Sends a request to the GGZ core client.
The request is then forwarded to the GGZ server if necessary. In most cases, an event will be delivered back to the game client.
- Parameters:
-
request The request to the GGZ core client
Definition at line 83 of file module.cpp.
| void KGGZMod::Module::signalError | ( | ) | [signal] |
An error has occurred.
In such a case, the game client should terminate its multiplayer mode and depending on the situation also terminate itself.
| void KGGZMod::Module::signalEvent | ( | const KGGZMod::Event & | event | ) | [signal] |
An event from the GGZ core client has happened.
Such events can be ignored but are still useful for many games to know.
- Parameters:
-
event The event from the core client
| void KGGZMod::Module::signalNetwork | ( | int | fd | ) | [signal] |
Messages from the game server are available.
If the connection to the game server is active and the game server writes out a message, the file descriptor contained in this event can be used to communicate with the game server. The file descriptor is initially reported in a signalEvent as well as a ServerEvent.
- Parameters:
-
fd File descriptor from which to read the message
| Module::State Module::state | ( | ) | const |
The documentation for this class was generated from the following files:
KDE 4.2 API Reference