Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9589 in orxonox.OLD for branches/proxy/src/lib


Ignore:
Timestamp:
Jul 28, 2006, 11:32:05 PM (18 years ago)
Author:
patrick
Message:

now the nodes get added in hirarchical way

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

Legend:

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

    r9586 r9589  
    227227
    228228/**
     229 * @param userId of the searched node
     230 * @returns the PeerInfo of the userId peer
     231 */
     232PeerInfo* NetworkMonitor::getPeerByUserId( int userId)
     233{
     234  PeerInfo* pInfo;
     235  std::list<NetworkNode*>::iterator it = this->nodeList.begin();
     236  for(; it != this->nodeList.end(); it++)
     237  {
     238    pInfo = (*it)->getPeerByUserId(userId);
     239    if( pInfo != NULL)
     240      return pInfo;
     241  }
     242  return NULL;
     243}
     244
     245/**
     246 * searches for a given NetworkNode
     247 * @param userId of the searched node
     248 * @returns the PeerInfo of the userId peer
     249 */
     250NetworkNode* NetworkMonitor::getNodeByUserId( int userId)
     251{
     252  std::list<NetworkNode*>::iterator it = this->nodeList.begin();
     253  for(; it != this->nodeList.end(); it++)
     254  {
     255    if( (*it)->getPeerInfo()->userId == userId)
     256      return (*it);
     257  }
     258  return NULL;
     259}
     260
     261
     262/**
    229263 * this displays the network monitor gui
    230264 */
  • branches/proxy/src/lib/network/monitor/network_monitor.h

    r9586 r9589  
    7979
    8080    inline const std::list<NetworkNode*>& getNodeList() const { return this->nodeList; };
    81     /** @param userId of the searched node @returns the PeerInfo of the userId peer */
    82     inline PeerInfo* getPeerByUserId( int userId) { return this->localNode->getPeerByUserId(userId); }
     81    PeerInfo* getPeerByUserId( int userId);
     82    NetworkNode* getNodeByUserId( int userId);
    8383
    8484
  • branches/proxy/src/lib/network/proxy/proxy_control.cc

    r9586 r9589  
    130130  // register the new node at the network monitor
    131131  NetworkMonitor* netMon = SharedNetworkData::getInstance()->getNetworkMonitor();
     132  NetworkNode* nNode = netMon->getNodeByUserId(senderId); // this gets the proxy server who sent the msg
    132133  PeerInfo* pInfo = new PeerInfo();
    133134  pInfo->bLocal = false;
     
    135136  pInfo->nodeType = NET_CLIENT;
    136137  pInfo->userId = newClientId;
    137   netMon->addNode(pInfo);
     138  netMon->addNode(nNode, pInfo);
    138139
    139140  PRINTF(0)("Got Signal: from %i new player arrived with userId: %i and ip: %i\n", senderId, newClientId, pInfo->ip.ipString().c_str());
     
    193194  // remove the node from the network monitor
    194195  NetworkMonitor* netMon = SharedNetworkData::getInstance()->getNetworkMonitor();
    195   netMon->removeNode( netMon->getPeerByUserId(leaveClientId));
     196  NetworkNode* nNode = netMon->getNodeByUserId(senderId); // this gets the proxy server who sent the msg
     197  netMon->removeNode(nNode, netMon->getPeerByUserId(leaveClientId));
    196198
    197199  PRINTF(0)("Got Signal: from %i new player left with userId: %i\n", senderId, leaveClientId);
Note: See TracChangeset for help on using the changeset viewer.