kmessageclient.h

Go to the documentation of this file.
00001 /*
00002     This file is part of the KDE games library
00003     Copyright (C) 2001 Burkhard Lehner (Burkhard.Lehner@gmx.de)
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License version 2 as published by the Free Software Foundation.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to
00016     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017     Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef __KMESSAGECLIENT_H__
00021 #define __KMESSAGECLIENT_H__
00022 
00023 #include <qobject.h>
00024 #include <qstring.h>
00025 #include <qvaluelist.h>
00026 
00027 class KMessageIO;
00028 class KMessageServer;
00029 class KMessageClientPrivate;
00030 
00050 class KMessageClient : public QObject
00051 {
00052   Q_OBJECT
00053 
00054 public:
00055 
00061   KMessageClient (QObject *parent = 0, const char *name = 0);
00062 
00067   ~KMessageClient ();
00068 
00076   Q_UINT32 id () const;
00077 
00088   bool isAdmin () const;
00089 
00093   Q_UINT32 adminId() const;
00094 
00098   const QValueList <Q_UINT32> &clientList() const;
00099 
00111   void setServer (const QString &host, Q_UINT16 port);
00112 
00122   void setServer (KMessageServer *server);
00123 
00127   void disconnect();
00128 
00150   virtual void setServer (KMessageIO *connection);
00151 
00158   bool isConnected () const;
00159 
00164   bool isNetwork () const;
00165 
00171   Q_UINT16 peerPort () const;
00172 
00178   QString peerName() const;
00179 
00191   void sendServerMessage (const QByteArray &msg);
00192 
00201   //AB: processBroadcast doesn't exist!! is processIncomingMessage meant?
00202   void sendBroadcast (const QByteArray &msg);
00203 
00220   //AB: processForward doesn't exist!! is processIncomingMessage meant?
00221   void sendForward (const QByteArray &msg, const QValueList <Q_UINT32> &clients);
00222 
00233   void sendForward (const QByteArray &msg, Q_UINT32 client);
00234 
00242   void lock();
00243 
00248   void unlock();
00249 
00253   unsigned int delayedMessageCount() const;
00254 
00255 signals:
00276   void broadcastReceived (const QByteArray &msg, Q_UINT32 senderID);
00277 
00306   void forwardReceived (const QByteArray &msg, Q_UINT32 senderID, const QValueList <Q_UINT32> &receivers);
00307 
00317   void connectionBroken ();
00318 
00323   void aboutToDisconnect(Q_UINT32 id);
00324 
00331   void adminStatusChanged (bool isAdmin);
00332 
00339   void eventClientConnected (Q_UINT32 clientID);
00340 
00348   void eventClientDisconnected (Q_UINT32 clientID, bool broken);
00349 
00360   //AB: maybe add a setNoEmit() so that the other signals can be deactivated?
00361   //Could be a performance benefit (note: KMessageClient is a time critical
00362   //class!!!)
00363   void serverMessageReceived (const QByteArray &msg, bool &unknown);
00364 
00365 protected:
00383   virtual void processMessage (const QByteArray& msg);
00384 
00385 protected slots:
00401   virtual void processIncomingMessage (const QByteArray &msg);
00402 
00407   void processFirstMessage();
00408 
00415   virtual void removeBrokenConnection ();
00416   void removeBrokenConnection2 ();
00417 
00418 private:
00419   KMessageClientPrivate *d;
00420 };
00421 
00422 #endif

Generated on Wed Aug 23 18:04:18 2006 for libkdegames by  doxygen 1.4.6