• 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
kmessageserver.h
Go to the documentation of this file.
1 /*
2  This file is part of the KDE games library
3  Copyright (C) 2001 Burkhard Lehner (Burkhard.Lehner@gmx.de)
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License version 2 as published by the Free Software Foundation.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef __KMESSAGESERVER_H__
21 #define __KMESSAGESERVER_H__
22 
23 #include <QtCore/QObject>
24 #include <QtCore/QString>
25 #include "../libkdegamesprivate_export.h"
26 
27 class KMessageIO;
28 class KMessageServerPrivate;
29 
175 class KDEGAMESPRIVATE_EXPORT KMessageServer : public QObject
176 {
177  Q_OBJECT
178 
179 public:
183  enum {
184  REQ_BROADCAST = 1,
185  REQ_FORWARD,
186  REQ_CLIENT_ID,
187  REQ_ADMIN_ID,
188  REQ_ADMIN_CHANGE,
189  REQ_REMOVE_CLIENT,
190  REQ_MAX_NUM_CLIENTS,
191  REQ_CLIENT_LIST,
192  REQ_MAX_REQ = 0xffff };
193 
197  enum {
198  MSG_BROADCAST = 101,
199  MSG_FORWARD,
200  ANS_CLIENT_ID,
201  ANS_ADMIN_ID,
202  ANS_CLIENT_LIST,
203  EVNT_CLIENT_CONNECTED,
204  EVNT_CLIENT_DISCONNECTED,
205  EVNT_MAX_EVNT = 0xffff
206  };
207 
211  explicit KMessageServer(quint16 cookie = 42, QObject* parent = 0);
212 
213  ~KMessageServer();
214 
218  virtual void Debug();
219 
220 //---------------------------------- TCP/IP server stuff
221 
229  bool initNetwork (quint16 port = 0);
230 
237  quint16 serverPort () const;
238 
244  void stopNetwork();
245 
250  bool isOfferingConnections() const;
251 
252 //---------------------------------- adding / removing clients
253 
254 public Q_SLOTS:
268  void addClient (KMessageIO *);
269 
281  void removeClient (KMessageIO *io, bool broken);
282 
286  void deleteClients();
287 
288 private Q_SLOTS:
295  void removeBrokenClient ();
296 
297 public:
309  void setMaxClients(int maxnumber);
310 
316  int maxClients() const;
317 
323  int clientCount() const;
324 
328  QList <quint32> clientIDs() const;
329 
335  KMessageIO *findClient (quint32 no) const;
336 
343  quint32 adminID() const;
344 
350  void setAdmin (quint32 adminID);
351 
352 
353 //------------------------------ ID stuff
354 
355  /*
356  * The unique ID of this game
357  *
358  * @return int id
359  **/
360 // int gameId() const;
361 
362  /*
363  * Application cookie. this idendifies the game application. It
364  * help to distinguish between e.g. KPoker and KWin4
365  *
366  * @return the application cookie
367  **/
368 // int cookie() const;
369 
370 //------------------------------ Message stuff
371 
372 public:
378  virtual void broadcastMessage (const QByteArray &msg);
379 
388  virtual void sendMessage (quint32 id, const QByteArray &msg);
389 
397  virtual void sendMessage (const QList <quint32> &ids, const QByteArray &msg);
398 
399 protected Q_SLOTS:
409  virtual void getReceivedMessage (const QByteArray &msg);
410 
419  virtual void processOneMessage ();
420 
421 //---------------------------- Signals
422 
423 Q_SIGNALS:
428  void clientConnected (KMessageIO *client);
429 
437  void connectionLost (KMessageIO *client);
438 
451  void messageReceived (const QByteArray &data, quint32 clientID, bool &unknown);
452 
453 protected:
459  quint32 uniqueClientNumber() const;
460 
461 private:
462  KMessageServerPrivate* d;
463 };
464 
465 
466 #endif
KMessageServer::REQ_FORWARD
Definition: kmessageserver.h:185
KMessageServer::EVNT_CLIENT_DISCONNECTED
Definition: kmessageserver.h:204
KMessageServer::ANS_ADMIN_ID
Definition: kmessageserver.h:201
QByteArray
KMessageServer::EVNT_CLIENT_CONNECTED
Definition: kmessageserver.h:203
KMessageServer::ANS_CLIENT_ID
Definition: kmessageserver.h:200
KMessageServer::REQ_ADMIN_CHANGE
Definition: kmessageserver.h:188
KMessageServer::MSG_FORWARD
Definition: kmessageserver.h:199
QObject
KMessageServer::REQ_ADMIN_ID
Definition: kmessageserver.h:187
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
KMessageServer::REQ_MAX_NUM_CLIENTS
Definition: kmessageserver.h:190
QList< quint32 >
KMessageServer::REQ_CLIENT_ID
Definition: kmessageserver.h:186
KMessageServer::ANS_CLIENT_LIST
Definition: kmessageserver.h:202
KMessageServer::REQ_CLIENT_LIST
Definition: kmessageserver.h:191
KMessageServer::REQ_REMOVE_CLIENT
Definition: kmessageserver.h:189
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