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