Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

heavy permissions fight: no node was ever thought to be client and server at the same time, proxy server are hybrid nodes so there is need for a big framework extension.

  • made the obb creation saver
  • prevented segfaults in the aabb tree creation, this was very dangerous code
  • inserted handshake hack to make the handshake work.

No I will have to get the handshake right so the node works correctly

File size: 2.8 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/network_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 ( isMasterServer())?this->newUniqueID++:-1; }
31    /** sets the @param newUniqueID: the new offset for the next unique id */
32    inline void setNewUniqueID(int newUniqueID) { this->newUniqueID = newUniqueID; }
33
34    /** @returns true is this node is a master server */
35    inline bool isMasterServer() { return this->nodeType == NET_MASTER_SERVER; }
36    /** @returns true is this node is a proxy server */
37    inline bool isProxyServerActive() { return this->nodeType == NET_PROXY_SERVER_ACTIVE; }
38    /** @returns true is this node is a client*/
39    inline bool isClient() { return this->nodeType == NET_CLIENT; }
40    /** sets the game server flag @param bGameServer true if it is a game server */
41    inline void setNodeType(int nodeType) { this->nodeType = nodeType; }
42
43    /** @returns the maximum number of players for this server */
44    inline int getMaxPlayer() { return NetworkSettings::getInstance()->getMaxPlayer(); }
45
46    /** @returns the hostID of the node */
47    inline int getHostID() { return this->hostID; }
48    /** sets the hostID of this node @param hostID of the node */
49    inline void setHostID(int hostID) { this->hostID = hostID; }
50
51    /** @returns the default synchronize stream */
52    inline NetworkStream* getDefaultSyncStream() { return this->defaultSyncStream; }
53    /** sets the default sync stream @param defaultSyncStream the default sync stream */
54    inline void setDefaultSyncStream(NetworkStream* defaultSyncStream) { this->defaultSyncStream = defaultSyncStream; }
55
56
57  private:
58    SharedNetworkData();
59
60
61  private:
62    int                             newUniqueID;             //!< next uniqueID
63    int                             nodeType;                //!< saves the node type here
64
65    int                             hostID;                  //!< The Host-ID of the Manager
66    NetworkStream*                  defaultSyncStream;       //!< default synchronize NetworkStream
67
68    static SharedNetworkData*       singletonRef;            //!< Pointer to the only instance of this Class
69
70};
71
72
73
74#endif /* _SHARED_NETWORK_DATA */
Note: See TracBrowser for help on using the repository browser.