[9406] | 1 | /*! |
---|
| 2 | * @file network_manager.h |
---|
| 3 | * Main interface for the network module. Manages all the modules |
---|
| 4 | */ |
---|
| 5 | |
---|
| 6 | /* you will want to add such a a line at your header file also, since it will |
---|
| 7 | prevent c++ from including your code twice*/ |
---|
| 8 | #ifndef _NETWORK_MANAGER |
---|
| 9 | #define _NETWORK_MANAGER |
---|
| 10 | |
---|
| 11 | /* include this file, it contains some default definitions */ |
---|
| 12 | #include "netdefs.h" |
---|
| 13 | #include "shared_network_data.h" |
---|
| 14 | |
---|
| 15 | /* include base_object.h since all classes are derived from this one */ |
---|
| 16 | #include "base_object.h" |
---|
| 17 | |
---|
| 18 | |
---|
[9494] | 19 | |
---|
[9406] | 20 | class NetworkStream; |
---|
| 21 | class Synchronizeable; |
---|
| 22 | |
---|
[9494] | 23 | |
---|
[9406] | 24 | /* and here is the class itsself*/ |
---|
| 25 | class NetworkManager : public BaseObject |
---|
| 26 | { |
---|
[9869] | 27 | ObjectListDeclaration(NetworkManager); |
---|
[9406] | 28 | public: |
---|
| 29 | |
---|
| 30 | inline static NetworkManager* getInstance() { if (!NetworkManager::singletonRef) NetworkManager::singletonRef = new NetworkManager(); |
---|
| 31 | return NetworkManager::singletonRef; } |
---|
| 32 | virtual ~NetworkManager(); |
---|
| 33 | |
---|
| 34 | void initialize(); |
---|
| 35 | void shutdown(); |
---|
| 36 | |
---|
| 37 | int createClient( const std::string & name, unsigned int port); |
---|
| 38 | int createMasterServer( unsigned int port); |
---|
| 39 | int createProxyServer( unsigned int port); |
---|
| 40 | |
---|
[9656] | 41 | void reconnectToServer(IP address); |
---|
| 42 | |
---|
[9406] | 43 | void connectSynchronizeable(Synchronizeable& sync); |
---|
| 44 | void synchronize(float dtS); |
---|
| 45 | |
---|
| 46 | void debug(); |
---|
| 47 | |
---|
[9656] | 48 | void setRedirectionTest(); |
---|
[9406] | 49 | |
---|
[9656] | 50 | |
---|
| 51 | |
---|
[9406] | 52 | private: |
---|
| 53 | NetworkManager(); |
---|
| 54 | |
---|
| 55 | |
---|
| 56 | private: |
---|
| 57 | static NetworkManager* singletonRef; //!< Pointer to the only instance of this Class |
---|
| 58 | NetworkStream* networkStream; //!< pointer to network stream |
---|
| 59 | |
---|
| 60 | float elapsedTime; //!< elapsed time since the last network update |
---|
| 61 | }; |
---|
| 62 | |
---|
| 63 | |
---|
| 64 | |
---|
| 65 | #endif /* _NETWORK_MANAGER */ |
---|