Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9430 in orxonox.OLD for branches/proxy


Ignore:
Timestamp:
Jul 24, 2006, 3:59:16 PM (18 years ago)
Author:
patrick
Message:

redirection stuck

File:
1 edited

Legend:

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

    r9425 r9430  
    203203  PRINTF(0)("connect to proxy %s, this is node %i\n", host.c_str(), node);
    204204
     205  if( this->peers[node].socket != NULL)
     206    delete this->peers[node].socket;
     207
    205208  this->peers[node].socket = new UdpSocket( host, port );
    206209  this->peers[node].userId = 0;
     
    437440
    438441#warning this is some more disconnct handling, consider doing it in the handleDisconnect() funciton
    439 //       // and cleanup the user infos
    440 //       for ( SynchronizeableList::iterator it2 = synchronizeables.begin(); it2 != synchronizeables.end(); it2++ )
    441 //       {
    442 //         (*it2)->cleanUpUser( it->second.userId );
    443 //       }
    444 //
    445 //       NetworkGameManager::getInstance()->signalLeftPlayer(it->second.userId);
    446 //
    447 //       freeSocketSlots.push_back( it->second.userId );
    448 //
    449 //       PeerList::iterator delit = it;
    450 //       it++;
    451 //
    452 //       peers.erase( delit );
     442      // and cleanup the user infos
     443      for ( SynchronizeableList::iterator it2 = synchronizeables.begin(); it2 != synchronizeables.end(); it2++ )
     444      {
     445        (*it2)->cleanUpUser( it->second.userId );
     446      }
     447
     448      NetworkGameManager::getInstance()->signalLeftPlayer(it->second.userId);
     449
     450      freeSocketSlots.push_back( it->second.userId );
     451
     452      PeerList::iterator delit = it;
     453      it++;
     454
     455      peers.erase( delit );
    453456
    454457      continue;
     
    520523          {
    521524            // make sure this is a client
    522             assert( this->pInfo->isClient());
    523 
    524             SharedNetworkData::getInstance()->setHostID( it->second.handshake->getHostId() );
    525             this->pInfo->userId = SharedNetworkData::getInstance()->getHostID();
    526 
    527             it->second.nodeType = it->second.handshake->getRemoteNodeType();
    528             it->second.ip = it->second.socket->getRemoteAddress();
     525            if( this->pInfo->isClient())
     526            {
     527              SharedNetworkData::getInstance()->setHostID( it->second.handshake->getHostId() );
     528              this->pInfo->userId = SharedNetworkData::getInstance()->getHostID();
     529
     530              it->second.nodeType = it->second.handshake->getRemoteNodeType();
     531              it->second.ip = it->second.socket->getRemoteAddress();
    529532              // add the new server to the nodes list (it can be a NET_MASTER_SERVER or NET_PROXY_SERVER)
    530             this->networkMonitor->addNode(&it->second);
     533              this->networkMonitor->addNode(&it->second);
    531534              // get proxy 1 address and add it
    532             this->networkMonitor->addNode(it->second.handshake->getProxy1Address(), NET_PROXY_SERVER_ACTIVE);
     535              this->networkMonitor->addNode(it->second.handshake->getProxy1Address(), NET_PROXY_SERVER_ACTIVE);
    533536              // get proxy 2 address and add it
    534             this->networkMonitor->addNode(it->second.handshake->getProxy2Address(), NET_PROXY_SERVER_ACTIVE);
     537              this->networkMonitor->addNode(it->second.handshake->getProxy2Address(), NET_PROXY_SERVER_ACTIVE);
    535538
    536539              // now check if the server accepted the connection
    537             if( !it->second.handshake->redirect())
    538             {
    539                 // create the new network game manager and init it
     540
     541              // create the new network game manager and init it
    540542              this->networkGameManager = NetworkGameManager::getInstance();
    541543              this->networkGameManager->setUniqueID( it->second.handshake->getNetworkGameManagerId() );
    542544              // init the new message manager
    543545              MessageManager::getInstance()->setUniqueID( it->second.handshake->getMessageManagerId() );
    544 
    545               PRINT(0)("handshake finished id=%d\n", it->second.handshake->getNetworkGameManagerId());
    546               it->second.handshake->del();
    547546            }
    548             else
    549               this->handleReconnect( it->second.userId);
     547
     548            PRINT(0)("handshake finished id=%d\n", it->second.handshake->getNetworkGameManagerId());
     549            it->second.handshake->del();
    550550
    551551          }
     
    600600    }
    601601  }
     602
     603
     604//   for ( PeerList::iterator it = peers.begin(); it != peers.end(); it++ )
     605//   {
     606//     if( !it->second.handshake->redirect())
     607//     {
     608//       if( SharedNetworkData::getInstance()->isClient())
     609//       {
     610//         this->handleReconnect( it->second.userId);
     611//         return;
     612//       }
     613//     }
     614//   }
    602615}
    603616
     
    618631
    619632  // reject the server
    620   pInfo->handshake->doReject( "redirected to different server");
    621   pInfo->handshake->del();
     633//   pInfo->handshake->doReject( "redirected to different server");
     634//   pInfo->handshake->del();
    622635
    623636  // flush the old synchronization states, since the numbering could be completely different
     
    631644//   pInfo->socket->reconnectToServer( proxyIP.ipString(), proxyIP.port());
    632645  this->handleDisconnect( userId);
    633   this->connectToProxyServer(proxyIP.ipString(), 9999);
     646//   this->connectToProxyServer(proxyIP.ipString(), 9999);
    634647#warning the ports are not yet integrated correctly in the ip class
    635648
    636649  // and restart the handshake
    637   this->startHandshake( userId);
     650//   this->startHandshake( userId);
    638651}
    639652
     
    658671
    659672
    660   for ( SynchronizeableList::iterator it2 = synchronizeables.begin(); it2 != synchronizeables.end(); it2++ )  {
    661     (*it2)->cleanUpUser( userId );
    662   }
    663 
    664 //   NetworkGameManager::getInstance()->signalLeftPlayer(userId);
    665 
    666   this->freeSocketSlots.push_back( userId );
    667 
    668   peers.erase( userId );
     673//   for ( SynchronizeableList::iterator it2 = synchronizeables.begin(); it2 != synchronizeables.end(); it2++ )  {
     674//     (*it2)->cleanUpUser( userId );
     675//   }
     676//
     677// //   NetworkGameManager::getInstance()->signalLeftPlayer(userId);
     678//
     679//   this->freeSocketSlots.push_back( userId );
     680//
     681//   peers.erase( userId );
     682
     683//   this->pInfo->userId = 0;
     684//   this->pInfo->lastAckedState = 0;
     685//   this->pInfo->lastRecvedState = 0;
     686//   this->pInfo->connectionMonitor = NULL;
     687//   this->pInfo->handshake = NULL;
     688//   this->pInfo->socket = NULL;
     689//   this->pInfo->nodeType = NET_CLIENT;
    669690}
    670691
Note: See TracChangeset for help on using the changeset viewer.