Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

disconnection of nodes, redirection bug tracing

File:
1 edited

Legend:

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

    r9406 r9419  
    8080      // init the shared network data
    8181      SharedNetworkData::getInstance()->setHostID(0);
    82 //       SharedNetworkData::getInstance()->setNodeType(NET_MASTER_SERVER);
    8382      break;
    8483
     
    8685      // init the shared network data
    8786      SharedNetworkData::getInstance()->setHostID(0);
    88 //       SharedNetworkData::getInstance()->setNodeType(NET_PROXY_SERVER_ACTIVE);
    8987      break;
    9088    case NET_PROXY_SERVER_PASSIVE:
    91             // init the shared network data
     89      // init the shared network data
    9290      SharedNetworkData::getInstance()->setHostID(0);
    93 //       SharedNetworkData::getInstance()->setNodeType(NET_PROXY_SERVER_PASSIVE);
    9491      break;
    9592    case NET_CLIENT:
    96 //       SharedNetworkData::getInstance()->setNodeType(NET_CLIENT);
    9793      break;
    9894  }
     
    323319    if ( peers[0].socket && ( !peers[0].socket->isOk() || peers[0].connectionMonitor->hasTimedOut() ) )
    324320    {
     321      this->handleDisconnect( 0);
    325322      PRINTF(1)("lost connection to server\n");
    326 
    327       peers[0].socket->disconnectServer();
    328       delete peers[0].socket;
    329       peers[0].socket = NULL;
    330 
    331       if ( peers[0].handshake )
    332         delete peers[0].handshake;
    333       peers[0].handshake = NULL;
    334 
    335       if ( peers[0].connectionMonitor )
    336         delete peers[0].connectionMonitor;
    337       peers[0].connectionMonitor = NULL;
    338323    }
    339324  }
     
    404389
    405390    // check if the connecting client should reconnect to a proxy server
    406     peers[clientId].handshake->setRedirect(/*this->networkMonitor->isReconnectNextClient()*/false);
     391    peers[clientId].handshake->setRedirect(/*this->networkMonitor->isReconnectNextClient()*/true);
    407392
    408393    // the connecting node of course is a client
     
    446431      PRINTF(0)("Client is gone: %d (%s)\n", it->second.userId, reason.c_str());
    447432
    448 
    449       // clean up the network data
    450       it->second.socket->disconnectServer();
    451       delete it->second.socket;
    452       it->second.socket = NULL;
    453 
    454       // remove the old connectin monitor
    455       if ( it->second.connectionMonitor )
    456         delete it->second.connectionMonitor;
    457       it->second.connectionMonitor = NULL;
    458 
    459       // remove the handshake
    460       if ( it->second.handshake )
    461         delete it->second.handshake;
    462       it->second.handshake = NULL;
    463 
     433      this->handleDisconnect( it->second.userId);
     434
     435#warning this is some more disconnct handling, consider doing it in the handleDisconnect() funciton
    464436      // and cleanup the user infos
    465437      for ( SynchronizeableList::iterator it2 = synchronizeables.begin(); it2 != synchronizeables.end(); it2++ )
     
    563535                this->handleReconnect( it->second.userId);
    564536
     537              PRINTF(0)("redirection: %i\n\n\n", it->second.handshake->redirect());
     538
    565539              // create the new network game manager and init it
    566540              this->networkGameManager = NetworkGameManager::getInstance();
     
    659633
    660634/**
     635 * handles the disconnect event
     636 * @param userId id of the user to remove
     637 */
     638void NetworkStream::handleDisconnect( int userId )
     639{
     640  peers[userId].socket->disconnectServer();
     641  delete peers[userId].socket;
     642  peers[userId].socket = NULL;
     643
     644  if ( peers[userId].handshake )
     645    delete peers[userId].handshake;
     646  peers[userId].handshake = NULL;
     647
     648  if ( peers[userId].connectionMonitor )
     649    delete peers[userId].connectionMonitor;
     650  peers[userId].connectionMonitor = NULL;
     651}
     652
     653
     654
     655/**
    661656 * handle upstream network traffic
     657 * @param tick: seconds elapsed since last update
    662658 */
    663659void NetworkStream::handleUpstream( int tick )
Note: See TracChangeset for help on using the changeset viewer.