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

libtdegames

  • libtdegames
  • kgame
kgamenetwork.h
1/*
2 This file is part of the TDE games library
3 Copyright (C) 2001 Martin Heni (martin@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 $Id$
22*/
23#ifndef __KGAMENETWORK_H_
24#define __KGAMENETWORK_H_
25
26#include <tqstring.h>
27#include <tqobject.h>
28#include <tdemacros.h>
29class KGameIO;
30class KMessageClient;
31class KMessageServer;
32
33class KGameNetworkPrivate;
34
46class TDE_EXPORT KGameNetwork : public TQObject
47{
48 TQ_OBJECT
49
50
51public:
55 KGameNetwork(int cookie=42,TQObject* parent=0);
56 virtual ~KGameNetwork();
57
61 virtual void Debug();
62
67 bool isNetwork() const;
68
81 bool isMaster() const;
82
93 bool isAdmin() const;
94
100 TQ_UINT32 gameId() const;
101
112 bool offerConnections (TQ_UINT16 port);
113
124 void setDiscoveryInfo(const TQString& type, const TQString& name=TQString());
125
134 bool connectToServer(const TQString& host, TQ_UINT16 port);
135
142 TQ_UINT16 port() const;
143
150 TQString hostName() const;
151
156 bool stopServerConnection();
157
168 void setMaxClients(int max);
169
170 //AB: is this now internal only? Can we make it protected (maybe with
171 //friends)? sendSystemMessage AND sendMessage is very confusing to the
172 //user.
192 // AB: TODO: doc on how "receiver" and "sender" should be created!
193 bool sendSystemMessage(const TQByteArray& buffer, int msgid, TQ_UINT32 receiver=0, TQ_UINT32 sender=0);
194
198 bool sendSystemMessage(int data, int msgid, TQ_UINT32 receiver=0, TQ_UINT32 sender=0);
199
203 bool sendSystemMessage(const TQDataStream &msg, int msgid, TQ_UINT32 receiver=0, TQ_UINT32 sender=0);
204
208 bool sendSystemMessage(const TQString& msg, int msgid, TQ_UINT32 receiver=0, TQ_UINT32 sender=0);
209
221 void sendError(int error, const TQByteArray& message, TQ_UINT32 receiver=0, TQ_UINT32 sender=0);
222
227 bool isOfferingConnections() const;
228
234 int cookie() const;
235
268 // AB: TODO: doc on how "receiver" and "sender" should be created!
269 bool sendMessage(const TQByteArray& buffer, int msgid, TQ_UINT32 receiver=0, TQ_UINT32 sender=0);
270
274 bool sendMessage(const TQDataStream &msg, int msgid, TQ_UINT32 receiver=0, TQ_UINT32 sender=0);
275
279 bool sendMessage(const TQString& msg, int msgid, TQ_UINT32 receiver=0, TQ_UINT32 sender=0);
280
284 bool sendMessage(int data, int msgid, TQ_UINT32 receiver=0, TQ_UINT32 sender=0);
285
286
291 virtual void networkTransmission(TQDataStream&, int, TQ_UINT32, TQ_UINT32, TQ_UINT32 clientID) = 0;
292
293
297 void disconnect();
298
299
308 void electAdmin(TQ_UINT32 clientID);
309
318 KMessageClient* messageClient() const;
319
328 KMessageServer* messageServer() const;
329
336 virtual void lock();
337
341 virtual void unlock();
342
343signals:
349 void signalNetworkErrorMessage(int error, TQString text);
350
355 void signalConnectionBroken();
356
366 void signalClientConnected(TQ_UINT32 clientID);
367
379 void signalClientDisconnected(TQ_UINT32 clientID, bool broken);
380
386 void signalAdminStatusChanged(bool isAdmin);
387
388protected:
395 void setMaster();
396
397protected slots:
405 void receiveNetworkTransmission(const TQByteArray& a, TQ_UINT32 clientID);
406
411 void slotAdminStatusChanged(bool isAdmin);
412
417 void aboutToLoseConnection(TQ_UINT32 id);
418
423 void slotResetConnection();
424
425
426private:
427 void tryPublish();
428 void tryStopPublishing();
429 KGameNetworkPrivate* d;
430};
431
432#endif
KGameIO
Base class for IO devices for games.
Definition: kgameio.h:56
KGameNetwork
The KGameNetwork class is the KGame class with network support.
Definition: kgamenetwork.h:47
KGameNetwork::signalClientDisconnected
void signalClientDisconnected(TQ_UINT32 clientID, bool broken)
This signal is emitted whenever the KMessageServer sends us a message that a connection to a client w...
KGameNetwork::signalClientConnected
void signalClientConnected(TQ_UINT32 clientID)
This signal is emitted whenever the KMessageServer sends us a message that a new client connected.
KGameNetwork::signalConnectionBroken
void signalConnectionBroken()
Our connection to the KMessageServer has broken.
KGameNetwork::signalNetworkErrorMessage
void signalNetworkErrorMessage(int error, TQString text)
A network error occurred.
KGameNetwork::networkTransmission
virtual void networkTransmission(TQDataStream &, int, TQ_UINT32, TQ_UINT32, TQ_UINT32 clientID)=0
Called by ReceiveNetworkTransmission().
KGameNetwork::signalAdminStatusChanged
void signalAdminStatusChanged(bool isAdmin)
This client gets or loses the admin status.
KMessageClient
A client to connect to a KMessageServer.
Definition: kmessageclient.h:51
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.4
This website is maintained by Timothy Pearson.