kgamenetwork.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __KGAMENETWORK_H_
00024 #define __KGAMENETWORK_H_
00025
00026 #include <qstring.h>
00027 #include <qobject.h>
00028
00029 class KGameIO;
00030 class KMessageClient;
00031 class KMessageServer;
00032
00033 class KGameNetworkPrivate;
00034
00046 class KGameNetwork : public QObject
00047 {
00048 Q_OBJECT
00049
00050 public:
00054 KGameNetwork(int cookie=42,QObject* parent=0);
00055 virtual ~KGameNetwork();
00056
00060 virtual void Debug();
00061
00066 bool isNetwork() const;
00067
00080 bool isMaster() const;
00081
00092 bool isAdmin() const;
00093
00099 Q_UINT32 gameId() const;
00100
00111 bool offerConnections (Q_UINT16 port);
00112
00121 bool connectToServer(const QString& host, Q_UINT16 port);
00122
00129 Q_UINT16 port() const;
00130
00137 QString hostName() const;
00138
00143 bool stopServerConnection();
00144
00155 void setMaxClients(int max);
00156
00157
00158
00159
00179
00180 bool sendSystemMessage(const QByteArray& buffer, int msgid, Q_UINT32 receiver=0, Q_UINT32 sender=0);
00181
00185 bool sendSystemMessage(int data, int msgid, Q_UINT32 receiver=0, Q_UINT32 sender=0);
00186
00190 bool sendSystemMessage(const QDataStream &msg, int msgid, Q_UINT32 receiver=0, Q_UINT32 sender=0);
00191
00195 bool sendSystemMessage(const QString& msg, int msgid, Q_UINT32 receiver=0, Q_UINT32 sender=0);
00196
00208 void sendError(int error, const QByteArray& message, Q_UINT32 receiver=0, Q_UINT32 sender=0);
00209
00214 bool isOfferingConnections() const;
00215
00221 int cookie() const;
00222
00255
00256 bool sendMessage(const QByteArray& buffer, int msgid, Q_UINT32 receiver=0, Q_UINT32 sender=0);
00257
00261 bool sendMessage(const QDataStream &msg, int msgid, Q_UINT32 receiver=0, Q_UINT32 sender=0);
00262
00266 bool sendMessage(const QString& msg, int msgid, Q_UINT32 receiver=0, Q_UINT32 sender=0);
00267
00271 bool sendMessage(int data, int msgid, Q_UINT32 receiver=0, Q_UINT32 sender=0);
00272
00273
00278 virtual void networkTransmission(QDataStream&, int, Q_UINT32, Q_UINT32, Q_UINT32 clientID) = 0;
00279
00280
00284 void disconnect();
00285
00286
00295 void electAdmin(Q_UINT32 clientID);
00296
00305 KMessageClient* messageClient() const;
00306
00315 KMessageServer* messageServer() const;
00316
00323 virtual void lock();
00324
00328 virtual void unlock();
00329
00330 signals:
00336 void signalNetworkErrorMessage(int error, QString text);
00337
00342 void signalConnectionBroken();
00343
00353 void signalClientConnected(Q_UINT32 clientID);
00354
00366 void signalClientDisconnected(Q_UINT32 clientID, bool broken);
00367
00373 void signalAdminStatusChanged(bool isAdmin);
00374
00375 protected:
00382 void setMaster();
00383
00384 protected slots:
00392 void receiveNetworkTransmission(const QByteArray& a, Q_UINT32 clientID);
00393
00398 void slotAdminStatusChanged(bool isAdmin);
00399
00404 void aboutToLoseConnection(Q_UINT32 id);
00405
00410 void slotResetConnection();
00411
00412
00413 private:
00414 KGameNetworkPrivate* d;
00415 };
00416
00417 #endif
This file is part of the documentation for libkdegames Library Version 3.2.2.