Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/proxy/src/lib/network/monitor/network_monitor.h @ 9431

Last change on this file since 9431 was 9431, checked in by bensch, 18 years ago

getBandwidth's

File size: 4.0 KB
Line 
1/*!
2 * @file network_monitor.h
3 *  a class to monitor the network: throughput, network nodes
4 */
5
6#ifndef _NETWORK_MONITOR_H
7#define _NETWORK_MONITOR_H
8
9#include "base_object.h"
10#include "synchronizeable.h"
11#include "shared_network_data.h"
12#include "ip.h"
13
14#include "network_node.h"
15
16#include <list>
17
18class NetworkStream;
19class PeerInfo;
20
21
22namespace OrxGui { class GLGuiBox; };
23
24
25
26//!< a class that monitors the whole network. it tries to gather all informations its able to from the network
27class NetworkMonitor : public Synchronizeable
28{
29
30  public:
31    NetworkMonitor(NetworkStream* networkStream);
32    virtual ~NetworkMonitor();
33
34    /* client/masterserver/proxyserver addition/removal interface */
35    void addNetworkNode(NetworkNode* node);
36    void removeNetworkNode(NetworkNode* node);
37
38    void addNode(PeerInfo* pInfo);
39    void addNode(const IP& ip, int nodeType);
40    void addNode(NetworkNode* node) { this->nodeList.push_back(node); }
41    void addNode(NetworkNode* node, PeerInfo* pInfo);
42
43    /** adds to @param node a network node @param pInfo a new client */
44    inline void addClient(NetworkNode* node, PeerInfo* pInfo) { node->addClient(pInfo); }
45    /** adds to @param node a network node @param pInfo a new proxy server */
46    inline void addActiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->addActiveProxyServer(pInfo); }
47    /** adds to @param node a network node @param pInfo a new proxy server */
48    inline void addPassiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->addPassiveProxyServer(pInfo); }
49    /** adds to @param node a network node @param pInfo a new master server*/
50    inline void addMasterServer(NetworkNode* node, PeerInfo* pInfo) { node->addMasterServer(pInfo); }
51
52    inline void removeClient(NetworkNode* node, PeerInfo* pInfo) { node->removeClient(pInfo); }
53    inline void removeActiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->removeActiveProxyServer(pInfo); }
54    inline void removePassiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->removePassiveProxyServer(pInfo); }
55    inline void removeMasterServer(NetworkNode* node, PeerInfo* pInfo) { node->removeMasterServer(pInfo); }
56
57    PeerInfo* getFirstChoiceProxy();
58    PeerInfo* getSecondChoiceProxy();
59
60    /** @returns the active proxy server list of the localnode */
61    inline std::list<PeerInfo*> getActiveProxyServer() { return this->localNode->getActiveProxyServer(); }
62
63    /* slots admin and info interface */
64    /** @returns the total number of players in this game (including all proxy servers etc)*/
65    inline int getPlayerNumber() { return this->playerNumber; }
66
67    /** @returns true if there are still free network slots available at the local node*/
68    inline bool gotFreeSlots() { return (this->localNode->getPlayerNumber() < SharedNetworkData::getInstance()->getMaxPlayer())?true:false; }
69    /** @param node node to be checked for slots @returns true if there are still free network slots available at this node */
70    inline bool gotFreeSlots(NetworkNode* node) { return (node->getPlayerNumber() < SharedNetworkData::getInstance()->getMaxPlayer())?true:false; }
71
72    /** @returns true if the next client should be reconnected to some other proxy server with more connections */
73    inline bool isReconnectNextClient() { return (this->localNode->getPlayerNumber() >= SharedNetworkData::getInstance()->getMaxPlayer())?true:false; }
74
75
76    void showGUI();
77    void hideGUI();
78
79    void process();
80    void debug();
81
82
83  private:
84    NetworkStream*               networkStream;              //!< reference to the one networkstream of the network
85    NetworkNode*                 localNode;                  //!< reference to the local node
86    std::list<NetworkNode*>      nodeList;                   //!< list of all network nodes
87
88    OrxGui::GLGuiBox*            box;
89
90    int                          playerNumber;                 //!< total number of players in the game
91    int                          connectionNumber;             //!< total number of connections at this localhost
92};
93
94
95#endif
Note: See TracBrowser for help on using the repository browser.