Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 1, 2006, 12:39:03 AM (18 years ago)
Author:
patrick
Message:

some more smaller works:

  • fixed a bug preventing clients/proxies to connect to server
  • started an implementation of a soft-reconnection
  • fixed a bug preventing more than one proxy to connect to a ms
File:
1 edited

Legend:

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

    r9652 r9653  
    390390  this->handleDownstream( tick );
    391391  this->handleUpstream( tick );
     392
     393  if( this->bSoftRedirect)
     394    this->softReconnectToServer(0, IP("localhost", 10001));
    392395}
    393396
     
    481484        userId = 1;
    482485
     486        // find an empty slot within the range
    483487        for( int i = 0; i < NET_ID_PROXY_MAX; i++)
    484488        {
    485           if( this->peers.find( i) != this->peers.end())
     489          if( this->peers.find( i) == this->peers.end())
     490          {
    486491            userId = i;
    487           break;
     492            break;
     493          }
    488494        }
    489         userId++;
    490495
    491496//         for ( PeerList::iterator it = peers.begin(); it != peers.end(); it++ )
     
    832837/**
    833838 * softly reconnecting to another server
     839 * @param serverUserId the id of the client
    834840 * @param address  of the new server
    835841 */
    836 void NetworkStream::softReconnectToServer(IP address)
    837 {
    838   this->networkMonitor->setForcedReconnection(address);
    839   this->handleReconnect( NET_ID_MASTER_SERVER);
     842void NetworkStream::softReconnectToServer(int serverUserId, IP address)
     843{
     844//   this->networkMonitor->setForcedReconnection(address);
     845//   this->handleReconnect( NET_ID_MASTER_SERVER);
     846
     847  // create the new udp socket and open the connection to the soft connection port
     848  NetworkSocket* newSocket = new UdpSocket(address.ipString(), 10001);
     849
     850  // delete the synchronization state of this client for all syncs
     851  for ( SynchronizeableList::iterator it2 = synchronizeables.begin(); it2 != synchronizeables.end(); it2++ )  {
     852    (*it2)->cleanUpUser( serverUserId );
     853  }
     854
     855  // temp save the old socket
     856  NetworkSocket* oldSocket = this->peers[serverUserId].socket;
     857
     858  // now integrate the new socket
     859  this->peers[serverUserId].socket = newSocket;
     860
     861  return;
     862
     863  // now remove the old socket
     864  oldSocket->disconnectServer();
     865  delete oldSocket;
     866
     867  // replace the old connection monitor
     868  if ( this->peers[serverUserId].connectionMonitor )
     869    delete this->peers[serverUserId].connectionMonitor;
     870  this->peers[serverUserId].connectionMonitor = new ConnectionMonitor(serverUserId);
     871
     872  // remove old node from the network monitor
     873  this->networkMonitor->removeNode(&this->peers[serverUserId]);
     874
     875  this->bSoftRedirect = false;
    840876}
    841877
     
    859895  this->peers[userId].connectionMonitor = NULL;
    860896
    861 
     897  // delete the synchronization state of this client for all syncs
    862898  for ( SynchronizeableList::iterator it2 = synchronizeables.begin(); it2 != synchronizeables.end(); it2++ )  {
    863899    (*it2)->cleanUpUser( userId );
     
    872908  this->peers.erase( userId);
    873909}
    874 
    875910
    876911
Note: See TracChangeset for help on using the changeset viewer.