[9276] | 1 | /*! |
---|
| 2 | * @file network_node.h |
---|
| 3 | * a class representing a node in the network (this can be a MASTER_SERVER, PROXY_SERVER or a CLIENT |
---|
| 4 | */ |
---|
| 5 | |
---|
| 6 | #ifndef _NETWORK_NODE_H |
---|
| 7 | #define _NETWORK_NODE_H |
---|
| 8 | |
---|
| 9 | #include "base_object.h" |
---|
| 10 | #include "synchronizeable.h" |
---|
[9284] | 11 | #include "peer_info.h" |
---|
[9276] | 12 | |
---|
| 13 | #include <list> |
---|
| 14 | |
---|
| 15 | //!< a class representing a node in the network (this can be a MASTER_SERVER, PROXY_SERVER or a CLIENT |
---|
| 16 | class NetworkNode |
---|
| 17 | { |
---|
| 18 | public: |
---|
[9284] | 19 | NetworkNode(PeerInfo* pInfo); |
---|
[9276] | 20 | ~NetworkNode(); |
---|
| 21 | |
---|
| 22 | |
---|
[9656] | 23 | void addClient(NetworkNode* node); |
---|
| 24 | void addActiveProxyServer(NetworkNode* node); |
---|
| 25 | void addPassiveProxyServer(NetworkNode* node); |
---|
| 26 | void addMasterServer(NetworkNode* node); |
---|
[9277] | 27 | |
---|
[9656] | 28 | void removeClient(NetworkNode* node); |
---|
| 29 | void removeActiveProxyServer(NetworkNode* node); |
---|
| 30 | void removePassiveProxyServer(NetworkNode* node); |
---|
| 31 | void removeMasterServer(NetworkNode* node); |
---|
[9277] | 32 | |
---|
[9656] | 33 | void removeClient(int userId); |
---|
| 34 | void removeActiveProxyServer(int userId); |
---|
| 35 | void removePassiveProxyServer(int userId); |
---|
| 36 | void removeMasterServer(int userId); |
---|
| 37 | |
---|
| 38 | |
---|
[9494] | 39 | PeerInfo* getClient(int index) const; |
---|
| 40 | PeerInfo* getActiveProxyServer(int index) const; |
---|
| 41 | PeerInfo* getPassiveProxyServer(int index) const; |
---|
| 42 | PeerInfo* getMasterServer(int index) const; |
---|
[9300] | 43 | |
---|
[9396] | 44 | /** @returns the master server list */ |
---|
[9656] | 45 | inline std::list<NetworkNode*> getMasterServers() const { return this->masterServerList; } |
---|
[9396] | 46 | /** @returns the active proxy server list */ |
---|
[9656] | 47 | inline std::list<NetworkNode*> getActiveProxyServers() const { return this->activeProxyServerList; } |
---|
[9396] | 48 | /** @returns the passive proxy server list */ |
---|
[9656] | 49 | inline std::list<NetworkNode*> getPassiveProxyServers() const { return this->passiveProxyServerList; } |
---|
[9396] | 50 | /** @returns the client list */ |
---|
[9656] | 51 | inline std::list<NetworkNode*> getClients() const { return this->clientList; } |
---|
[9396] | 52 | |
---|
[9656] | 53 | PeerInfo* getPeerByUserId( int userId); |
---|
[9396] | 54 | |
---|
[9279] | 55 | /** @returns the number of players */ |
---|
[9494] | 56 | inline int getPlayerNumber() const { return this->playerNumber; } |
---|
[9279] | 57 | /** @returns the node type of this node */ |
---|
[9494] | 58 | inline int getNodeType() const { return this->peerInfo->nodeType; } |
---|
[9286] | 59 | /** @returns the peer info of this node */ |
---|
[9494] | 60 | inline PeerInfo* getPeerInfo() const { return this->peerInfo; } |
---|
[9277] | 61 | |
---|
[9656] | 62 | NetworkNode* getNodeByUserId( int userId); |
---|
| 63 | |
---|
[9494] | 64 | void debug(int depth) const; |
---|
[9277] | 65 | |
---|
[9288] | 66 | |
---|
[9276] | 67 | private: |
---|
[9277] | 68 | int playerNumber; //!< localy direct connected player number |
---|
[9404] | 69 | int connectionNumber; //!< number of connections ( can but musn't be equal players) |
---|
[9494] | 70 | PeerInfo* peerInfo; //!< the peer information about this node |
---|
[9276] | 71 | |
---|
[9277] | 72 | /* network nodes directly connected to this node */ |
---|
[9656] | 73 | std::list<NetworkNode*> clientList; //!< list of all clients in the network |
---|
| 74 | std::list<NetworkNode*> activeProxyServerList; //!< list of all proxy servers in the network |
---|
| 75 | std::list<NetworkNode*> passiveProxyServerList; //!< list of all proxy servers in the network |
---|
| 76 | std::list<NetworkNode*> masterServerList; //!< list of all master servers in the network (should be 1!! :D) |
---|
[9276] | 77 | |
---|
| 78 | }; |
---|
| 79 | |
---|
| 80 | #endif /* _NETWORK_NODE_H */ |
---|