Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 4, 2006, 11:01:28 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the proxy bache back with no conflicts

File:
1 edited

Legend:

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

    r9494 r9656  
    1010
    1111### File Specific:
    12    main-programmer: Patrick Boenzli
     12   main-programmer: Patrick Boenzli (patrick@orxonox.ethz.ch)
    1313*/
    1414
     
    4949  this->networkStream = networkStream;
    5050  this->playerNumber = 0;
     51  this->connectionNumber = 0;
    5152  // create the localnode, init it and add it to the nodes list
    5253  this->localNode = new NetworkNode( this->networkStream->getPeerInfo());
     
    6667      PeerInfo* peer = new PeerInfo();
    6768      peer->ip = (*it);
    68       peer->nodeType = NET_PROXY_SERVER_ACTIVE;
     69      peer->nodeType = NET_PROXY_SERVER_PASSIVE;
    6970      peer->userId = -1;
    7071
    71       NetworkNode* node = new NetworkNode(peer);
    72       this->addNode( node);
    7372      this->addActiveProxyServer( this->localNode, peer);
    7473    }
     
    141140    return;
    142141
     142  PRINTF(0)("^^^^^^^^^^^^^^^^^^^^^^^^^^ adding node: %i with type: %s\n\n", pInfo->userId, pInfo->getNodeTypeString().c_str());
     143
    143144  if( pInfo->isClient())
    144     this->localNode->addClient(pInfo);
     145  {
     146    this->localNode->addClient(new NetworkNode(pInfo));
     147  }
    145148  else if( pInfo->isProxyServerActive())
    146149  {
    147     this->localNode->addActiveProxyServer(pInfo);
    148     // create a new node, since a proxy can connect clients again
    149     NetworkNode* node = new NetworkNode(pInfo);
    150     this->nodeList.push_back(node);
     150    this->localNode->addActiveProxyServer(new NetworkNode(pInfo));
     151  }
     152  else if( pInfo->isProxyServerActivePassive())
     153  {
     154    this->localNode->addPassiveProxyServer(new NetworkNode(pInfo));
    151155  }
    152156  else if( pInfo->isMasterServer())
    153157  {
    154     this->localNode->addMasterServer(pInfo);
    155   }
     158    this->localNode->addMasterServer(new NetworkNode(pInfo));
     159  }
     160  else
     161    assert(false);
    156162}
    157163
     
    168174
    169175  if( pInfo->isClient())
    170     node->addClient(pInfo);
     176    node->addClient(new NetworkNode(pInfo));
    171177  else if( pInfo->isProxyServerActive())
    172     node->addActiveProxyServer(pInfo);
     178    node->addActiveProxyServer(new NetworkNode(pInfo));
    173179  else if( pInfo->isMasterServer())
    174     node->addMasterServer(pInfo);
     180    node->addMasterServer(new NetworkNode(pInfo));
     181}
     182
     183
     184
     185/**
     186 * removes a node from the network monitor
     187 * @param pInfo the node to remove
     188 */
     189void NetworkMonitor::removeNode(PeerInfo* pInfo)
     190{
     191  this->removeNode(this->localNode, pInfo);
     192}
     193
     194
     195/**
     196 * removes the network node
     197 * @param node the network node where the PeerInfo node is connected to
     198 * @param pInfo the PeerInfo to remove
     199 */
     200void NetworkMonitor::removeNode(NetworkNode* node, PeerInfo* pInfo)
     201{
     202  if( node == NULL || pInfo == NULL)
     203    return;
     204
     205  if( pInfo->isClient())
     206    node->removeClient(pInfo->userId);
     207  else if( pInfo->isProxyServerActive())
     208    node->removeActiveProxyServer(pInfo->userId);
     209  else if( pInfo->isMasterServer())
     210    node->removeMasterServer(pInfo->userId);
    175211}
    176212
     
    197233
    198234/**
     235 * @param userId of the searched node
     236 * @returns the PeerInfo of the userId peer
     237 */
     238PeerInfo* NetworkMonitor::getPeerByUserId( int userId)
     239{
     240  NetworkNode* node = this->getNodeByUserId(userId);
     241  if( node != NULL)
     242    return node->getPeerInfo();
     243
     244  return NULL;
     245}
     246
     247/**
     248 * searches for a given NetworkNode
     249 * @param userId of the searched node
     250 * @returns the PeerInfo of the userId peer
     251 */
     252NetworkNode* NetworkMonitor::getNodeByUserId( int userId)
     253{
     254  std::list<NetworkNode*>::iterator it = this->nodeList.begin();
     255  NetworkNode* node = NULL;
     256  for(; it != this->nodeList.end(); it++)
     257  {
     258    node = (*it)->getNodeByUserId(userId);
     259    if( node != NULL)
     260      return node;
     261  }
     262
     263  return NULL;
     264}
     265
     266
     267/**
    199268 * this displays the network monitor gui
    200269 */
     
    203272  if (this->box == NULL)
    204273  {
    205     this->box = new OrxGui::GLGuiBox(OrxGui::Vertical);
    206     {
    207       NetworkStatsWidget* netStats = new NetworkStatsWidget(this);
    208       this->box->pack(netStats);
    209 
    210     }
    211 
     274    this->box = new NetworkStatsWidget(this);
    212275    this->box->showAll();
    213     this->box->setAbsCoor2D(300, 40);
    214276  }
    215277  else
     
    251313  for(; it != this->nodeList.end(); it++)
    252314  {
    253     (*it)->debug(0);
     315    (*it)->debug(1);
    254316  }
    255317
Note: See TracChangeset for help on using the changeset viewer.