• 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::messageServer
KMessageServer * messageServer() const
Don't use this unless you really know what you are doing!
Definition kgamenetwork.cpp:110
KGameNetwork::isMaster
bool isMaster() const
Is this the game MASTER (i.e.
Definition kgamenetwork.cpp:101
KGameNetwork::messageClient
KMessageClient * messageClient() const
Don't use this unless you really know what youre doing!
Definition kgamenetwork.cpp:107
KGameNetwork::offerConnections
bool offerConnections(TQ_UINT16 port)
Inits a network game as network MASTER.
Definition kgamenetwork.cpp:174
KGameNetwork::isNetwork
bool isNetwork() const
Definition kgamenetwork.cpp:83
KGameNetwork::isAdmin
bool isAdmin() const
The admin of a game is the one who initializes newly connected clients using negotiateNetworkGame and...
Definition kgamenetwork.cpp:104
KGameNetwork::aboutToLoseConnection
void aboutToLoseConnection(TQ_UINT32 id)
Called when the network connection is about to terminate.
Definition kgamenetwork.cpp:323
KGameNetwork::receiveNetworkTransmission
void receiveNetworkTransmission(const TQByteArray &a, TQ_UINT32 clientID)
Called by KMessageClient::broadcastReceived() and will check if the message format is valid.
Definition kgamenetwork.cpp:461
KGameNetwork::lock
virtual void lock()
You should call this before doing thigs like, e.g.
Definition kgamenetwork.cpp:361
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::Debug
virtual void Debug()
Gives debug output of the game status.
Definition kgamenetwork.cpp:505
KGameNetwork::slotResetConnection
void slotResetConnection()
Called when the network connection is terminated.
Definition kgamenetwork.cpp:329
KGameNetwork::disconnect
void disconnect()
Disconnect the current connection and establish a new local one.
Definition kgamenetwork.cpp:273
KGameNetwork::hostName
TQString hostName() const
Definition kgamenetwork.cpp:254
KGameNetwork::signalClientConnected
void signalClientConnected(TQ_UINT32 clientID)
This signal is emitted whenever the KMessageServer sends us a message that a new client connected.
KGameNetwork::gameId
TQ_UINT32 gameId() const
The unique ID of this game.
Definition kgamenetwork.cpp:86
KGameNetwork::cookie
int cookie() const
Application cookie.
Definition kgamenetwork.cpp:98
KGameNetwork::sendSystemMessage
bool sendSystemMessage(const TQByteArray &buffer, int msgid, TQ_UINT32 receiver=0, TQ_UINT32 sender=0)
Sends a network message msg with a given msg id msgid to all clients.
Definition kgamenetwork.cpp:396
KGameNetwork::sendMessage
bool sendMessage(const TQByteArray &buffer, int msgid, TQ_UINT32 receiver=0, TQ_UINT32 sender=0)
Send a network message msg with a given message ID msgid to all clients.
Definition kgamenetwork.cpp:447
KGameNetwork::isOfferingConnections
bool isOfferingConnections() const
Are we still offer offering server connections - only for game MASTER.
Definition kgamenetwork.cpp:270
KGameNetwork::setMaxClients
void setMaxClients(int max)
Changes the maximal connection number of the KMessageServer to max.
Definition kgamenetwork.cpp:348
KGameNetwork::slotAdminStatusChanged
void slotAdminStatusChanged(bool isAdmin)
This KGame object receives or loses the admin status.
Definition kgamenetwork.cpp:498
KGameNetwork::electAdmin
void electAdmin(TQ_UINT32 clientID)
If you are the ADMIN of the game you can give the ADMIN status away to another client.
Definition kgamenetwork.cpp:335
KGameNetwork::port
TQ_UINT16 port() const
Definition kgamenetwork.cpp:242
KGameNetwork::signalConnectionBroken
void signalConnectionBroken()
Our connection to the KMessageServer has broken.
KGameNetwork::unlock
virtual void unlock()
Definition kgamenetwork.cpp:368
KGameNetwork::setDiscoveryInfo
void setDiscoveryInfo(const TQString &type, const TQString &name=TQString())
Announces game MASTER on network using DNS-SD.
Definition kgamenetwork.cpp:150
KGameNetwork::sendError
void sendError(int error, const TQByteArray &message, TQ_UINT32 receiver=0, TQ_UINT32 sender=0)
Sends a network message.
Definition kgamenetwork.cpp:450
KGameNetwork::KGameNetwork
KGameNetwork(int cookie=42, TQObject *parent=0)
Create a KGameNetwork object.
Definition kgamenetwork.cpp:62
KGameNetwork::signalNetworkErrorMessage
void signalNetworkErrorMessage(int error, TQString text)
A network error occurred.
KGameNetwork::connectToServer
bool connectToServer(const TQString &host, TQ_UINT16 port)
Inits a network game as a network CLIENT.
Definition kgamenetwork.cpp:204
KGameNetwork::stopServerConnection
bool stopServerConnection()
Stops offering server connections - only for game MASTER.
Definition kgamenetwork.cpp:259
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.15.0
This website is maintained by Timothy Pearson.