Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

redirection flag added, proxy settings as a way to get/save the server settings

File size: 2.9 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(NetworkNode* node) { this->nodeList.push_back(node); }
38    void addNode(NetworkNode* node, PeerInfo* pInfo);
39
40    /** adds to @param node a network node @param pInfo a new client */
41    inline void addClient(NetworkNode* node, PeerInfo* pInfo) { node->addClient(pInfo); }
42    /** adds to @param node a network node @param pInfo a new proxy server */
43    inline void addActiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->addActiveProxyServer(pInfo); }
44    /** adds to @param node a network node @param pInfo a new master server*/
45    inline void addMasterServer(NetworkNode* node, PeerInfo* pInfo) { node->addMasterServer(pInfo); }
46
47    inline void removeClient(NetworkNode* node, PeerInfo* pInfo) { node->removeClient(pInfo); }
48    inline void removeActiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->removeActiveProxyServer(pInfo); }
49    inline void removeMasterServer(NetworkNode* node, PeerInfo* pInfo) { node->removeMasterServer(pInfo); }
50
51    /* slots admin and info interface */
52    /** @returns the total number of players in this game (including all proxy servers etc)*/
53    inline int getPlayerNumber() { return this->playerNumber; }
54
55    /** @returns true if there are still free network slots available */
56    inline bool gotFreeSlots() { return (this->localNode->getPlayerNumber() < NET_MAX_CONNECTIONS)?true:false; }
57    /** @param node node to be checked for slots @returns true if there are still free network slots available at this node */
58    inline bool gotFreeSlots(NetworkNode* node) { return (node->getPlayerNumber() < NET_MAX_CONNECTIONS)?true:false; }
59    void getServerWithFreeSlots() { }
60
61
62    void showGUI();
63    void hideGUI();
64
65    void process();
66    void debug();
67
68
69  private:
70    NetworkStream*               networkStream;              //!< reference to the one networkstream of the network
71    NetworkNode*                 localNode;                  //!< reference to the local node
72    std::list<NetworkNode*>      nodeList;                   //!< list of all network nodes
73
74    OrxGui::GLGuiBox*            box;
75
76    int                          playerNumber;                 //!< total number of players in the game
77};
78
79
80#endif
Note: See TracBrowser for help on using the repository browser.