Changeset 9430 in orxonox.OLD for branches/proxy/src/lib/network
- Timestamp:
- Jul 24, 2006, 3:59:16 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/proxy/src/lib/network/network_stream.cc
r9425 r9430 203 203 PRINTF(0)("connect to proxy %s, this is node %i\n", host.c_str(), node); 204 204 205 if( this->peers[node].socket != NULL) 206 delete this->peers[node].socket; 207 205 208 this->peers[node].socket = new UdpSocket( host, port ); 206 209 this->peers[node].userId = 0; … … 437 440 438 441 #warning this is some more disconnct handling, consider doing it in the handleDisconnect() funciton 439 //// and cleanup the user infos440 //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 ); 453 456 454 457 continue; … … 520 523 { 521 524 // 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(); 529 532 // 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); 531 534 // 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); 533 536 // 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); 535 538 536 539 // 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 540 542 this->networkGameManager = NetworkGameManager::getInstance(); 541 543 this->networkGameManager->setUniqueID( it->second.handshake->getNetworkGameManagerId() ); 542 544 // init the new message manager 543 545 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();547 546 } 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(); 550 550 551 551 } … … 600 600 } 601 601 } 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 // } 602 615 } 603 616 … … 618 631 619 632 // 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(); 622 635 623 636 // flush the old synchronization states, since the numbering could be completely different … … 631 644 // pInfo->socket->reconnectToServer( proxyIP.ipString(), proxyIP.port()); 632 645 this->handleDisconnect( userId); 633 this->connectToProxyServer(proxyIP.ipString(), 9999);646 // this->connectToProxyServer(proxyIP.ipString(), 9999); 634 647 #warning the ports are not yet integrated correctly in the ip class 635 648 636 649 // and restart the handshake 637 this->startHandshake( userId);650 // this->startHandshake( userId); 638 651 } 639 652 … … 658 671 659 672 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; 669 690 } 670 691
Note: See TracChangeset
for help on using the changeset viewer.