| 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" |
|---|
| 11 | #include "peer_info.h" |
|---|
| 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: |
|---|
| 20 | NetworkNode(PeerInfo* pInfo); |
|---|
| 21 | ~NetworkNode(); |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | void addClient(PeerInfo* node); |
|---|
| 25 | void addActiveProxyServer(PeerInfo* node); |
|---|
| 26 | void addPassiveProxyServer(PeerInfo* node); |
|---|
| 27 | void addMasterServer(PeerInfo* node); |
|---|
| 28 | |
|---|
| 29 | void removeClient(PeerInfo* node); |
|---|
| 30 | void removeActiveProxyServer(PeerInfo* node); |
|---|
| 31 | void removePassiveProxyServer(PeerInfo* node); |
|---|
| 32 | void removeMasterServer(PeerInfo* node); |
|---|
| 33 | |
|---|
| 34 | PeerInfo* getClient(int index); |
|---|
| 35 | PeerInfo* getActiveProxyServer(int index); |
|---|
| 36 | PeerInfo* getPassiveProxyServer(int index); |
|---|
| 37 | PeerInfo* getMasterServer(int index); |
|---|
| 38 | |
|---|
| 39 | /** @returns the master server list */ |
|---|
| 40 | inline std::list<PeerInfo*> getMasterServer() { return this->masterServerList; } |
|---|
| 41 | /** @returns the active proxy server list */ |
|---|
| 42 | inline std::list<PeerInfo*> getActiveProxyServer() { return this->activeProxyServerList; } |
|---|
| 43 | /** @returns the passive proxy server list */ |
|---|
| 44 | inline std::list<PeerInfo*> getPassiveProxyServer() { return this->passiveProxyServerList; } |
|---|
| 45 | /** @returns the client list */ |
|---|
| 46 | inline std::list<PeerInfo*> getClient() { return this->clientList; } |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | /** @returns the number of players */ |
|---|
| 50 | inline int getPlayerNumber() { return this->playerNumber; } |
|---|
| 51 | /** @returns the node type of this node */ |
|---|
| 52 | inline int getNodeType() { return this->peerInfo->nodeType; } |
|---|
| 53 | /** @returns the peer info of this node */ |
|---|
| 54 | inline PeerInfo* getPeerInfo() { return this->peerInfo; } |
|---|
| 55 | |
|---|
| 56 | void debug(int depth); |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | private: |
|---|
| 60 | int playerNumber; //!< localy direct connected player number |
|---|
| 61 | int connectionNumber; //!< number of connections ( can but musn't be equal players) |
|---|
| 62 | PeerInfo* peerInfo; //!< the peer informationa about this node |
|---|
| 63 | |
|---|
| 64 | /* network nodes directly connected to this node */ |
|---|
| 65 | std::list<PeerInfo*> clientList; //!< list of all clients in the network |
|---|
| 66 | std::list<PeerInfo*> activeProxyServerList; //!< list of all proxy servers in the network |
|---|
| 67 | std::list<PeerInfo*> passiveProxyServerList; //!< list of all proxy servers in the network |
|---|
| 68 | std::list<PeerInfo*> masterServerList; //!< list of all master servers in the network (should be 1!! :D) |
|---|
| 69 | |
|---|
| 70 | }; |
|---|
| 71 | |
|---|
| 72 | #endif /* _NETWORK_NODE_H */ |
|---|