Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9637 in orxonox.OLD


Ignore:
Timestamp:
Jul 31, 2006, 3:16:35 AM (18 years ago)
Author:
patrick
Message:

the node registration now works perfectly and hirarchicaly

Location:
branches/proxy/src/lib/network
Files:
4 edited

Legend:

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

    r9625 r9637  
    238238PeerInfo* NetworkMonitor::getPeerByUserId( int userId)
    239239{
    240   PeerInfo* pInfo;
    241   std::list<NetworkNode*>::iterator it = this->nodeList.begin();
    242   for(; it != this->nodeList.end(); it++)
    243   {
    244     pInfo = (*it)->getPeerByUserId(userId);
    245     if( pInfo != NULL)
    246       return pInfo;
    247   }
     240  NetworkNode* node = this->getNodeByUserId(userId);
     241  if( node != NULL)
     242    return node->getPeerInfo();
     243
    248244  return NULL;
    249245}
     
    257253{
    258254  std::list<NetworkNode*>::iterator it = this->nodeList.begin();
     255  NetworkNode* node = NULL;
    259256  for(; it != this->nodeList.end(); it++)
    260257  {
    261     PRINTF(0)("comparing %i to %i\n", (*it)->getPeerInfo()->userId, userId);
    262     if( (*it)->getPeerInfo()->userId == userId)
    263       return (*it);
    264   }
     258    node = (*it)->getNodeByUserId(userId);
     259    if( node != NULL)
     260      return node;
     261  }
     262
    265263  return NULL;
    266264}
  • branches/proxy/src/lib/network/monitor/network_node.cc

    r9625 r9637  
    352352
    353353
     354
     355/**
     356 * searches for a given NetworkNode
     357 * @param userId of the searched node
     358 * @returns the PeerInfo of the userId peer
     359 */
     360NetworkNode* NetworkNode::getNodeByUserId( int userId)
     361{
     362  if( this->peerInfo->userId == userId)
     363    return this;
     364
     365
     366  NetworkNode* node = NULL;
     367  std::list<NetworkNode*>::iterator it = this->masterServerList.begin();
     368
     369  for(; it != this->masterServerList.end(); it++)
     370  {
     371    node = (*it)->getNodeByUserId(userId);
     372    if( node != NULL)
     373      return node;
     374  }
     375
     376  it = this->activeProxyServerList.begin();
     377  for(; it != this->activeProxyServerList.end(); it++)
     378  {
     379    node = (*it)->getNodeByUserId(userId);
     380    if( node != NULL)
     381      return node;
     382  }
     383
     384  it = this->passiveProxyServerList.begin();
     385  for(; it != this->passiveProxyServerList.end(); it++)
     386  {
     387    node = (*it)->getNodeByUserId(userId);
     388    if( node != NULL)
     389      return node;
     390  }
     391
     392  it = this->clientList.begin();
     393  for(; it != this->clientList.end(); it++)
     394  {
     395    node = (*it)->getNodeByUserId(userId);
     396    if( node != NULL)
     397      return node;
     398  }
     399
     400  return NULL;
     401}
     402
     403
    354404/**
    355405 * debug function
     
    362412  indent[depth] = '\0';
    363413
    364   PRINT(0)("%s + %s, with ip: %s\n", indent,  this->peerInfo->getNodeTypeString().c_str(), this->peerInfo->ip.ipString().c_str());
     414  PRINT(0)("%s + %s, with id %i and ip: %s\n", indent, this->peerInfo->getNodeTypeString().c_str(), this->peerInfo->userId, this->peerInfo->ip.ipString().c_str());
    365415  std::list<NetworkNode*>::const_iterator it;
    366416  if( !this->masterServerList.empty())
  • branches/proxy/src/lib/network/monitor/network_node.h

    r9625 r9637  
    6161    inline PeerInfo* getPeerInfo() const { return this->peerInfo; }
    6262
     63    NetworkNode* getNodeByUserId( int userId);
     64
    6365    void debug(int depth) const;
    6466
  • branches/proxy/src/lib/network/proxy/proxy_control.cc

    r9625 r9637  
    137137  NetworkMonitor* netMon = SharedNetworkData::getInstance()->getNetworkMonitor();
    138138  NetworkNode* nNode = netMon->getNodeByUserId(senderId); // this gets the proxy server who sent the msg
     139  if( nNode == NULL)
     140    PRINTF(0)("Couldn't find node %i! Error\n", senderId);
    139141  PeerInfo* pInfo = new PeerInfo();
    140142  pInfo->bLocal = false;
     
    144146  netMon->addNode(nNode, pInfo);
    145147
    146   PRINTF(0)("Got Signal: from %i new player arrived with userId: %i and ip: %i\n", senderId, newClientId, pInfo->ip.ipString().c_str());
     148  PRINTF(0)("Got Signal: from %i new player arrived with userId: %i and ip: %s on %i\n", senderId, newClientId, pInfo->ip.ipString().c_str(), senderId);
    147149  // part for the master server
    148150  if( SharedNetworkData::getInstance()->isMasterServer())
Note: See TracChangeset for help on using the changeset viewer.