Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9300 in orxonox.OLD for branches/proxy/src/lib/network/monitor


Ignore:
Timestamp:
Jul 17, 2006, 10:15:33 AM (18 years ago)
Author:
patrick
Message:

work from this weekend in the train :D

  • the ip should now synchronize over network in the handshake (always the favorite 2 proxy server ips)
  • the network monitor now keeps track of all network nodes answers with proxy server lists if asked/needed
  • it is untested :D
Location:
branches/proxy/src/lib/network/monitor
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/proxy/src/lib/network/monitor/network_monitor.cc

    r9292 r9300  
    1919#include "debug.h"
    2020
     21#include "proxy/proxy_settings.h"
     22
    2123#include "network_monitor.h"
    2224#include "network_node.h"
     25#include "peer_info.h"
    2326#include "network_stream.h"
     27#include "netdefs.h"
     28
     29#include <vector>
    2430
    2531
     
    4551
    4652  this->setSynchronized(false);
     53
     54  // assuming that the config files are already read we get the proxy servers
     55  std::vector<IPaddress*>* proxyList = &ProxySettings::getInstance()->getProxyList();
     56  std::vector<IPaddress*>::iterator it = proxyList->begin();
     57  // create a peer info class and a network node class for each new proxy and add them to the passive list
     58  for(; it < proxyList->end(); it++)
     59  {
     60    PeerInfo* peer = new PeerInfo();
     61    peer->ip = *(*it);
     62    peer->nodeType = NET_PROXY_SERVER;
     63    peer->userId = -1;
     64
     65    NetworkNode* node = new NetworkNode(peer);
     66    this->addPassiveProxyServer( this->localNode, peer);
     67  }
    4768}
    4869
     
    86107}
    87108
     109/**
     110 * tihs adds the new network node
     111 * @param ip ip of the new node
     112 */
     113void NetworkMonitor::addNode(IPaddress ip)
     114{}
     115
    88116
    89117/**
     
    128156  else if( pInfo->isMasterServer())
    129157    node->addMasterServer(pInfo);
     158}
     159
     160
     161/**
     162 * @returns the proxy server of the first choice
     163 */
     164PeerInfo* NetworkMonitor::getFirstChoiceProxy()
     165{
     166  // return the fist proxy in the list
     167  return this->localNode->getActiveProxyServer(0);
     168}
     169
     170
     171/**
     172 * @returns the proxy server of second choice
     173 */
     174PeerInfo* NetworkMonitor::getSecondChoiceProxy()
     175{
     176  // return the second server in the list
     177  return this->localNode->getActiveProxyServer(1);
    130178}
    131179
     
    185233  }
    186234
     235  // check if a proxy server has to activated
     236
    187237  this->debug();
    188238}
  • branches/proxy/src/lib/network/monitor/network_monitor.h

    r9296 r9300  
    3434    void removeNetworkNode(NetworkNode* node);
    3535
     36    void addNode(IPaddress ip);
    3637    void addNode(PeerInfo* pInfo);
    3738    void addNode(NetworkNode* node) { this->nodeList.push_back(node); }
     
    4243    /** adds to @param node a network node @param pInfo a new proxy server */
    4344    inline void addActiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->addActiveProxyServer(pInfo); }
     45    /** adds to @param node a network node @param pInfo a new proxy server */
     46    inline void addPassiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->addPassiveProxyServer(pInfo); }
    4447    /** adds to @param node a network node @param pInfo a new master server*/
    4548    inline void addMasterServer(NetworkNode* node, PeerInfo* pInfo) { node->addMasterServer(pInfo); }
     
    4750    inline void removeClient(NetworkNode* node, PeerInfo* pInfo) { node->removeClient(pInfo); }
    4851    inline void removeActiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->removeActiveProxyServer(pInfo); }
     52    inline void removePassiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->removePassiveProxyServer(pInfo); }
    4953    inline void removeMasterServer(NetworkNode* node, PeerInfo* pInfo) { node->removeMasterServer(pInfo); }
    5054
     
    5761    /** @param node node to be checked for slots @returns true if there are still free network slots available at this node */
    5862    inline bool gotFreeSlots(NetworkNode* node) { return (node->getPlayerNumber() < NET_MAX_CONNECTIONS)?true:false; }
    59     void getServerWithFreeSlots() { }
     63    PeerInfo* getFirstChoiceProxy();
     64    PeerInfo* getSecondChoiceProxy();
     65    /** @returns true if the next client should be reconnected to some other proxy server with more connections */
     66    inline bool reconnectNextClient() { return (this->localNode->getPlayerNumber() >= NET_MAX_CONNECTIONS)?true:false; }
    6067
    6168
  • branches/proxy/src/lib/network/monitor/network_node.cc

    r9292 r9300  
    147147
    148148
     149/**
     150 * @param index index to the client
     151 * @return the client in the list or NULL if none
     152 */
     153PeerInfo* NetworkNode::getClient(int index)
     154{
     155  if( this->clientList.size() < index)
     156    return NULL;
     157
     158  std::list<PeerInfo*>::iterator it = this->clientList.begin();
     159  for(int i = 0; it != this->clientList.end(); it++, i++)
     160  {
     161  if( i == index)
     162    return (*it);
     163  }
     164
     165  return NULL;
     166}
     167
     168
     169/**
     170 * @param index index to the client
     171 * @return the active proxy server in the list or NULL if none
     172 */
     173PeerInfo* NetworkNode::getActiveProxyServer(int index)
     174{
     175  if( this->activeProxyServerList.size() < index)
     176    return NULL;
     177
     178  std::list<PeerInfo*>::iterator it = this->activeProxyServerList.begin();
     179  for(int i = 0; it != this->activeProxyServerList.end(); it++, i++)
     180  {
     181    if( i == index)
     182      return (*it);
     183  }
     184
     185  return NULL;
     186}
     187
     188
     189/**
     190 * @param index index to the client
     191 * @return the passive proxy server in the list or NULL if none
     192 */
     193PeerInfo* NetworkNode::getPassiveProxyServer(int index)
     194{
     195  if( this->passiveProxyServerList.size() < index)
     196    return NULL;
     197
     198  std::list<PeerInfo*>::iterator it = this->passiveProxyServerList.begin();
     199  for(int i = 0; it != this->passiveProxyServerList.end(); it++, i++)
     200  {
     201    if( i == index)
     202      return (*it);
     203  }
     204
     205  return NULL;
     206}
     207
     208
     209/**
     210 * @param index index to the client
     211 * @return the master server in the list or NULL if none
     212 */
     213PeerInfo* NetworkNode::getMasterServer(int index)
     214{
     215  if( this->masterServerList.size() < index)
     216    return NULL;
     217
     218  std::list<PeerInfo*>::iterator it = this->masterServerList.begin();
     219  for(int i = 0; it != this->masterServerList.end(); it++, i++)
     220  {
     221    if( i == index)
     222      return (*it);
     223  }
     224
     225  return NULL;
     226}
     227
    149228
    150229/**
  • branches/proxy/src/lib/network/monitor/network_node.h

    r9292 r9300  
    3232    void removeMasterServer(PeerInfo* node);
    3333
     34    PeerInfo* getClient(int index);
     35    PeerInfo* getActiveProxyServer(int index);
     36    PeerInfo* getPassiveProxyServer(int index);
     37    PeerInfo* getMasterServer(int index);
     38
    3439    /** @returns the number of players */
    3540    inline int getPlayerNumber() { return this->playerNumber; }
Note: See TracChangeset for help on using the changeset viewer.