kmessageclient.h
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 <tqobject.h> 00024 #include <tqstring.h> 00025 #include <tqvaluelist.h> 00026 00027 class KMessageIO; 00028 class KMessageServer; 00029 class KMessageClientPrivate; 00030 00050 class KMessageClient : public TQObject 00051 { 00052 Q_OBJECT 00053 TQ_OBJECT 00054 00055 public: 00056 00062 KMessageClient (TQObject *parent = 0, const char *name = 0); 00063 00068 ~KMessageClient (); 00069 00077 TQ_UINT32 id () const; 00078 00089 bool isAdmin () const; 00090 00094 TQ_UINT32 adminId() const; 00095 00099 const TQValueList <TQ_UINT32> &clientList() const; 00100 00112 void setServer (const TQString &host, TQ_UINT16 port); 00113 00123 void setServer (KMessageServer *server); 00124 00128 void disconnect(); 00129 00151 virtual void setServer (KMessageIO *connection); 00152 00159 bool isConnected () const; 00160 00165 bool isNetwork () const; 00166 00172 TQ_UINT16 peerPort () const; 00173 00179 TQString peerName() const; 00180 00192 void sendServerMessage (const TQByteArray &msg); 00193 00202 //AB: processBroadcast doesn't exist!! is processIncomingMessage meant? 00203 void sendBroadcast (const TQByteArray &msg); 00204 00221 //AB: processForward doesn't exist!! is processIncomingMessage meant? 00222 void sendForward (const TQByteArray &msg, const TQValueList <TQ_UINT32> &clients); 00223 00234 void sendForward (const TQByteArray &msg, TQ_UINT32 client); 00235 00243 void lock(); 00244 00249 void unlock(); 00250 00254 unsigned int delayedMessageCount() const; 00255 00256 signals: 00277 void broadcastReceived (const TQByteArray &msg, TQ_UINT32 senderID); 00278 00307 void forwardReceived (const TQByteArray &msg, TQ_UINT32 senderID, const TQValueList <TQ_UINT32> &receivers); 00308 00318 void connectionBroken (); 00319 00324 void aboutToDisconnect(TQ_UINT32 id); 00325 00332 void adminStatusChanged (bool isAdmin); 00333 00340 void eventClientConnected (TQ_UINT32 clientID); 00341 00349 void eventClientDisconnected (TQ_UINT32 clientID, bool broken); 00350 00361 //AB: maybe add a setNoEmit() so that the other signals can be deactivated? 00362 //Could be a performance benefit (note: KMessageClient is a time critical 00363 //class!!!) 00364 void serverMessageReceived (const TQByteArray &msg, bool &unknown); 00365 00366 protected: 00384 virtual void processMessage (const TQByteArray& msg); 00385 00386 protected slots: 00402 virtual void processIncomingMessage (const TQByteArray &msg); 00403 00408 void processFirstMessage(); 00409 00416 virtual void removeBrokenConnection (); 00417 void removeBrokenConnection2 (); 00418 00419 private: 00420 KMessageClientPrivate *d; 00421 }; 00422 00423 #endif