• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • libtdegames
 

libtdegames

  • libtdegames
  • kgame
kmessageclient.h
1 /*
2  This file is part of the TDE 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 __KMESSAGECLIENT_H__
21 #define __KMESSAGECLIENT_H__
22 
23 #include <tqobject.h>
24 #include <tqstring.h>
25 #include <tqvaluelist.h>
26 
27 class KMessageIO;
28 class KMessageServer;
29 class KMessageClientPrivate;
30 
50 class KMessageClient : public TQObject
51 {
52  TQ_OBJECT
53 
54 
55 public:
56 
62  KMessageClient (TQObject *parent = 0, const char *name = 0);
63 
68  ~KMessageClient ();
69 
77  TQ_UINT32 id () const;
78 
89  bool isAdmin () const;
90 
94  TQ_UINT32 adminId() const;
95 
99  const TQValueList <TQ_UINT32> &clientList() const;
100 
112  void setServer (const TQString &host, TQ_UINT16 port);
113 
123  void setServer (KMessageServer *server);
124 
128  void disconnect();
129 
151  virtual void setServer (KMessageIO *connection);
152 
159  bool isConnected () const;
160 
165  bool isNetwork () const;
166 
172  TQ_UINT16 peerPort () const;
173 
179  TQString peerName() const;
180 
192  void sendServerMessage (const TQByteArray &msg);
193 
202  //AB: processBroadcast doesn't exist!! is processIncomingMessage meant?
203  void sendBroadcast (const TQByteArray &msg);
204 
221  //AB: processForward doesn't exist!! is processIncomingMessage meant?
222  void sendForward (const TQByteArray &msg, const TQValueList <TQ_UINT32> &clients);
223 
234  void sendForward (const TQByteArray &msg, TQ_UINT32 client);
235 
243  void lock();
244 
249  void unlock();
250 
254  unsigned int delayedMessageCount() const;
255 
256 signals:
277  void broadcastReceived (const TQByteArray &msg, TQ_UINT32 senderID);
278 
307  void forwardReceived (const TQByteArray &msg, TQ_UINT32 senderID, const TQValueList <TQ_UINT32> &receivers);
308 
318  void connectionBroken ();
319 
324  void aboutToDisconnect(TQ_UINT32 id);
325 
332  void adminStatusChanged (bool isAdmin);
333 
340  void eventClientConnected (TQ_UINT32 clientID);
341 
349  void eventClientDisconnected (TQ_UINT32 clientID, bool broken);
350 
361  //AB: maybe add a setNoEmit() so that the other signals can be deactivated?
362  //Could be a performance benefit (note: KMessageClient is a time critical
363  //class!!!)
364  void serverMessageReceived (const TQByteArray &msg, bool &unknown);
365 
366 protected:
384  virtual void processMessage (const TQByteArray& msg);
385 
386 protected slots:
402  virtual void processIncomingMessage (const TQByteArray &msg);
403 
408  void processFirstMessage();
409 
416  virtual void removeBrokenConnection ();
417  void removeBrokenConnection2 ();
418 
419 private:
420  KMessageClientPrivate *d;
421 };
422 
423 #endif
KMessageClient
A client to connect to a KMessageServer.
Definition: kmessageclient.h:51
KMessageClient::processFirstMessage
void processFirstMessage()
Called from unlock() (using TQTimer::singleShot) until all delayed messages are delivered.
Definition: kmessageclient.cpp:305
KMessageClient::isConnected
bool isConnected() const
Definition: kmessageclient.cpp:118
KMessageClient::peerPort
TQ_UINT16 peerPort() const
Definition: kmessageclient.cpp:128
KMessageClient::isNetwork
bool isNetwork() const
Definition: kmessageclient.cpp:123
KMessageClient::clientList
const TQValueList< TQ_UINT32 > & clientList() const
Definition: kmessageclient.cpp:113
KMessageClient::setServer
void setServer(const TQString &host, TQ_UINT16 port)
Connects the client to (another) server.
Definition: kmessageclient.cpp:66
KMessageClient::lock
void lock()
Once this function is called no message will be received anymore.
Definition: kmessageclient.cpp:354
KMessageClient::adminId
TQ_UINT32 adminId() const
Definition: kmessageclient.cpp:108
KMessageClient::~KMessageClient
~KMessageClient()
Destructor.
Definition: kmessageclient.cpp:58
KMessageClient::peerName
TQString peerName() const
Definition: kmessageclient.cpp:133
KMessageClient::forwardReceived
void forwardReceived(const TQByteArray &msg, TQ_UINT32 senderID, const TQValueList< TQ_UINT32 > &receivers)
This signal is emitted when the client receives a forward message from the KMessageServer,...
KMessageClient::eventClientDisconnected
void eventClientDisconnected(TQ_UINT32 clientID, bool broken)
This signal is emitted when the server has lost the connection to one of the clients (This could be b...
KMessageClient::aboutToDisconnect
void aboutToDisconnect(TQ_UINT32 id)
This signal is emitted right before the client disconnects.
KMessageClient::broadcastReceived
void broadcastReceived(const TQByteArray &msg, TQ_UINT32 senderID)
This signal is emitted when the client receives a broadcast message from the KMessageServer,...
KMessageClient::disconnect
void disconnect()
Corresponds to setServer(0); but also emits the connectionBroken signal.
Definition: kmessageclient.cpp:342
KMessageClient::KMessageClient
KMessageClient(TQObject *parent=0, const char *name=0)
Constructor.
Definition: kmessageclient.cpp:51
KMessageClient::connectionBroken
void connectionBroken()
This signal is emitted when the connection to the KMessageServer is broken.
KMessageClient::id
TQ_UINT32 id() const
Definition: kmessageclient.cpp:98
KMessageClient::adminStatusChanged
void adminStatusChanged(bool isAdmin)
This signal is emitted when this client becomes the admin client or when it loses the admin client st...
KMessageClient::isAdmin
bool isAdmin() const
Definition: kmessageclient.cpp:103
KMessageClient::delayedMessageCount
unsigned int delayedMessageCount() const
Definition: kmessageclient.cpp:368
KMessageClient::sendBroadcast
void sendBroadcast(const TQByteArray &msg)
Sends a message to all the clients connected to the server, including ourself.
Definition: kmessageclient.cpp:150
KMessageClient::unlock
void unlock()
Deliver every message that was delayed by lock() and actually deliver all messages that get received ...
Definition: kmessageclient.cpp:359
KMessageClient::serverMessageReceived
void serverMessageReceived(const TQByteArray &msg, bool &unknown)
This signal is emitted on every message that came from the server.
KMessageClient::processIncomingMessage
virtual void processIncomingMessage(const TQByteArray &msg)
This slot is called from the signal KMessageIO::received whenever a message from the KMessageServer a...
Definition: kmessageclient.cpp:182
KMessageClient::removeBrokenConnection
virtual void removeBrokenConnection()
This slot is called from the signal KMessageIO::connectionBroken.
Definition: kmessageclient.cpp:321
KMessageClient::eventClientConnected
void eventClientConnected(TQ_UINT32 clientID)
This signal is emitted when another client has connected to the server.
KMessageClient::sendForward
void sendForward(const TQByteArray &msg, const TQValueList< TQ_UINT32 > &clients)
Sends a message to all the clients in a list.
Definition: kmessageclient.cpp:162
KMessageClient::sendServerMessage
void sendServerMessage(const TQByteArray &msg)
Sends a message to the KMessageServer.
Definition: kmessageclient.cpp:140
KMessageClient::processMessage
virtual void processMessage(const TQByteArray &msg)
This slot is called from processIncomingMessage or processFirstMessage, depending on whether the clie...
Definition: kmessageclient.cpp:202
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:176

libtdegames

Skip menu "libtdegames"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

libtdegames

Skip menu "libtdegames"
  • libtdegames
Generated for libtdegames by doxygen 1.9.1
This website is maintained by Timothy Pearson.