KDEGames
kgamenetwork.cpp
56 qCDebug(GAMES_PRIVATE_KGAME) << "this=" << this <<", cookie=" << cookie() << "sizeof(this)="<<sizeof(KGameNetwork);
107 connect(d->mMessageClient, &KMessageClient::broadcastReceived, this, &KGameNetwork::receiveNetworkTransmission);
108 connect(d->mMessageClient, &KMessageClient::connectionBroken, this, &KGameNetwork::signalConnectionBroken);
109 connect(d->mMessageClient, &KMessageClient::aboutToDisconnect, this, &KGameNetwork::aboutToLoseConnection);
110 connect(d->mMessageClient, &KMessageClient::connectionBroken, this, &KGameNetwork::slotResetConnection);
112 connect(d->mMessageClient, &KMessageClient::adminStatusChanged, this, &KGameNetwork::slotAdminStatusChanged);
113 connect(d->mMessageClient, &KMessageClient::eventClientConnected, this, &KGameNetwork::signalClientConnected);
114 connect(d->mMessageClient, &KMessageClient::eventClientDisconnected, this, &KGameNetwork::signalClientDisconnected);
210 qCWarning(GAMES_PRIVATE_KGAME) << "we are server but we are trying to connect to another server! "
221 Q_EMIT signalAdminStatusChanged(false); // as we delete the connection above isAdmin() is always false now!
374 bool KGameNetwork::sendSystemMessage(const QString &msg, int msgid, quint32 receiver, quint32 sender)
382 bool KGameNetwork::sendSystemMessage(const QDataStream &msg, int msgid, quint32 receiver, quint32 sender)
385 bool KGameNetwork::sendSystemMessage(const QByteArray& data, int msgid, quint32 receiver, quint32 sender)
433 bool KGameNetwork::sendMessage(const QDataStream &msg, int msgid, quint32 receiver, quint32 sender)
436 bool KGameNetwork::sendMessage(const QByteArray &msg, int msgid, quint32 receiver, quint32 sender)
439 void KGameNetwork::sendError(int error,const QByteArray& message, quint32 receiver, quint32 sender)
450 void KGameNetwork::receiveNetworkTransmission(const QByteArray& receiveBuffer, quint32 clientID)
void slotResetConnection()
Called when the network connection is terminated.
Definition: kgamenetwork.cpp:318
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:248
Definition: kmessageio.h:51
KMessageClient * messageClient() const
Don't use this unless you really know what you're doing! You might experience some strange behaviour ...
Definition: kgamenetwork.cpp:91
WriteOnly
void forwardReceived(const QByteArray &msg, quint32 senderID, const QList< quint32 > &receivers)
This signal is emitted when the client receives a forward message from the KMessageServer,...
int size() const const
Q_EMITQ_EMIT
KMessageServer * messageServer() const
Don't use this unless you really know what you are doing! You might experience some strange behaviour...
Definition: kgamenetwork.cpp:94
void connectionBroken()
This signal is emitted when the connection to the KMessageServer is broken.
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:436
QIODevice * device() const const
QObject * sender() const const
void signalConnectionBroken()
Our connection to the KMessageServer has broken.
void aboutToLoseConnection(quint32 id)
Called when the network connection is about to terminate.
Definition: kgamenetwork.cpp:312
QByteArray toLatin1() const const
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:324
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void sendError(int error, const QByteArray &message, quint32 receiver=0, quint32 sender=0)
Sends a network message.
Definition: kgamenetwork.cpp:439
void eventClientDisconnected(quint32 clientID, bool broken)
This signal is emitted when the server has lost the connection to one of the clients (This could be b...
void unlock()
Deliver every message that was delayed by lock() and actually deliver all messages that get received ...
Definition: kmessageclient.cpp:347
KGameNetwork(int cookie=42, QObject *parent=nullptr)
Create a KGameNetwork object.
Definition: kgamenetwork.cpp:46
Definition: kmessageio.h:164
int writeRawData(const char *s, int len)
bool connectToServer(const QString &host, quint16 port)
Inits a network game as a network CLIENT.
Definition: kgamenetwork.cpp:181
virtual void lock()
You should call this before doing thigs like, e.g.
Definition: kgamenetwork.cpp:350
void adminStatusChanged(bool isAdmin)
This signal is emitted when this client becomes the admin client or when it loses the admin client st...
void signalNetworkErrorMessage(int error, const QString &text)
A network error occurred.
void disconnect()
Disconnect the current connection and establish a new local one.
Definition: kgamenetwork.cpp:262
ScriptableExtension * host() const
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:385
void lock()
Once this function is called no message will be received anymore.
Definition: kmessageclient.cpp:342
void signalClientDisconnected(quint32 clientID, bool broken)
This signal is emitted whenever the KMessageServer sends us a message that a connection to a client w...
bool isAdmin() const
The admin of a game is the one who initializes newly connected clients using negotiateNetworkGame and...
Definition: kgamenetwork.cpp:88
QList::iterator begin()
int size() const const
QChar * data()
void slotAdminStatusChanged(bool isAdmin)
This KGame object receives or loses the admin status.
Definition: kgamenetwork.cpp:487
bool offerConnections(quint16 port)
Inits a network game as network MASTER.
Definition: kgamenetwork.cpp:151
void setMaxClients(int max)
Changes the maximal connection number of the KMessageServer to max.
Definition: kgamenetwork.cpp:337
void eventClientConnected(quint32 clientID)
This signal is emitted when another client has connected to the server.
A server for message sending and broadcasting, using TCP/IP connections.
Definition: kmessageserver.h:167
virtual void networkTransmission(QDataStream &, int, quint32, quint32, quint32 clientID)=0
Called by ReceiveNetworkTransmission().
QList::iterator end()
void aboutToDisconnect(quint32 id)
This signal is emitted right before the client disconnects.
void signalClientConnected(quint32 clientID)
This signal is emitted whenever the KMessageServer sends us a message that a new client connected.
void receiveNetworkTransmission(const QByteArray &a, quint32 clientID)
Called by KMessageClient::broadcastReceived() and will check if the message format is valid.
Definition: kgamenetwork.cpp:450
QString message
void broadcastReceived(const QByteArray &msg, quint32 senderID)
This signal is emitted when the client receives a broadcast message from the KMessageServer,...
char * data()
bool isOfferingConnections() const
Are we still offer offering server connections - only for game MASTER.
Definition: kgamenetwork.cpp:259
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu May 26 2022 04:04:05 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu May 26 2022 04:04:05 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.