Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

proxy server ip synchronizeing bug, nodes get registered

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