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 | |
---|
16 | class NetworkStream; |
---|
17 | class PeerInfo; |
---|
18 | |
---|
19 | |
---|
20 | namespace 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 |
---|
25 | class 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 | inline void addClient(NetworkNode* node, PeerInfo* pInfo) { node->addClient(pInfo); } |
---|
37 | inline void addProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->addProxyServer(pInfo); } |
---|
38 | inline void addMasterServer(NetworkNode* node, PeerInfo* pInfo) { node->addMasterServer(pInfo); } |
---|
39 | |
---|
40 | inline void removeClient(NetworkNode* node, PeerInfo* pInfo) { node->removeClient(pInfo); } |
---|
41 | inline void removeProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->removeProxyServer(pInfo); } |
---|
42 | inline void removeMasterServer(NetworkNode* node, PeerInfo* pInfo) { node->removeMasterServer(pInfo); } |
---|
43 | |
---|
44 | /** @returns the total number of players in this game (including all proxy servers etc)*/ |
---|
45 | inline int getPlayerNumber() { return this->playerNumber; } |
---|
46 | |
---|
47 | |
---|
48 | void showGUI(); |
---|
49 | void hideGUI(); |
---|
50 | |
---|
51 | void process(); |
---|
52 | |
---|
53 | |
---|
54 | private: |
---|
55 | NetworkStream* networkStream; //!< reference to the one networkstream of the network |
---|
56 | std::list<NetworkNode*> nodeList; //!< list of all network nodes |
---|
57 | |
---|
58 | OrxGui::GLGuiBox* box; |
---|
59 | |
---|
60 | int playerNumber; //!< total number of players in the game |
---|
61 | }; |
---|
62 | |
---|
63 | |
---|
64 | #endif |
---|