Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/proxy/src/lib/network/shared_network_data.h @ 9387

Last change on this file since 9387 was 9387, checked in by patrick, 18 years ago

bringing the max connection stuff down

File size: 2.6 KB
Line 
1/*!
2 * @file shared_network_data.h
3 *  some shared data from the NetworkManager
4 */
5
6#ifndef _SHARED_NETWORK_DATA
7#define _SHARED_NETWORK_DATA
8
9#include "base_object.h"
10#include "netdefs.h"
11#include "proxy/proxy_settings.h"
12
13//!< maximal connectinons for the server
14#define NET_MAX_CONNECTIONS 2
15
16class NetworkStream;
17class Synchronizeable;
18
19
20/* and here is the class itsself*/
21class SharedNetworkData : public BaseObject
22{
23
24  public:
25    inline static SharedNetworkData* getInstance() { if (!SharedNetworkData::singletonRef) SharedNetworkData::singletonRef = new SharedNetworkData();
26      return SharedNetworkData::singletonRef; }
27    virtual ~SharedNetworkData();
28
29    /** @returns the next uniqueID free for an object */
30    inline int getNewUniqueID() { return ( this->nodeType != NET_CLIENT)?this->newUniqueID++:-1; }
31
32    /** @returns true is this node is a master server */
33    inline bool isMasterServer() { return this->nodeType == NET_MASTER_SERVER; }
34    /** @returns true is this node is a proxy server */
35    inline bool isProxyServer() { return this->nodeType == NET_PROXY_SERVER_ACTIVE; }
36    /** @returns true is this node is a client*/
37    inline bool isClient() { return this->nodeType == NET_CLIENT; }
38    /** sets the game server flag @param bGameServer true if it is a game server */
39    inline void setNodeType(int nodeType) { this->nodeType = nodeType; }
40
41    /** @returns the maximum number of players for this server */
42    inline int getMaxPlayer() { return /*ProxySettings::getInstance()->getMaxPlayer()*/NET_MAX_CONNECTIONS; }
43
44    /** @returns the hostID of the node */
45    inline int getHostID() { return this->hostID; }
46    /** sets the hostID of this node @param hostID of the node */
47    inline void setHostID(int hostID) { this->hostID = hostID; }
48
49    /** @returns the default synchronize stream */
50    inline NetworkStream* getDefaultSyncStream() { return this->defaultSyncStream; }
51    /** sets the default sync stream @param defaultSyncStream the default sync stream */
52    inline void setDefaultSyncStream(NetworkStream* defaultSyncStream) { this->defaultSyncStream = defaultSyncStream; }
53
54
55  private:
56    SharedNetworkData();
57
58
59  private:
60    int                             newUniqueID;             //!< next uniqueID
61    int                             nodeType;                //!< saves the node type here
62
63    int                             hostID;                  //!< The Host-ID of the Manager
64    NetworkStream*                  defaultSyncStream;       //!< default synchronize NetworkStream
65
66    static SharedNetworkData*       singletonRef;            //!< Pointer to the only instance of this Class
67
68};
69
70
71
72#endif /* _SHARED_NETWORK_DATA */
Note: See TracBrowser for help on using the repository browser.