#include <kgamenetwork.h>
Inheritance diagram for KGameNetwork:


Signals | |
| void | signalNetworkErrorMessage (int error, QString text) |
| A network error occurred. | |
| void | signalConnectionBroken () |
| Our connection to the KMessageServer has broken. | |
| void | signalClientConnected (Q_UINT32 clientID) |
| This signal is emitted whenever the KMessageServer sends us a message that a new client connected. | |
| void | signalClientDisconnected (Q_UINT32 clientID, bool broken) |
| This signal is emitted whenever the KMessageServer sends us a message that a connection to a client was detached. | |
| void | signalAdminStatusChanged (bool isAdmin) |
| This client gets or loses the admin status. | |
Public Member Functions | |
| KGameNetwork (int cookie=42, QObject *parent=0) | |
| Create a KGameNetwork object. | |
| virtual | ~KGameNetwork () |
| virtual void | Debug () |
| Gives debug output of the game status. | |
| bool | isNetwork () const |
| bool | isMaster () const |
| Is this the game MASTER (i.e. | |
| bool | isAdmin () const |
| The admin of a game is the one who initializes newly connected clients using negotiateNetworkGame and is allowed to configure the game. | |
| Q_UINT32 | gameId () const |
| The unique ID of this game. | |
| bool | offerConnections (Q_UINT16 port) |
| Inits a network game as network MASTER. | |
| void | setDiscoveryInfo (const QString &type, const QString &name=QString::null) |
| Announces game MASTER on network using DNS-SD. | |
| bool | connectToServer (const QString &host, Q_UINT16 port) |
| Inits a network game as a network CLIENT. | |
| Q_UINT16 | port () const |
| QString | hostName () const |
| bool | stopServerConnection () |
| Stops offering server connections - only for game MASTER. | |
| void | setMaxClients (int max) |
| Changes the maximal connection number of the KMessageServer to max. | |
| bool | sendSystemMessage (const QByteArray &buffer, int msgid, Q_UINT32 receiver=0, Q_UINT32 sender=0) |
| Sends a network message msg with a given msg id msgid to all clients. | |
| bool | sendSystemMessage (int data, int msgid, Q_UINT32 receiver=0, Q_UINT32 sender=0) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| bool | sendSystemMessage (const QDataStream &msg, int msgid, Q_UINT32 receiver=0, Q_UINT32 sender=0) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| bool | sendSystemMessage (const QString &msg, int msgid, Q_UINT32 receiver=0, Q_UINT32 sender=0) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | sendError (int error, const QByteArray &message, Q_UINT32 receiver=0, Q_UINT32 sender=0) |
| Sends a network message. | |
| bool | isOfferingConnections () const |
| Are we still offer offering server connections - only for game MASTER. | |
| int | cookie () const |
| Application cookie. | |
| bool | sendMessage (const QByteArray &buffer, int msgid, Q_UINT32 receiver=0, Q_UINT32 sender=0) |
| Send a network message msg with a given message ID msgid to all clients. | |
| bool | sendMessage (const QDataStream &msg, int msgid, Q_UINT32 receiver=0, Q_UINT32 sender=0) |
| This is an overloaded member function, provided for convenience. | |
| bool | sendMessage (const QString &msg, int msgid, Q_UINT32 receiver=0, Q_UINT32 sender=0) |
| This is an overloaded member function, provided for convenience. | |
| bool | sendMessage (int data, int msgid, Q_UINT32 receiver=0, Q_UINT32 sender=0) |
| This is an overloaded member function, provided for convenience. | |
| virtual void | networkTransmission (QDataStream &, int, Q_UINT32, Q_UINT32, Q_UINT32 clientID)=0 |
| Called by ReceiveNetworkTransmission(). | |
| void | disconnect () |
| Disconnect the current connection and establish a new local one. | |
| void | electAdmin (Q_UINT32 clientID) |
| If you are the ADMIN of the game you can give the ADMIN status away to another client. | |
| KMessageClient * | messageClient () const |
| Don't use this unless you really know what youre doing! You might experience some strange behaviour if you send your messages directly through the KMessageClient! | |
| KMessageServer * | messageServer () const |
| Don't use this unless you really know what you are doing! You might experience some strange behaviour if you use the message server directly! | |
| virtual void | lock () |
| You should call this before doing thigs like, e.g. | |
| virtual void | unlock () |
Protected Slots | |
| void | receiveNetworkTransmission (const QByteArray &a, Q_UINT32 clientID) |
| Called by KMessageClient::broadcastReceived() and will check if the message format is valid. | |
| void | slotAdminStatusChanged (bool isAdmin) |
| This KGame object receives or loses the admin status. | |
| void | aboutToLoseConnection (Q_UINT32 id) |
| Called when the network connection is about to terminate. | |
| void | slotResetConnection () |
| Called when the network connection is terminated. | |
Protected Member Functions | |
| void | setMaster () |
All other features are the same but they are now network transparent. It is not used directly but only via a KGame object. So you do not really have to bother with this object.
Definition at line 46 of file kgamenetwork.h.
|
||||||||||||
|
Create a KGameNetwork object.
Definition at line 62 of file kgamenetwork.cpp. References cookie(), KGameNetworkPrivate::mCookie, and setMaster(). Here is the call graph for this function: ![]() |
|
|
Definition at line 74 of file kgamenetwork.cpp. References KGameNetworkPrivate::mService. |
|
|
Called when the network connection is about to terminate. Is used to store the network parameter like the game id Definition at line 323 of file kgamenetwork.cpp. References KGameNetworkPrivate::mDisconnectId. Referenced by setMaster(). |
|
||||||||||||
|
Inits a network game as a network CLIENT.
Definition at line 204 of file kgamenetwork.cpp. |
|
|
Application cookie. this idendifies the game application. It help to distinguish between e.g. KPoker and KWin4
Definition at line 98 of file kgamenetwork.cpp. References KGameNetworkPrivate::mCookie. Referenced by KGameNetwork(), KGame::loadgame(), KGame::negotiateNetworkGame(), KGame::savegame(), setMaster(), and KGameDebugDialog::slotUpdateGameData(). |
|
|
Gives debug output of the game status.
Reimplemented in KGame. Definition at line 505 of file kgamenetwork.cpp. References gameId(), isAdmin(), and isMaster(). Referenced by KGame::Debug(). Here is the call graph for this function: ![]() |
|
|
Disconnect the current connection and establish a new local one.
Definition at line 273 of file kgamenetwork.cpp. References KMessageServer::clientIDs(), KMessageServer::findClient(), KGameNetworkPrivate::mMessageServer, KMessageServer::removeClient(), KMessageIO::rtti(), and stopServerConnection(). Referenced by KGameDialogNetworkConfig::slotExitConnection(). Here is the call graph for this function: ![]() |
|
|
If you are the ADMIN of the game you can give the ADMIN status away to another client. Use this e.g. if you want to quit the game or if you want another client to administrate the game (note that disconnect calls this automatically).
Definition at line 335 of file kgamenetwork.cpp. References isAdmin(), KGameNetworkPrivate::mMessageClient, KMessageServer::REQ_ADMIN_CHANGE, and KMessageClient::sendServerMessage(). Referenced by KGameDialogMsgServerConfig::slotChangeAdmin(). Here is the call graph for this function: ![]() |
|
|
The unique ID of this game.
Definition at line 86 of file kgamenetwork.cpp. References KMessageClient::id(), and KGameNetworkPrivate::mMessageClient. Referenced by KGame::addPlayer(), Debug(), KPlayer::networkTransmission(), receiveNetworkTransmission(), sendSystemMessage(), KGame::slotServerDisconnected(), and KGameDebugDialog::slotUpdateGameData(). Here is the call graph for this function: ![]() |
|
|
Definition at line 254 of file kgamenetwork.cpp. References KGameNetworkPrivate::mMessageClient, and KMessageClient::peerName(). Here is the call graph for this function: ![]() |
|
|
The admin of a game is the one who initializes newly connected clients using negotiateNetworkGame and is allowed to configure the game. E.g. only the admin is allowed to use KGame::setMaxPlayers. If one KGame object in the game is MASTER then this client is the admin as well. isMaster and isAdmin differ only if the KMessageServer is running in an own process.
Definition at line 104 of file kgamenetwork.cpp. References KMessageClient::isAdmin(), and KGameNetworkPrivate::mMessageClient. Referenced by KGameDialog::addConfigWidget(), Debug(), electAdmin(), KGame::negotiateNetworkGame(), setMaxClients(), KGame::setMaxPlayers(), KGame::setMinPlayers(), KGame::slotClientConnected(), and KGameDebugDialog::slotUpdateGameData(). Here is the call graph for this function: ![]() |
|
|
Is this the game MASTER (i.e. has started theKMessageServer). A game has always exactly one MASTER. This is either a KGame object (i.e. a Client) or an own MessageServer-process. A KGame object that has the MASTER status is always admin. You probably don't want to use this. It is a mostly internal method which will probably become protected. Better use isAdmin
Definition at line 101 of file kgamenetwork.cpp. References KGameNetworkPrivate::mMessageServer. Referenced by Debug(), offerConnections(), and KGameDebugDialog::slotUpdateGameData(). |
|
|
Definition at line 83 of file kgamenetwork.cpp. References KMessageClient::isNetwork(), isOfferingConnections(), and KGameNetworkPrivate::mMessageClient. Referenced by port(). Here is the call graph for this function: ![]() |
|
|
Are we still offer offering server connections - only for game MASTER.
Definition at line 270 of file kgamenetwork.cpp. References KMessageServer::isOfferingConnections(), and KGameNetworkPrivate::mMessageServer. Referenced by isNetwork(), port(), and KGameDebugDialog::slotUpdateGameData(). Here is the call graph for this function: ![]() |
|
|
You should call this before doing thigs like, e.g. qApp->processEvents(). Don't forget to call unlock once you are done!
Definition at line 361 of file kgamenetwork.cpp. References KMessageClient::lock(), and messageClient(). Here is the call graph for this function: ![]() |
|
|
Don't use this unless you really know what youre doing! You might experience some strange behaviour if you send your messages directly through the KMessageClient!
Definition at line 107 of file kgamenetwork.cpp. References KGameNetworkPrivate::mMessageClient. |
|
|
Don't use this unless you really know what you are doing! You might experience some strange behaviour if you use the message server directly!
Definition at line 110 of file kgamenetwork.cpp. References KGameNetworkPrivate::mMessageServer. |
|
||||||||||||||||||||||||
|
Called by ReceiveNetworkTransmission(). Will be overwritten by KGame and handle the incoming message. Implemented in KGame. Referenced by receiveNetworkTransmission(). |
|
|
Inits a network game as network MASTER. Note that if the KMessageServer is not yet started it will be started here (see setMaster). Any existing connection will be disconnected. If you already offer connections the port is changed.
Definition at line 174 of file kgamenetwork.cpp. References isMaster(), KMessageServer::isOfferingConnections(), KGameNetworkPrivate::mDisconnectId, KGameNetworkPrivate::mMessageServer, and setMaster(). Referenced by KGameDialogNetworkConfig::slotInitConnection(). Here is the call graph for this function: ![]() |
|
|
Definition at line 242 of file kgamenetwork.cpp. References isNetwork(), isOfferingConnections(), KGameNetworkPrivate::mMessageClient, KGameNetworkPrivate::mMessageServer, KMessageClient::peerPort(), and KMessageServer::serverPort(). Here is the call graph for this function: ![]() |
|
||||||||||||
|
Called by KMessageClient::broadcastReceived() and will check if the message format is valid. If it is not, it will generate an error (see signalNetworkVersionError and signalNetworkErorrMessage). If it is valid, the pure virtual method networkTransmission() is called. (This one is overwritten in KGame.) Definition at line 461 of file kgamenetwork.cpp. References KGameError::errorText(), KGameMessage::extractHeader(), gameId(), KGameMessage::IdError, KGameMessage::isPlayer(), networkTransmission(), KGameMessage::rawGameId(), and signalNetworkErrorMessage(). Referenced by setMaster(). |
|
||||||||||||||||||||
|
Sends a network message.
Definition at line 450 of file kgamenetwork.cpp. References KGameMessage::IdError, and sendSystemMessage(). Here is the call graph for this function: ![]() |
|
||||||||||||||||||||
|
This is an overloaded member function, provided for convenience.
Definition at line 438 of file kgamenetwork.cpp. References KGameMessage::IdUser, and sendSystemMessage(). Here is the call graph for this function: ![]() |
|
||||||||||||||||||||
|
This is an overloaded member function, provided for convenience.
Definition at line 441 of file kgamenetwork.cpp. References KGameMessage::IdUser, and sendSystemMessage(). Here is the call graph for this function: ![]() |
|
||||||||||||||||||||
|
This is an overloaded member function, provided for convenience.
Definition at line 444 of file kgamenetwork.cpp. References KGameMessage::IdUser, and sendSystemMessage(). Here is the call graph for this function: ![]() |
|
||||||||||||||||||||
|
Send a network message msg with a given message ID msgid to all clients. You want to use this to send a message to the clients. Note that a message is always sent to ALL clients! This is necessary so that all clients always have the same data and can easily be changed from network to non-network without restarting the game. If you want a specific KGame / KPlayer to react to the message use the receiver and sender parameters. See KGameMessage::calsMessageId SendMessage differs from sendSystemMessage only by the msgid parameter. sendSystemMessage is thought as a KGame only mehtod while sendMessage is for public use. The msgid parameter will be +=KGameMessageIdUser and in KGame::signalNetworkData msgid will be -= KGameMessage::IdUser again, so that one can easily distinguish between system and user messages. Use sendSystemMessage to comunicate with KGame (e.g. by adding a player) and sendMessage for your own user message. Note: a player should send messages through a KGameIO!
Definition at line 447 of file kgamenetwork.cpp. References KGameMessage::IdUser, and sendSystemMessage(). Referenced by KGameChat::returnPressed(), and KGame::sendGroupMessage(). Here is the call graph for this function: ![]() |
|
||||||||||||||||||||
|
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 385 of file kgamenetwork.cpp. References sendSystemMessage(). Here is the call graph for this function: ![]() |
|
||||||||||||||||||||
|
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 393 of file kgamenetwork.cpp. References sendSystemMessage(). Here is the call graph for this function: ![]() |
|
||||||||||||||||||||
|
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 377 of file kgamenetwork.cpp. References sendSystemMessage(). Here is the call graph for this function: ![]() |
|
||||||||||||||||||||
|
Sends a network message msg with a given msg id msgid to all clients. Use this to communicate with KGame (e.g. to add a player ot to configure the game - usually not necessary). For your own messages use sendMessage instead! This is mostly internal!
Definition at line 396 of file kgamenetwork.cpp. References KGameMessage::createHeader(), gameId(), KGameNetworkPrivate::mMessageClient, KGameMessage::rawGameId(), KGameMessage::rawPlayerId(), KMessageClient::sendBroadcast(), and KMessageClient::sendForward(). Referenced by KGame::activatePlayer(), KPlayer::forwardMessage(), KGame::inactivatePlayer(), KGame::negotiateNetworkGame(), KGame::playerDeleted(), sendError(), sendMessage(), KGame::sendPlayerInput(), KGame::sendPlayerProperty(), KGame::sendProperty(), sendSystemMessage(), and KGame::syncRandom(). Here is the call graph for this function: ![]() |
|
||||||||||||
|
Announces game MASTER on network using DNS-SD. Clients then can discover it using DNSSD::ServiceBrowser (or KGameConnectWidget) instead of manually entering IP address.
Definition at line 150 of file kgamenetwork.cpp. References KGameNetworkPrivate::mName, and KGameNetworkPrivate::mType. Referenced by KGameDialogNetworkConfig::slotInitConnection(). |
|
|
Definition at line 114 of file kgamenetwork.cpp. References aboutToLoseConnection(), cookie(), KGameNetworkPrivate::mMessageClient, KGameNetworkPrivate::mMessageServer, receiveNetworkTransmission(), KMessageClient::setServer(), signalClientConnected(), signalClientDisconnected(), signalConnectionBroken(), slotAdminStatusChanged(), and slotResetConnection(). Referenced by KGameNetwork(), and offerConnections(). Here is the call graph for this function: ![]() |
|
|
Changes the maximal connection number of the KMessageServer to max. -1 Means infinite connections are possible. Note that existing connections are not affected, so even if you set this to 0 in a running game no client is being disconnected. You can call this only if you are the ADMIN!
Definition at line 348 of file kgamenetwork.cpp. References isAdmin(), KGameNetworkPrivate::mMessageClient, KMessageServer::REQ_MAX_NUM_CLIENTS, and KMessageClient::sendServerMessage(). Referenced by KGameDialogMsgServerConfig::slotChangeMaxClients(). Here is the call graph for this function: ![]() |
|
|
This client gets or loses the admin status.
Referenced by slotAdminStatusChanged(). |
|
|
This signal is emitted whenever the KMessageServer sends us a message that a new client connected. KGame uses this to call KGame::negotiateNetworkGame for the newly connected client if we are admin (see isAdmin)
Referenced by KGame::KGame(), and setMaster(). |
|
||||||||||||
|
This signal is emitted whenever the KMessageServer sends us a message that a connection to a client was detached. The second parameter can be used to distinguish between network errors or removing on purpose.
Referenced by KGame::KGame(), and setMaster(). |
|
|
Our connection to the KMessageServer has broken. See KMessageClient::connectionBroken Referenced by KGame::KGame(), and setMaster(). |
|
||||||||||||
|
A network error occurred.
Referenced by receiveNetworkTransmission(). |
|
|
This KGame object receives or loses the admin status.
Definition at line 498 of file kgamenetwork.cpp. References signalAdminStatusChanged(). Referenced by setMaster(). |
|
|
Called when the network connection is terminated. Used to clean up the disconnect parameter Definition at line 329 of file kgamenetwork.cpp. References KGameNetworkPrivate::mDisconnectId. Referenced by setMaster(). |
|
|
Stops offering server connections - only for game MASTER.
Definition at line 259 of file kgamenetwork.cpp. References KGameNetworkPrivate::mMessageServer, and KMessageServer::stopNetwork(). Referenced by disconnect(). Here is the call graph for this function: ![]() |
|
|
Definition at line 368 of file kgamenetwork.cpp. References messageClient(), and KMessageClient::unlock(). Here is the call graph for this function: ![]() |
1.4.6