[9263] | 1 | /*! |
---|
[9264] | 2 | * @file network_monitor.h |
---|
| 3 | * a class to monitor the network: throughput, network nodes |
---|
[9263] | 4 | */ |
---|
| 5 | |
---|
| 6 | #ifndef _NETWORK_MONITOR_H |
---|
| 7 | #define _NETWORK_MONITOR_H |
---|
| 8 | |
---|
| 9 | #include "base_object.h" |
---|
| 10 | #include "synchronizeable.h" |
---|
| 11 | |
---|
[9278] | 12 | #include "network_node.h" |
---|
| 13 | |
---|
[9264] | 14 | #include <list> |
---|
| 15 | |
---|
[9263] | 16 | class NetworkStream; |
---|
[9264] | 17 | class PeerInfo; |
---|
[9263] | 18 | |
---|
[9278] | 19 | |
---|
[9269] | 20 | namespace OrxGui { class GLGuiBox; }; |
---|
[9264] | 21 | |
---|
[9273] | 22 | |
---|
| 23 | |
---|
| 24 | //!< a class that monitors the whole network. it tries to gather all informations its able to from the network |
---|
[9263] | 25 | class NetworkMonitor : public Synchronizeable |
---|
| 26 | { |
---|
| 27 | |
---|
| 28 | public: |
---|
| 29 | NetworkMonitor(NetworkStream* networkStream); |
---|
[9264] | 30 | virtual ~NetworkMonitor(); |
---|
| 31 | |
---|
[9277] | 32 | /* client/masterserver/proxyserver addition/removal interface */ |
---|
| 33 | void addNetworkNode(NetworkNode* node); |
---|
| 34 | void removeNetworkNode(NetworkNode* node); |
---|
[9264] | 35 | |
---|
[9282] | 36 | void addNode(PeerInfo* pInfo); |
---|
[9287] | 37 | void addNode(NetworkNode* node) { this->nodeList.push_back(node); } |
---|
| 38 | void addNode(NetworkNode* node, PeerInfo* pInfo); |
---|
[9282] | 39 | |
---|
| 40 | /** adds to @param node a network node @param pInfo a new client */ |
---|
[9278] | 41 | inline void addClient(NetworkNode* node, PeerInfo* pInfo) { node->addClient(pInfo); } |
---|
[9282] | 42 | /** adds to @param node a network node @param pInfo a new proxy server */ |
---|
[9292] | 43 | inline void addActiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->addActiveProxyServer(pInfo); } |
---|
[9282] | 44 | /** adds to @param node a network node @param pInfo a new master server*/ |
---|
[9278] | 45 | inline void addMasterServer(NetworkNode* node, PeerInfo* pInfo) { node->addMasterServer(pInfo); } |
---|
[9264] | 46 | |
---|
[9278] | 47 | inline void removeClient(NetworkNode* node, PeerInfo* pInfo) { node->removeClient(pInfo); } |
---|
[9292] | 48 | inline void removeActiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->removeActiveProxyServer(pInfo); } |
---|
[9278] | 49 | inline void removeMasterServer(NetworkNode* node, PeerInfo* pInfo) { node->removeMasterServer(pInfo); } |
---|
[9264] | 50 | |
---|
[9280] | 51 | /** @returns the total number of players in this game (including all proxy servers etc)*/ |
---|
| 52 | inline int getPlayerNumber() { return this->playerNumber; } |
---|
[9277] | 53 | |
---|
[9290] | 54 | /** @returns true if there are still free network slots available */ |
---|
[9292] | 55 | inline bool gotFreeSlots() { return (this->localNode->getPlayerNumber() < NET_MAX_CONNECTIONS)?true:false; } |
---|
| 56 | /** @param node node to be checked for slots @returns true if there are still free network slots available at this node */ |
---|
| 57 | inline bool gorFreeSlots(NetworkNode* node) { return (node->getPlayerNumber() < NET_MAX_CONNECTIONS)?true:false; } |
---|
[9290] | 58 | void getServerWithFreeSlots() { } |
---|
[9280] | 59 | |
---|
[9290] | 60 | |
---|
[9265] | 61 | void showGUI(); |
---|
[9266] | 62 | void hideGUI(); |
---|
[9264] | 63 | |
---|
| 64 | void process(); |
---|
[9285] | 65 | void debug(); |
---|
[9264] | 66 | |
---|
| 67 | |
---|
| 68 | private: |
---|
[9279] | 69 | NetworkStream* networkStream; //!< reference to the one networkstream of the network |
---|
[9282] | 70 | NetworkNode* localNode; //!< reference to the local node |
---|
[9277] | 71 | std::list<NetworkNode*> nodeList; //!< list of all network nodes |
---|
[9265] | 72 | |
---|
| 73 | OrxGui::GLGuiBox* box; |
---|
[9272] | 74 | |
---|
| 75 | int playerNumber; //!< total number of players in the game |
---|
[9263] | 76 | }; |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | #endif |
---|