Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/proxy: merged the proxy.old back again, and it seems to work.

Merged with command
svn merge -r9247:HEAD https://svn.orxonox.net/orxonox/branches/proxy.old .

no conflicts

File size: 3.7 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(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    /* slots admin and info interface */
58    /** @returns the total number of players in this game (including all proxy servers etc)*/
59    inline int getPlayerNumber() { return this->playerNumber; }
60
61    /** @returns true if there are still free network slots available */
62    inline bool gotFreeSlots() { return (this->localNode->getPlayerNumber() < SharedNetworkData::getInstance()->getMaxPlayer())?true:false; }
63    /** @param node node to be checked for slots @returns true if there are still free network slots available at this node */
64    inline bool gotFreeSlots(NetworkNode* node) { return (node->getPlayerNumber() < SharedNetworkData::getInstance()->getMaxPlayer())?true:false; }
65    PeerInfo* getFirstChoiceProxy();
66    PeerInfo* getSecondChoiceProxy();
67    /** @returns true if the next client should be reconnected to some other proxy server with more connections */
68    inline bool isReconnectNextClient() { return (this->localNode->getPlayerNumber() >= SharedNetworkData::getInstance()->getMaxPlayer())?true:false; }
69
70
71    void showGUI();
72    void hideGUI();
73
74    void process();
75    void debug();
76
77
78  private:
79    NetworkStream*               networkStream;              //!< reference to the one networkstream of the network
80    NetworkNode*                 localNode;                  //!< reference to the local node
81    std::list<NetworkNode*>      nodeList;                   //!< list of all network nodes
82
83    OrxGui::GLGuiBox*            box;
84
85    int                          playerNumber;                 //!< total number of players in the game
86};
87
88
89#endif
Note: See TracBrowser for help on using the repository browser.