Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9422 in orxonox.OLD for branches


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

made the network stream interface more flexible in terms of connection reestablishing and fixed some segfaults connected to connection restarts

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

Legend:

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

    r9406 r9422  
    165165  this->networkStream->startHandshake();
    166166
    167   PRINTF(0)("Created Network Client");
     167  PRINTF(0)("Created Network Client\n");
    168168  return 1;
    169169}
  • branches/proxy/src/lib/network/network_stream.cc

    r9420 r9422  
    236236 * handsakes are always initialized from the client side first. this starts the handshake and therefore is only
    237237 * executed as client
    238  */
    239 void NetworkStream::startHandshake()
     238 * @param userId: start handshake for this user id (optional, default == 0)
     239 */
     240void NetworkStream::startHandshake(int userId)
    240241{
    241242  Handshake* hs = new Handshake(this->pInfo->nodeType);
    242243  hs->setUniqueID( 0 );
    243   assert( peers[0].handshake == NULL );
    244   peers[0].handshake = hs;
     244  assert( peers[userId].handshake == NULL );
     245  peers[userId].handshake = hs;
    245246
    246247  // set the preferred nick name
     
    255256 * it all over the network and creating it on the other platforms (if and only if it is a
    256257 * server
     258 * @param sync: the synchronizeable to add
    257259 */
    258260void NetworkStream::connectSynchronizeable(Synchronizeable& sync)
     
    260262  this->synchronizeables.push_back(&sync);
    261263  sync.setNetworkStream( this );
    262 
    263 //   this->bActive = true;
    264264}
    265265
     
    267267/**
    268268 * removes the synchronizeable from the list of synchronized entities
     269 * @param sync: the syncronizeable to remove
    269270 */
    270271void NetworkStream::disconnectSynchronizeable(Synchronizeable& sync)
     
    434435
    435436#warning this is some more disconnct handling, consider doing it in the handleDisconnect() funciton
    436       // and cleanup the user infos
    437       for ( SynchronizeableList::iterator it2 = synchronizeables.begin(); it2 != synchronizeables.end(); it2++ )
    438       {
    439         (*it2)->cleanUpUser( it->second.userId );
    440       }
    441 
    442       NetworkGameManager::getInstance()->signalLeftPlayer(it->second.userId);
    443 
    444       freeSocketSlots.push_back( it->second.userId );
    445 
    446       PeerList::iterator delit = it;
    447       it++;
    448 
    449       peers.erase( delit );
     437//       // and cleanup the user infos
     438//       for ( SynchronizeableList::iterator it2 = synchronizeables.begin(); it2 != synchronizeables.end(); it2++ )
     439//       {
     440//         (*it2)->cleanUpUser( it->second.userId );
     441//       }
     442//
     443//       NetworkGameManager::getInstance()->signalLeftPlayer(it->second.userId);
     444//
     445//       freeSocketSlots.push_back( it->second.userId );
     446//
     447//       PeerList::iterator delit = it;
     448//       it++;
     449//
     450//       peers.erase( delit );
    450451
    451452      continue;
     
    532533
    533534              // now check if the server accepted the connection
    534               if( it->second.handshake->redirect())
     535              if( !it->second.handshake->redirect())
     536              {
     537                // create the new network game manager and init it
     538                this->networkGameManager = NetworkGameManager::getInstance();
     539                this->networkGameManager->setUniqueID( it->second.handshake->getNetworkGameManagerId() );
     540              // init the new message manager
     541                MessageManager::getInstance()->setUniqueID( it->second.handshake->getMessageManagerId() );
     542
     543                PRINT(0)("handshake finished id=%d\n", it->second.handshake->getNetworkGameManagerId());
     544                it->second.handshake->del();
     545              }
     546              else
    535547                this->handleReconnect( it->second.userId);
    536548
    537               // create the new network game manager and init it
    538               this->networkGameManager = NetworkGameManager::getInstance();
    539               this->networkGameManager->setUniqueID( it->second.handshake->getNetworkGameManagerId() );
    540               // init the new message manager
    541               MessageManager::getInstance()->setUniqueID( it->second.handshake->getMessageManagerId() );
    542549            }
    543 
    544 
    545             PRINT(0)("handshake finished id=%d\n", it->second.handshake->getNetworkGameManagerId());
    546             it->second.handshake->del();
     550            else
     551              assert(false);
     552
     553
     554
    547555          }
    548556          else
     
    609617  PRINTF(0)("===============================================\n");
    610618  PRINTF(0)("Client is redirected to the other proxy servers\n");
     619  PRINTF(0)("  user id: %i\n", userId);
    611620  PRINTF(0)("  connecting to: %s\n", pInfo->handshake->getProxy1Address().ipString().c_str());
    612621  PRINTF(0)("===============================================\n");
     
    622631  IP proxyIP = pInfo->handshake->getProxy1Address();
    623632
    624   // not sure if this works as expected
    625   if( pInfo->handshake)
    626     delete pInfo->handshake;
    627 
    628633  // disconnect from the current server and reconnect to proxy server
    629   pInfo->socket->reconnectToServer( proxyIP.ipString(), proxyIP.port());
     634//   pInfo->socket->reconnectToServer( proxyIP.ipString(), proxyIP.port());
     635  this->handleDisconnect( userId);
     636//   this->connectToProxyServer(proxyIP.ipString(), 9999);
     637#warning the ports are not yet integrated correctly in the ip class
    630638
    631639  // and restart the handshake
    632   this->startHandshake();
     640//   this->startHandshake( userId);
    633641}
    634642
     
    651659    delete peers[userId].connectionMonitor;
    652660  peers[userId].connectionMonitor = NULL;
     661
     662
     663  for ( SynchronizeableList::iterator it2 = synchronizeables.begin(); it2 != synchronizeables.end(); it2++ )  {
     664    (*it2)->cleanUpUser( userId );
     665  }
     666
     667//   NetworkGameManager::getInstance()->signalLeftPlayer(userId);
     668
     669  this->freeSocketSlots.push_back( userId );
     670
     671  peers.erase( userId );
    653672}
    654673
  • branches/proxy/src/lib/network/network_stream.h

    r9419 r9422  
    4646
    4747    void createNetworkGameManager();
    48     void startHandshake();
     48    void startHandshake(int userId = 0);
    4949
    5050    /* synchronizeable interface */
Note: See TracChangeset for help on using the changeset viewer.