• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegames API Reference
  • KDE Home
  • Contact Us
 

libkdegames/libkdegamesprivate/kgame

  • sources
  • kde-4.14
  • kdegames
  • libkdegames
  • libkdegamesprivate
  • kgame
kgamenetwork.h
Go to the documentation of this file.
1 /*
2  This file is part of the KDE games library
3  Copyright (C) 2001 Martin Heni (kde at heni-online.de)
4  Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License version 2 as published by the Free Software Foundation.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #ifndef __KGAMENETWORK_H_
22 #define __KGAMENETWORK_H_
23 
24 #include <QtCore/QString>
25 #include <QtCore/QObject>
26 #include "../libkdegamesprivate_export.h"
27 
28 class KGameIO;
29 class KMessageIO;
30 class KMessageClient;
31 class KMessageServer;
32 
33 class KGameNetworkPrivate;
34 
46 class KDEGAMESPRIVATE_EXPORT KGameNetwork : public QObject
47 {
48  Q_OBJECT
49 
50 public:
54  explicit KGameNetwork(int cookie=42,QObject* parent=0);
55  virtual ~KGameNetwork();
56 
60  virtual void Debug();
61 
66  bool isNetwork() const;
67 
80  bool isMaster() const;
81 
92  bool isAdmin() const;
93 
99  quint32 gameId() const;
100 
111  bool offerConnections (quint16 port);
112 
113  void setDiscoveryInfo(const QString& type, const QString& name=QString());
114 
123  bool connectToServer(const QString& host, quint16 port);
124  bool connectToServer(KMessageIO *connection);
125 
131  quint16 port() const;
132 
138  QString hostName() const;
139 
144  bool stopServerConnection();
145 
156  void setMaxClients(int max);
157 
158  //AB: is this now internal only? Can we make it protected (maybe with
159  //friends)? sendSystemMessage AND sendMessage is very confusing to the
160  //user.
180  // AB: TODO: doc on how "receiver" and "sender" should be created!
181  bool sendSystemMessage(const QByteArray& buffer, int msgid, quint32 receiver=0, quint32 sender=0);
182 
186  bool sendSystemMessage(int data, int msgid, quint32 receiver=0, quint32 sender=0);
187 
191  bool sendSystemMessage(const QDataStream &msg, int msgid, quint32 receiver=0, quint32 sender=0);
192 
196  bool sendSystemMessage(const QString& msg, int msgid, quint32 receiver=0, quint32 sender=0);
197 
209  void sendError(int error, const QByteArray& message, quint32 receiver=0, quint32 sender=0);
210 
215  bool isOfferingConnections() const;
216 
222  int cookie() const;
223 
256  // AB: TODO: doc on how "receiver" and "sender" should be created!
257  bool sendMessage(const QByteArray& buffer, int msgid, quint32 receiver=0, quint32 sender=0);
258 
262  bool sendMessage(const QDataStream &msg, int msgid, quint32 receiver=0, quint32 sender=0);
263 
267  bool sendMessage(const QString& msg, int msgid, quint32 receiver=0, quint32 sender=0);
268 
272  bool sendMessage(int data, int msgid, quint32 receiver=0, quint32 sender=0);
273 
274 
279  virtual void networkTransmission(QDataStream&, int, quint32, quint32, quint32 clientID) = 0;
280 
281 
285  void disconnect();
286 
287 
296  void electAdmin(quint32 clientID);
297 
306  KMessageClient* messageClient() const;
307 
316  KMessageServer* messageServer() const;
317 
324  virtual void lock();
325 
329  virtual void unlock();
330 
331 Q_SIGNALS:
337  void signalNetworkErrorMessage(int error, QString text);
338 
343  void signalConnectionBroken();
344 
354  void signalClientConnected(quint32 clientID);
355 
367  void signalClientDisconnected(quint32 clientID, bool broken);
368 
374  void signalAdminStatusChanged(bool isAdmin);
375 
376 protected:
383  void setMaster();
384 
385 protected Q_SLOTS:
393  void receiveNetworkTransmission(const QByteArray& a, quint32 clientID);
394 
399  void slotAdminStatusChanged(bool isAdmin);
400 
405  void aboutToLoseConnection(quint32 id);
406 
411  void slotResetConnection();
412 
413 
414 private:
415  void tryPublish();
416  void tryStopPublishing();
417  KGameNetworkPrivate* const d;
418 };
419 
420 #endif
QByteArray
QDataStream
QObject::disconnect
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
KMessageClient
A client to connect to a KMessageServer.
Definition: kmessageclient.h:52
QObject
KMessageIO
This abstract base class represents one end of a message connections between two clients.
Definition: kmessageio.h:57
KMessageServer
A server for message sending and broadcasting, using TCP/IP connections.
Definition: kmessageserver.h:175
QString
KGameNetwork
The KGameNetwork class is the KGame class with network support.
Definition: kgamenetwork.h:46
KGameIO
Base class for IO devices for games.
Definition: kgameio.h:65
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:54 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libkdegames/libkdegamesprivate/kgame

Skip menu "libkdegames/libkdegamesprivate/kgame"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdegames API Reference

Skip menu "kdegames API Reference"
  • granatier
  • kapman
  • kblackbox
  • kgoldrunner
  • kigo
  • kmahjongg
  • KShisen
  • ksquares
  • libkdegames
  •   highscore
  •   libkdegamesprivate
  •     kgame
  • libkmahjongg
  • palapeli
  •   libpala

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal