diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:42:31 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:42:31 +0000 |
commit | 576eb4299a00bc053db35414406f46372a0f70f2 (patch) | |
tree | 4c030922d533821db464af566188e7d40cc8848c /libkdegames/kgame/kmessageserver.h | |
parent | 0718336b6017d1a4fc1d626544180a5a2a29ddec (diff) | |
download | tdegames-576eb4299a00bc053db35414406f46372a0f70f2.tar.gz tdegames-576eb4299a00bc053db35414406f46372a0f70f2.zip |
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1157643 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'libkdegames/kgame/kmessageserver.h')
-rw-r--r-- | libkdegames/kgame/kmessageserver.h | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/libkdegames/kgame/kmessageserver.h b/libkdegames/kgame/kmessageserver.h index 0049a2e7..3d0b1055 100644 --- a/libkdegames/kgame/kmessageserver.h +++ b/libkdegames/kgame/kmessageserver.h @@ -20,10 +20,10 @@ #ifndef __KMESSAGESERVER_H__ #define __KMESSAGESERVER_H__ -#include <qobject.h> -#include <qserversocket.h> -#include <qstring.h> -#include <qvaluelist.h> +#include <tqobject.h> +#include <tqserversocket.h> +#include <tqstring.h> +#include <tqvaluelist.h> class KMessageIO; class KMessageServerPrivate; @@ -42,7 +42,7 @@ class KMessageServerPrivate; KMessageDirect.) This object already has to be connected. The messages are always packages of an arbitrary length. The format of the messages - is given below. All the data is stored and received with QDataStream, to be + is given below. All the data is stored and received with TQDataStream, to be platform independant. Setting up a KMessageServer can be done like this: @@ -72,53 +72,53 @@ class KMessageServerPrivate; This is always interpreted as the admin client, independant of its real clientID. Here is a list of the messages the KMessageServer understands: - << means, the value is inserted into the QByteArray using QDataStream. The + << means, the value is inserted into the TQByteArray using TQDataStream. The messageIDs (REQ_BROADCAST, ...) are of type Q_UINT32. - - QByteArray << static_cast<Q_UINT32>( REQ_BROADCAST ) << raw_data + - TQByteArray << static_cast<Q_UINT32>( REQ_BROADCAST ) << raw_data When the server receives this message, it sends the following message to ALL connected clients (a broadcast), where the raw_data is left unchanged: - QByteArray << static_cast <Q_UINT32>( MSG_BROADCAST ) << clientID << raw_data + TQByteArray << static_cast <Q_UINT32>( MSG_BROADCAST ) << clientID << raw_data Q_UINT32 clientID; // the ID of the client that sent the broadcast request - - QByteArray << static_cast<Q_UINT32>( REQ_FORWARD ) << client_list << raw_data - QValueList <Q_UINT32> client_list; // list of receivers + - TQByteArray << static_cast<Q_UINT32>( REQ_FORWARD ) << client_list << raw_data + TQValueList <Q_UINT32> client_list; // list of receivers When the server receives this message, it sends the following message to the clients in client_list: - QByteArray << static_cast<Q_UINT32>( MSG_FORWARD ) << senderID << client_list << raw_data + TQByteArray << static_cast<Q_UINT32>( MSG_FORWARD ) << senderID << client_list << raw_data Q_UINT32 senderID; // the sender of the forward request - QValueList <Q_UINT32> client_list; // a copy of the receiver list + TQValueList <Q_UINT32> client_list; // a copy of the receiver list Note: Every client receives the message as many times as he is in the client_list. Note: Since the client_list is sent to all the clients, every client can see who else got the message. If you want to prevent this, send a single REQ_FORWARD message for every receiver. - - QByteArray << static_cast<Q_UINT32>( REQ_CLIENT_ID ) + - TQByteArray << static_cast<Q_UINT32>( REQ_CLIENT_ID ) When the server receives this message, it sends the following message to the asking client: - QByteArray << static_cast<Q_UINT32>( ANS_CLIENT_ID ) << clientID + TQByteArray << static_cast<Q_UINT32>( ANS_CLIENT_ID ) << clientID Q_UINT32 clientID; // The ID of the client who asked for it Note: This answer is also automatically sent to a new connected client, so that he can store his ID. The ID of a client doesn't change during his lifetime, and is unique for this KMessageServer. - - QByteArray << static_cast<Q_UINT32>( REQ_ADMIN_ID ) + - TQByteArray << static_cast<Q_UINT32>( REQ_ADMIN_ID ) When the server receives this message, it sends the following message to the asking client: - QByteArray << ANS_ADMIN_ID << adminID + TQByteArray << ANS_ADMIN_ID << adminID Q_UINT32 adminID; // The ID of the admin Note: This answer is also automatically sent to a new connected client, so that he can see if he is the admin or not. It will also be sent to all connected clients when a new admin is set (see REQ_ADMIN_CHANGE). - - QByteArray << static_cast<Q_UINT32>( REQ_ADMIN_CHANGE ) << new_admin + - TQByteArray << static_cast<Q_UINT32>( REQ_ADMIN_CHANGE ) << new_admin Q_UINT32 new_admin; // the ID of the new admin, or 0 for no admin When the server receives this message, it sets the admin to the new ID. If no client @@ -127,8 +127,8 @@ class KMessageServerPrivate; Note: The server sends a ANS_ADMIN_ID message to every connected client. - - QByteArray << static_cast<Q_UINT32>( REQ_REMOVE_CLIENT ) << client_list - QValueList <Q_UINT32> client_list; // The list of clients to be removed + - TQByteArray << static_cast<Q_UINT32>( REQ_REMOVE_CLIENT ) << client_list + TQValueList <Q_UINT32> client_list; // The list of clients to be removed When the server receives this message, it removes the clients with the ids stored in client_list, disconnecting the connection to them. @@ -137,7 +137,7 @@ class KMessageServerPrivate; Note: If one of the clients is the admin himself, he will also be deleted. Another client (if any left) will become the new admin. - - QByteArray << static_cast<Q_UINT32>( REQ_MAX_NUM_CLIENTS ) << maximum_clients + - TQByteArray << static_cast<Q_UINT32>( REQ_MAX_NUM_CLIENTS ) << maximum_clients Q_INT32 maximum_clients; // The maximum of clients connected, or infinite if -1 When the server receives this message, it limits the number of clients to the number given, @@ -147,12 +147,12 @@ class KMessageServerPrivate; Note: If there are already more clients, they are not affected. It only prevents new Clients to be added. To assure this limit, remove clients afterwards (REQ_REMOVE_CLIENT) - - QByteArray << static_cast<Q_UINT32>( REQ_CLIENT_LIST ) + - TQByteArray << static_cast<Q_UINT32>( REQ_CLIENT_LIST ) When the server receives this message, it answers by sending a list of IDs of all the clients that are connected at the moment. So it sends the following message to the asking client: - QByteArray << static_cast<Q_UINT32>( ANS_CLIENT_LIST ) << clientList - QValueList <Q_UINT32> clientList; // The IDs of the connected clients + TQByteArray << static_cast<Q_UINT32>( ANS_CLIENT_LIST ) << clientList + TQValueList <Q_UINT32> clientList; // The IDs of the connected clients Note: This message is also sent to every new connected client, so that he knows the other clients. @@ -160,10 +160,10 @@ class KMessageServerPrivate; There are two more messages that are sent from the server to the every client automatically when a new client connects or a connection to a client is lost: - QByteArray << static_cast<Q_UINT32>( EVNT_CLIENT_CONNECTED ) << clientID; + TQByteArray << static_cast<Q_UINT32>( EVNT_CLIENT_CONNECTED ) << clientID; Q_UINT32 clientID; // the ID of the new connected client - QByteArray << static_cast<Q_UINT32>( EVNT_CLIENT_DISCONNECTED ) << clientID; + TQByteArray << static_cast<Q_UINT32>( EVNT_CLIENT_DISCONNECTED ) << clientID; Q_UINT32 clientID; // the ID of the client that lost the connection Q_UINT8 broken; // 1 if the network connection was closed, 0 if it was disconnected // on purpose @@ -208,7 +208,7 @@ public: /** * Create a KGameNetwork object **/ - KMessageServer(Q_UINT16 cookie = 42, QObject* parent = 0); + KMessageServer(Q_UINT16 cookie = 42, TQObject* parent = 0); ~KMessageServer(); @@ -325,7 +325,7 @@ public: /** * returns a list of the unique IDs of all clients. **/ - QValueList <Q_UINT32> clientIDs() const; + TQValueList <Q_UINT32> clientIDs() const; /** * Find the @ref KMessageIO object to the given client number. @@ -375,7 +375,7 @@ public: * The message is NOT translated in any way. This method calls * @ref KMessageIO::send for every client added. **/ - virtual void broadcastMessage (const QByteArray &msg); + virtual void broadcastMessage (const TQByteArray &msg); /** * Sends a message to a single client with the given ID. @@ -385,7 +385,7 @@ public: * @ref findClient (id)->send(msg) manually, but this method checks for * errors. **/ - virtual void sendMessage (Q_UINT32 id, const QByteArray &msg); + virtual void sendMessage (Q_UINT32 id, const TQByteArray &msg); /** * Sends a message to a list of clients. Their ID is given in ids. If @@ -394,7 +394,7 @@ public: * This is just a convenience method. You could also iterate over the * list of IDs. **/ - virtual void sendMessage (const QValueList <Q_UINT32> &ids, const QByteArray &msg); + virtual void sendMessage (const TQValueList <Q_UINT32> &ids, const TQByteArray &msg); protected slots: /** @@ -406,7 +406,7 @@ protected slots: * @ref KMessageIO::received, since the sender() object is used to find out * the client that sent the message! **/ - virtual void getReceivedMessage (const QByteArray &msg); + virtual void getReceivedMessage (const TQByteArray &msg); /** * This slot is called whenever there are elements in the message queue. This queue @@ -448,7 +448,7 @@ signals: * @param clientID the ID of the KMessageIO object that received the message * @param unknown true, if the message type is not known by the KMessageServer **/ - void messageReceived (const QByteArray &data, Q_UINT32 clientID, bool &unknown); + void messageReceived (const TQByteArray &data, Q_UINT32 clientID, bool &unknown); protected: /** @@ -468,7 +468,7 @@ private: connections. NOTE: This has to be here in the header file, because it is a subclass from - QObject and has to go through the moc. + TQObject and has to go through the moc. @short An internal class for KServerSocket @author Burkhard Lehner <[email protected]> @@ -478,7 +478,7 @@ class KMessageServerSocket : public QServerSocket Q_OBJECT public: - KMessageServerSocket (Q_UINT16 port, QObject *parent = 0); + KMessageServerSocket (Q_UINT16 port, TQObject *parent = 0); ~KMessageServerSocket (); void newConnection (int socket); |