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 #include <kdemacros.h>
00029 class KGameIO;
00030 class KMessageClient;
00031 class KMessageServer;
00032
00033 class KGameNetworkPrivate;
00034
00046 class KDE_EXPORT 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
00113 void setDiscoveryInfo(const QString& type, const QString& name=QString::null);
00114
00123 bool connectToServer(const QString& host, Q_UINT16 port);
00124
00131 Q_UINT16 port() const;
00132
00139 QString hostName() const;
00140
00145 bool stopServerConnection();
00146
00157 void setMaxClients(int max);
00158
00159
00160
00161
00181
00182 bool sendSystemMessage(const QByteArray& buffer, int msgid, Q_UINT32 receiver=0, Q_UINT32 sender=0);
00183
00187 bool sendSystemMessage(int data, int msgid, Q_UINT32 receiver=0, Q_UINT32 sender=0);
00188
00192 bool sendSystemMessage(const QDataStream &msg, int msgid, Q_UINT32 receiver=0, Q_UINT32 sender=0);
00193
00197 bool sendSystemMessage(const QString& msg, int msgid, Q_UINT32 receiver=0, Q_UINT32 sender=0);
00198
00210 void sendError(int error, const QByteArray& message, Q_UINT32 receiver=0, Q_UINT32 sender=0);
00211
00216 bool isOfferingConnections() const;
00217
00223 int cookie() const;
00224
00257
00258 bool sendMessage(const QByteArray& buffer, int msgid, Q_UINT32 receiver=0, Q_UINT32 sender=0);
00259
00263 bool sendMessage(const QDataStream &msg, int msgid, Q_UINT32 receiver=0, Q_UINT32 sender=0);
00264
00268 bool sendMessage(const QString& msg, int msgid, Q_UINT32 receiver=0, Q_UINT32 sender=0);
00269
00273 bool sendMessage(int data, int msgid, Q_UINT32 receiver=0, Q_UINT32 sender=0);
00274
00275
00280 virtual void networkTransmission(QDataStream&, int, Q_UINT32, Q_UINT32, Q_UINT32 clientID) = 0;
00281
00282
00286 void disconnect();
00287
00288
00297 void electAdmin(Q_UINT32 clientID);
00298
00307 KMessageClient* messageClient() const;
00308
00317 KMessageServer* messageServer() const;
00318
00325 virtual void lock();
00326
00330 virtual void unlock();
00331
00332 signals:
00338 void signalNetworkErrorMessage(int error, QString text);
00339
00344 void signalConnectionBroken();
00345
00355 void signalClientConnected(Q_UINT32 clientID);
00356
00368 void signalClientDisconnected(Q_UINT32 clientID, bool broken);
00369
00375 void signalAdminStatusChanged(bool isAdmin);
00376
00377 protected:
00384 void setMaster();
00385
00386 protected slots:
00394 void receiveNetworkTransmission(const QByteArray& a, Q_UINT32 clientID);
00395
00400 void slotAdminStatusChanged(bool isAdmin);
00401
00406 void aboutToLoseConnection(Q_UINT32 id);
00407
00412 void slotResetConnection();
00413
00414
00415 private:
00416 void tryPublish();
00417 void tryStopPublishing();
00418 KGameNetworkPrivate* d;
00419 };
00420
00421 #endif
This file is part of the documentation for libkdegames Library Version 3.4.2.