libkdegames/kggznet
KGGZPacket Class Reference
#include <kggzpacket.h>

Detailed Description
Communication interface to packet (quantized) binary communication.The KGGZPacket class can be used to read and write binary data on a network stream. To use it, connect any signal which reports file descriptor activity to slotNetwork, or call this method manually with the file descriptor as its argument every time traffic arrives on the corresponding socket. Next, connect the signalPacket signal to a slot in your application. Finally, start writing data to the outputstream (calling flush whenever a packet is done), and start reading data whenever the signalPacket signal is sent from the inputstream.
KGGZPacket implements the 'dio' binary protocol from the GGZ Gaming Zone project. For alternative protocols, please have a look at the KGGZRaw class, or at http://dev.ggzgamingzone.org/protocols/.
Note: Using KGGZPacket implies nonblocking operations, so it is safe to use this class in a single-threaded GUI application. The drawback for this convenience (as opposed to KGGZRaw) is that slightly more traffic is caused on the network.
Definition at line 54 of file kggzpacket.h.
Public Slots | |
| void | slotNetwork (int fd) |
Signals | |
| void | signalPacket () |
Public Member Functions | |
| void | flush () |
| QDataStream * | inputstream () |
| KGGZPacket () | |
| QDataStream * | outputstream () |
| ~KGGZPacket () | |
Constructor & Destructor Documentation
| KGGZPacket::KGGZPacket | ( | ) |
Constructor.
Creates a new KGGZPacket object. It will remain unusable unless slotNetwork is called.
Definition at line 27 of file kggzpacket.cpp.
| KGGZPacket::~KGGZPacket | ( | ) |
Destructor.
Destroys a KGGZPacket object. All unflushed data is flushed before the object is destroyed.
Definition at line 35 of file kggzpacket.cpp.
Member Function Documentation
| void KGGZPacket::flush | ( | ) |
Flushes pending output data.
This method finishes up a pending packet and sends it out over the active connection.
Definition at line 54 of file kggzpacket.cpp.
| QDataStream * KGGZPacket::inputstream | ( | ) |
The stream for reading data from.
Data can safely be read from this stream whenever signalPacket was emitted. No reading should be done in other situations.
- Returns:
- Input stream to read data from
Definition at line 44 of file kggzpacket.cpp.
| QDataStream * KGGZPacket::outputstream | ( | ) |
The stream to write data to.
Data can be written at any time. A new packet is created automatically and must always be finished with flush.
- Returns:
- Output stream to write data to
Definition at line 49 of file kggzpacket.cpp.
| void KGGZPacket::signalPacket | ( | ) | [signal] |
A new packet has arrived.
This signal gets emitted whenever slotNetwork is called and a whole packet can be read through it.
| void KGGZPacket::slotNetwork | ( | int | fd | ) | [slot] |
Network activity monitor.
This method must be called whenever network activity is happening on the specified socket file descriptor. In many cases, signalPacket will then be emitted.
- Parameters:
-
fd File descriptor for the monitored socket
Definition at line 67 of file kggzpacket.cpp.
The documentation for this class was generated from the following files:
KDE 4.1 API Reference