libkdegames Library API Documentation

kgamenetwork.h

00001 /* 00002 This file is part of the KDE games library 00003 Copyright (C) 2001 Martin Heni (martin@heni-online.de) 00004 Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de) 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License version 2 as published by the Free Software Foundation. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00018 Boston, MA 02111-1307, USA. 00019 */ 00020 /* 00021 $Id: kgamenetwork.h,v 1.29 2003/10/12 13:32:56 bhards Exp $ 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 //AB: is this now internal only? Can we make it protected (maybe with 00158 //friends)? sendSystemMessage AND sendMessage is very confusing to the 00159 //user. 00179 // AB: TODO: doc on how "receiver" and "sender" should be created! 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 // AB: TODO: doc on how "receiver" and "sender" should be created! 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
KDE Logo
This file is part of the documentation for libkdegames Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 28 14:18:46 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003