libkdegames/libkdegamesprivate/kgame
kgamenetwork.cpp
Go to the documentation of this file.
71 kDebug(11001) << "this=" << this <<", cookie=" << cookie() << "sizeof(this)="<<sizeof(KGameNetwork);
244 emit signalAdminStatusChanged(false); // as we delete the connection above isAdmin() is always false now!
397 bool KGameNetwork::sendSystemMessage(const QString &msg, int msgid, quint32 receiver, quint32 sender)
405 bool KGameNetwork::sendSystemMessage(const QDataStream &msg, int msgid, quint32 receiver, quint32 sender)
408 bool KGameNetwork::sendSystemMessage(const QByteArray& data, int msgid, quint32 receiver, quint32 sender)
456 bool KGameNetwork::sendMessage(const QDataStream &msg, int msgid, quint32 receiver, quint32 sender)
459 bool KGameNetwork::sendMessage(const QByteArray &msg, int msgid, quint32 receiver, quint32 sender)
462 void KGameNetwork::sendError(int error,const QByteArray& message, quint32 receiver, quint32 sender)
473 void KGameNetwork::receiveNetworkTransmission(const QByteArray& receiveBuffer, quint32 clientID)
void aboutToLoseConnection(quint32 id)
Called when the network connection is about to terminate.
Definition: kgamenetwork.cpp:335
KMessageServer * messageServer() const
Don't use this unless you really know what you are doing! You might experience some strange behaviour...
Definition: kgamenetwork.cpp:110
bool sendMessage(const QByteArray &buffer, int msgid, quint32 receiver=0, quint32 sender=0)
Send a network message msg with a given message ID msgid to all clients.
Definition: kgamenetwork.cpp:459
void signalConnectionBroken()
Our connection to the KMessageServer has broken.
Definition: kgamemessage.h:169
This class implements the message communication using a TCP/IP socket.
Definition: kmessageio.h:170
void sendError(int error, const QByteArray &message, quint32 receiver=0, quint32 sender=0)
Sends a network message.
Definition: kgamenetwork.cpp:462
void signalClientConnected(quint32 clientID)
This signal is emitted whenever the KMessageServer sends us a message that a new client connected...
QObject * sender() const
static bool isPlayer(quint32 id)
Checks whether a message receiver/sender is a player.
Definition: kgamemessage.cpp:45
void setDiscoveryInfo(const QString &type, const QString &name=QString())
Definition: kgamenetwork.cpp:150
void signalAdminStatusChanged(bool isAdmin)
This client gets or loses the admin status.
bool stopServerConnection()
Stops offering server connections - only for game MASTER.
Definition: kgamenetwork.cpp:271
static QString errorText(int errorCode, QDataStream &message)
Create an erorr text using a QDataStream (QByteArray) which was created using KGameError.
Definition: kgameerror.cpp:50
virtual void lock()
You should call this before doing thigs like, e.g.
Definition: kgamenetwork.cpp:373
bool connectToServer(const QString &host, quint16 port)
Inits a network game as a network CLIENT.
Definition: kgamenetwork.cpp:204
const char * name() const
static void createHeader(QDataStream &msg, quint32 sender, quint32 receiver, int msgid)
Creates a message header given cookie,sender,receiver,...
Definition: kgamemessage.cpp:60
bool isEmpty() const
This abstract base class represents one end of a message connections between two clients.
Definition: kmessageio.h:57
void electAdmin(quint32 clientID)
If you are the ADMIN of the game you can give the ADMIN status away to another client.
Definition: kgamenetwork.cpp:347
A server for message sending and broadcasting, using TCP/IP connections.
Definition: kmessageserver.h:175
KMessageClient * messageClient() const
Don't use this unless you really know what youre doing! You might experience some strange behaviour i...
Definition: kgamenetwork.cpp:107
bool isOfferingConnections() const
Are we still offer offering server connections - only for game MASTER.
Definition: kgamenetwork.cpp:282
iterator end()
bool isAdmin() const
The admin of a game is the one who initializes newly connected clients using negotiateNetworkGame and...
Definition: kgamenetwork.cpp:104
bool offerConnections(quint16 port)
Inits a network game as network MASTER.
Definition: kgamenetwork.cpp:174
void signalNetworkErrorMessage(int error, QString text)
A network error occurred.
virtual void networkTransmission(QDataStream &, int, quint32, quint32, quint32 clientID)=0
Called by ReceiveNetworkTransmission().
void setMaxClients(int max)
Changes the maximal connection number of the KMessageServer to max.
Definition: kgamenetwork.cpp:360
KGameNetwork(int cookie=42, QObject *parent=0)
Create a KGameNetwork object.
Definition: kgamenetwork.cpp:61
void lock()
Once this function is called no message will be received anymore.
Definition: kmessageclient.cpp:356
QByteArray toLatin1() const
void receiveNetworkTransmission(const QByteArray &a, quint32 clientID)
Called by KMessageClient::broadcastReceived() and will check if the message format is valid...
Definition: kgamenetwork.cpp:473
Definition: kgamemessage.h:161
static quint32 rawGameId(quint32 playerid)
Returns the raw game id, that is, the game id the player belongs to.
Definition: kgamemessage.cpp:40
void disconnect()
Disconnect the current connection and establish a new local one.
Definition: kgamenetwork.cpp:285
int writeRawData(const char *s, int len)
char * data()
void unlock()
Deliver every message that was delayed by lock() and actually deliver all messages that get received ...
Definition: kmessageclient.cpp:361
void slotResetConnection()
Called when the network connection is terminated.
Definition: kgamenetwork.cpp:341
QIODevice * device() const
int size() const
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
bool sendSystemMessage(const QByteArray &buffer, int msgid, quint32 receiver=0, quint32 sender=0)
Sends a network message msg with a given msg id msgid to all clients.
Definition: kgamenetwork.cpp:408
static void extractHeader(QDataStream &msg, quint32 &sender, quint32 &receiver, int &msgid)
Retrieves the information like cookie,sender,receiver,...
Definition: kgamemessage.cpp:65
static int rawPlayerId(quint32 playerid)
Returns the raw playerid, that is, a id which does not contain the game number encoded in it...
Definition: kgamemessage.cpp:35
void signalClientDisconnected(quint32 clientID, bool broken)
This signal is emitted whenever the KMessageServer sends us a message that a connection to a client w...
iterator begin()
void slotAdminStatusChanged(bool isAdmin)
This KGame object receives or loses the admin status.
Definition: kgamenetwork.cpp:510
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:54 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:54 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.