Changeset 9334 in orxonox.OLD for branches/proxy/src/lib/network/network_stream.cc
- Timestamp:
- Jul 19, 2006, 10:29:14 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/proxy/src/lib/network/network_stream.cc
r9327 r9334 28 28 #include "monitor/network_monitor.h" 29 29 #include "synchronizeable.h" 30 #include "ip.h" 30 31 #include "network_game_manager.h" 31 32 #include "shared_network_data.h" … … 85 86 this->pInfo->nodeType = NET_CLIENT; 86 87 // get the local ip address 87 SDLNet_ResolveHost( &this->pInfo->ip, NULL, port ); 88 IPaddress ip; 89 SDLNet_ResolveHost( &ip, NULL, port ); 90 this->pInfo->ip = ip; 88 91 } 89 92 … … 99 102 this->pInfo->nodeType = NET_MASTER_SERVER; 100 103 // get the local ip address 101 SDLNet_ResolveHost( &this->pInfo->ip, NULL, port ); 104 IPaddress ip; 105 SDLNet_ResolveHost( &ip, NULL, port ); 106 this->pInfo->ip = ip; 102 107 } 103 108 … … 356 361 357 362 // check if the connecting client should reconnect to a proxy server 358 peers[clientId].handshake->setRedirect(this->networkMonitor-> reconnectNextClient());363 peers[clientId].handshake->setRedirect(this->networkMonitor->isReconnectNextClient()); 359 364 360 365 … … 364 369 365 370 // check if there are too many clients connected (DEPRECATED: new: the masterserver sends a list of proxy servers) 366 if ( clientId > SharedNetworkData::getInstance()->getMaxPlayer() ) 367 { 368 // peers[clientId].handshake->setRedirect(true); 369 // 370 // peers[clientId].handshake->doReject( "too many connections" ); 371 PRINTF(0)("Will reject client %d because there are to many connections!\n", clientId); 372 } 373 else 374 { 375 PRINTF(0)("New Client: %d\n", clientId); 376 } 377 378 //this->connectSynchronizeable(*handshakes[clientId]); 371 // if ( clientId > SharedNetworkData::getInstance()->getMaxPlayer() ) 372 // { 373 // // peers[clientId].handshake->setRedirect(true); 374 // // 375 // // peers[clientId].handshake->doReject( "too many connections" ); 376 // PRINTF(0)("Will reject client %d because there are to many connections!\n", clientId); 377 // } 378 // else 379 // { 380 // PRINTF(0)("New Client: %d\n", clientId); 381 // } 382 PRINTF(0)("New Client: %d\n", clientId); 383 384 379 385 } 380 386 … … 493 499 it->second.nodeType = it->second.handshake->getRemoteNodeType(); 494 500 it->second.ip = it->second.socket->getRemoteAddress(); 501 // add the new server to the nodes list (it can be a NET_MASTER_SERVER or NET_PROXY_SERVER) 495 502 this->networkMonitor->addNode(&it->second); 496 497 503 // get proxy 1 address and add it 498 504 this->networkMonitor->addNode(it->second.handshake->getProxy1Address(), NET_PROXY_SERVER_ACTIVE); … … 500 506 this->networkMonitor->addNode(it->second.handshake->getProxy2Address(), NET_PROXY_SERVER_ACTIVE); 501 507 502 503 // now check if there server accepted the connection 508 // now check if the server accepted the connection 504 509 if( it->second.handshake->redirect()) 505 { 506 // handle the redirection 507 PRINTF(0)("===============================================\n"); 508 PRINTF(0)("Client is redirected to the other proxy servers\n"); 509 PRINTF(0)("===============================================\n"); 510 511 // disconnect from the current server and reconnect to proxy server 512 // it->second.socket->disconnectServer(); 513 } 510 this->handleReconnect( it->second.userId); 514 511 515 512 // create the new network game manager and init it … … 537 534 this->networkMonitor->addNode(&it->second); 538 535 539 handleNewClient( it->second.userId );536 this->handleNewClient( it->second.userId ); 540 537 541 538 if ( PlayerStats::getStats( it->second.userId ) && it->second.handshake->getPreferedNickName() != "" ) … … 560 557 } 561 558 } 559 } 560 561 562 /** 563 * this functions handles a reconnect event received from the a NET_MASTER_SERVER or NET_PROXY_SERVER 564 */ 565 void NetworkStream::handleReconnect(int userId) 566 { 567 PRINTF(0)("===============================================\n"); 568 PRINTF(0)("Client is redirected to the other proxy servers\n"); 569 PRINTF(0)("===============================================\n"); 570 571 PeerInfo* pInfo = &this->peers[userId]; 572 573 // reject the server 574 pInfo->handshake->doReject( "redirected to different server"); 575 576 // flush the old synchronization states, since the numbering could be completely different 577 pInfo->lastAckedState = 0; 578 pInfo->lastRecvedState = 0; 579 // not sure if this works as expected 580 if( pInfo->handshake) 581 delete pInfo->handshake; 582 583 // disconnect from the current server and reconnect to proxy server 584 pInfo->socket->reconnectToServer( pInfo->handshake->getProxy1Address().ipString(), pInfo->handshake->getProxy1Address().port()); 585 586 // and restart the handshake 587 this->startHandshake(); 562 588 } 563 589
Note: See TracChangeset
for help on using the changeset viewer.