KGameMessage

Search for usage in LXR

#include <KGame/KGameMessage>

Public Types

enum  GameMessageIds {
  IdSetupGame = 1 , IdSetupGameContinue = 2 , IdGameLoad = 3 , IdGameConnected = 4 ,
  IdSyncRandom = 5 , IdDisconnect = 6 , IdGameSetupDone = 7 , IdPlayerProperty = 20 ,
  IdGameProperty = 21 , IdAddPlayer = 30 , IdRemovePlayer = 31 , IdActivatePlayer = 32 ,
  IdInactivatePlayer = 33 , IdTurn = 34 , IdError = 100 , IdPlayerInput = 101 ,
  IdIOAdded = 102 , IdProcessQuery = 220 , IdPlayerId = 221 , IdUser = 256
}
 

Static Public Member Functions

static void createHeader (QDataStream &msg, quint32 sender, quint32 receiver, int msgid)
 
static quint32 createPlayerId (int player, quint32 game)
 
static void createPropertyCommand (QDataStream &msg, int cmdid, int pid, int cmd)
 
static void createPropertyHeader (QDataStream &msg, int id)
 
static void extractHeader (QDataStream &msg, quint32 &sender, quint32 &receiver, int &msgid)
 
static void extractPropertyCommand (QDataStream &msg, int &pid, int &cmd)
 
static void extractPropertyHeader (QDataStream &msg, int &id)
 
static bool isGame (quint32 id)
 
static bool isPlayer (quint32 id)
 
static QString messageId2Text (int msgid)
 
static quint32 rawGameId (quint32 playerid)
 
static int rawPlayerId (quint32 playerid)
 
static int version ()
 

Detailed Description

Namespace-like class for message-related static functions.

Definition at line 22 of file kgamemessage.h.

Member Enumeration Documentation

◆ GameMessageIds

Message Ids used inside KGame.

You can use your own custom message Id by adding IdUser to it.

Definition at line 130 of file kgamemessage.h.

Member Function Documentation

◆ createHeader()

void KGameMessage::createHeader ( QDataStream & msg,
quint32 sender,
quint32 receiver,
int msgid )
static

Creates a message header given cookie,sender,receiver,...

Also puts "hidden" header into the stream which are used by KGameClient (message length and magic cookie). If you don't need them remove them with dropExternalHeader

Definition at line 48 of file kgamemessage.cpp.

◆ createPlayerId()

quint32 KGameMessage::createPlayerId ( int player,
quint32 game )
static

Creates a fully qualified player ID which contains the original player id in the lower bits and the game number in the higher bits.

Do not rely on the exact bit positions as they are internal.

See also rawPlayerId and rawGameId which are the inverse operations

Parameters
playerThe player id - can include a gameid (will get removed)
gameThe game id (<64). 0 For broadcast.
Returns
The new player id

Definition at line 16 of file kgamemessage.cpp.

◆ createPropertyCommand()

void KGameMessage::createPropertyCommand ( QDataStream & msg,
int cmdid,
int pid,
int cmd )
static

Creates a property header given the property id.

Definition at line 74 of file kgamemessage.cpp.

◆ createPropertyHeader()

void KGameMessage::createPropertyHeader ( QDataStream & msg,
int id )
static

Creates a property header given the property id.

Definition at line 62 of file kgamemessage.cpp.

◆ extractHeader()

void KGameMessage::extractHeader ( QDataStream & msg,
quint32 & sender,
quint32 & receiver,
int & msgid )
static

Retrieves the information like cookie,sender,receiver,... from a message header.

Note that it could be necessary to call dropExternalHeader first

Definition at line 53 of file kgamemessage.cpp.

◆ extractPropertyCommand()

void KGameMessage::extractPropertyCommand ( QDataStream & msg,
int & pid,
int & cmd )
static

Retrieves the property id from a property message header.

Definition at line 81 of file kgamemessage.cpp.

◆ extractPropertyHeader()

void KGameMessage::extractPropertyHeader ( QDataStream & msg,
int & id )
static

Retrieves the property id from a property message header.

Definition at line 67 of file kgamemessage.cpp.

◆ isGame()

bool KGameMessage::isGame ( quint32 id)
static

Checks whether the sender/receiver of a message is a game.

Parameters
idThe ID of the sender/receiver
Returns
true/false

Definition at line 43 of file kgamemessage.cpp.

◆ isPlayer()

bool KGameMessage::isPlayer ( quint32 id)
static

Checks whether a message receiver/sender is a player.

Parameters
idThe ID of the sender/receiver
Returns
true/false

Definition at line 34 of file kgamemessage.cpp.

◆ messageId2Text()

QString KGameMessage::messageId2Text ( int msgid)
static

This function takes a GameMessageIds as argument and returns a suitable string for it.

This string can't be used to identify a message (as it is i18n'ed) but it can make debugging more easy.

Returns
Either a i18n'ed string (the name of the id) or QString() if the msgid is unknown

Definition at line 95 of file kgamemessage.cpp.

◆ rawGameId()

quint32 KGameMessage::rawGameId ( quint32 playerid)
static

Returns the raw game id, that is, the game id the player belongs to.

Se also createPlayerId which is the inverse operation.

Parameters
playeridThe player id
Returns
The raw game id

Definition at line 29 of file kgamemessage.cpp.

◆ rawPlayerId()

int KGameMessage::rawPlayerId ( quint32 playerid)
static

Returns the raw playerid, that is, a id which does not contain the game number encoded in it.

See also createPlayerId which is the inverse operation.

Parameters
playeridThe player id
Returns
The raw player id

Definition at line 24 of file kgamemessage.cpp.

◆ version()

int KGameMessage::version ( )
static
Returns
Version of the network library

Definition at line 90 of file kgamemessage.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:59:04 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.