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

libkdegames/kggznet

KGGZRaw Class Reference

#include <kggzraw.h>

Inheritance diagram for KGGZRaw:

Inheritance graph
[legend]

List of all members.


Detailed Description

Communication interface to raw (non-quantized) binary communication.

The KGGZRaw class can be used to read and write binary data on a network stream. To use it, make the socket's file descriptor known to KGGZRaw through setNetwork, and connect the signalError signal to a slot just in case an error happens. Afterwards, read and write data at any time.

KGGZRaw implements the 'easysock' binary protocol from the GGZ Gaming Zone project. For alternative protocols, please have a look at the KGGZPacket class, or at http://dev.ggzgamingzone.org/protocols/.

From a developer point of view, this class should be used as a replacement for QDataStream on TCP/IP sockets for blocking read and write operations. It only covers the three basic data types supported by the easysock library, namely integers, characters and strings. All const char* strings are automatically converted to and from QStrings. Since the native format of serialized QStrings on QDataStream differs, the Qt behaviour can be restored with setFormat. In the context of GGZ games, this should however not be necessary.

Note: Blocking operations might freeze the GUI, so either use KGGZRaw in a separate thread only, or ensure that data can always be read (i.e. for local Unix socket operations).

Author:
Josef Spillner (josef@ggzgamingzone.org)

Definition at line 75 of file kggzraw.h.


Public Types

enum  Format { QtFormat, EasysockFormat }

Signals

void signalError ()

Public Member Functions

 KGGZRaw ()
 ~KGGZRaw ()
void setNetwork (int fd)
void setFormat (Format format)
KGGZRaw & operator<< (qint32 i)
KGGZRaw & operator<< (qint8 i)
KGGZRaw & operator<< (QString s)
KGGZRaw & operator>> (qint32 &i)
KGGZRaw & operator>> (qint8 &i)
KGGZRaw & operator>> (QString &s)

Member Enumeration Documentation

enum KGGZRaw::Format

Data serialization format.

The default format is EasysockFormat.

Enumerator:
QtFormat 
EasysockFormat 

Definition at line 99 of file kggzraw.h.


Constructor & Destructor Documentation

KGGZRaw::KGGZRaw (  ) 

Constructor.

Creates a new KGGZRaw object. It will remain unusable unless setNetwork is called.

Definition at line 50 of file kggzraw.cpp.

KGGZRaw::~KGGZRaw (  ) 

Destructor.

Destroys a KGGZRaw object.

Definition at line 57 of file kggzraw.cpp.


Member Function Documentation

void KGGZRaw::setNetwork ( int  fd  ) 

Specifies the socket file descriptor to use.

This function must be called exactly once before a KGGZRaw object can be used. Calling it more than once will result in an error. The socket must be a TCP/IP socket and already be opened. Usually, game clients will use KGGZRaw on the socket to the game server as returned by KGGZMod's Module object.

Parameters:
fd File descriptor of the underlying TCP/IP socket

Definition at line 71 of file kggzraw.cpp.

void KGGZRaw::setFormat ( Format  format  ) 

Changes the serialization format.

The format of the datatypes on the wire can be influenced by calling this method. However, this should not be necessary in most cases, since the EasysockFormat is used by default.

Parameters:
format Format to use for data serialization

Definition at line 66 of file kggzraw.cpp.

KGGZRaw & KGGZRaw::operator<< ( qint32  i  ) 

Definition at line 162 of file kggzraw.cpp.

KGGZRaw & KGGZRaw::operator<< ( qint8  i  ) 

Definition at line 172 of file kggzraw.cpp.

KGGZRaw & KGGZRaw::operator<< ( QString  s  ) 

Definition at line 182 of file kggzraw.cpp.

KGGZRaw & KGGZRaw::operator>> ( qint32 &  i  ) 

Definition at line 114 of file kggzraw.cpp.

KGGZRaw & KGGZRaw::operator>> ( qint8 &  i  ) 

Definition at line 126 of file kggzraw.cpp.

KGGZRaw & KGGZRaw::operator>> ( QString &  s  ) 

Definition at line 138 of file kggzraw.cpp.

void KGGZRaw::signalError (  )  [signal]

An error has occurred.

The game should destroy the KGGZRaw object and disable all networking activities associated with it.


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

libkdegames/kggznet

Skip menu "libkdegames/kggznet"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • 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