- Timestamp:
- Jul 24, 2006, 2:05:16 PM (18 years ago)
- Location:
- branches/proxy/src/lib/network
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/proxy/src/lib/network/network_manager.cc
r9406 r9422 165 165 this->networkStream->startHandshake(); 166 166 167 PRINTF(0)("Created Network Client ");167 PRINTF(0)("Created Network Client\n"); 168 168 return 1; 169 169 } -
branches/proxy/src/lib/network/network_stream.cc
r9420 r9422 236 236 * handsakes are always initialized from the client side first. this starts the handshake and therefore is only 237 237 * executed as client 238 */ 239 void NetworkStream::startHandshake() 238 * @param userId: start handshake for this user id (optional, default == 0) 239 */ 240 void NetworkStream::startHandshake(int userId) 240 241 { 241 242 Handshake* hs = new Handshake(this->pInfo->nodeType); 242 243 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; 245 246 246 247 // set the preferred nick name … … 255 256 * it all over the network and creating it on the other platforms (if and only if it is a 256 257 * server 258 * @param sync: the synchronizeable to add 257 259 */ 258 260 void NetworkStream::connectSynchronizeable(Synchronizeable& sync) … … 260 262 this->synchronizeables.push_back(&sync); 261 263 sync.setNetworkStream( this ); 262 263 // this->bActive = true;264 264 } 265 265 … … 267 267 /** 268 268 * removes the synchronizeable from the list of synchronized entities 269 * @param sync: the syncronizeable to remove 269 270 */ 270 271 void NetworkStream::disconnectSynchronizeable(Synchronizeable& sync) … … 434 435 435 436 #warning this is some more disconnct handling, consider doing it in the handleDisconnect() funciton 436 // and cleanup the user infos437 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 ); 450 451 451 452 continue; … … 532 533 533 534 // 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 535 547 this->handleReconnect( it->second.userId); 536 548 537 // create the new network game manager and init it538 this->networkGameManager = NetworkGameManager::getInstance();539 this->networkGameManager->setUniqueID( it->second.handshake->getNetworkGameManagerId() );540 // init the new message manager541 MessageManager::getInstance()->setUniqueID( it->second.handshake->getMessageManagerId() );542 549 } 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 547 555 } 548 556 else … … 609 617 PRINTF(0)("===============================================\n"); 610 618 PRINTF(0)("Client is redirected to the other proxy servers\n"); 619 PRINTF(0)(" user id: %i\n", userId); 611 620 PRINTF(0)(" connecting to: %s\n", pInfo->handshake->getProxy1Address().ipString().c_str()); 612 621 PRINTF(0)("===============================================\n"); … … 622 631 IP proxyIP = pInfo->handshake->getProxy1Address(); 623 632 624 // not sure if this works as expected625 if( pInfo->handshake)626 delete pInfo->handshake;627 628 633 // 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 630 638 631 639 // and restart the handshake 632 this->startHandshake();640 // this->startHandshake( userId); 633 641 } 634 642 … … 651 659 delete peers[userId].connectionMonitor; 652 660 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 ); 653 672 } 654 673 -
branches/proxy/src/lib/network/network_stream.h
r9419 r9422 46 46 47 47 void createNetworkGameManager(); 48 void startHandshake( );48 void startHandshake(int userId = 0); 49 49 50 50 /* synchronizeable interface */
Note: See TracChangeset
for help on using the changeset viewer.