• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

libkdegames/kggzmod

KGGZMod::Module

KGGZMod::Module Class Reference

#include <module.h>

Inheritance diagram for KGGZMod::Module:

Inheritance graph
[legend]

List of all members.


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.

Author:
Josef Spillner (josef@ggzgamingzone.org)

Definition at line 82 of file module.h.


Public Types

enum  State {
  created, connected, waiting, playing,
  done
}

Signals

void signalEvent (const KGGZMod::Event &event)
void signalError ()
void signalNetwork (int fd)

Public Member Functions

 Module (const QString &name)
 ~Module ()
void sendRequest (Request request)
QList< Player * > players () const
QList< Player * > spectators () const
State state () const
Player * self () const

Static Public Member Functions

static bool isGGZ ()
static Module * instance ()

Member Enumeration Documentation

enum KGGZMod::Module::State

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.

Enumerator:
created  The initial state.

connected  The GGZ core client could be contacted successfully.

waiting  The connection to the game server has been established.

playing  The game client is now playing.

done  The game is over.

Definition at line 105 of file module.h.


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

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.

QList< Player * > Module::players (  )  const

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.

QList< Player * > Module::spectators (  )  const

Returns the list of game spectators.

Definition at line 93 of file module.cpp.

Module::State Module::state (  )  const

Returns the current state the game is in.

Definition at line 98 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 604 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 610 of file module.cpp.

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 615 of file module.cpp.

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::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::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


The documentation for this class was generated from the following files:
  • module.h
  • module.cpp

libkdegames/kggzmod

Skip menu "libkdegames/kggzmod"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • kblackbox
  • kgoldrunner
  • kmahjongg
  • ksquares
  • libkdegames
  •   highscore
  •   kgame
  •   kggzgames
  •   kggzmod
  •   kggznet
  • libkmahjongg
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal