Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9653 in orxonox.OLD for branches


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
Location:
branches/proxy/src/lib/network
Files:
7 edited

Legend:

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

    r9652 r9653  
    239239      outgoingMessageQueue[userId].toAck.push_back( number );
    240240
     241//     PRINTF(0)("got message with type: %i\n", messageType);
    241242    assert( i + messageLength <= length );
    242243    // make sure there is a message handler for this message type
    243     assert( messageHandlerMap.find( (MessageType)messageType ) == messageHandlerMap.end());
     244    assert( messageHandlerMap.find( (MessageType)messageType ) != messageHandlerMap.end());
    244245
    245246
     
    453454         recieverType == RT_ALL_BUT_ME  ||
    454455         recieverType == RT_USER        && it->first == reciever ||
    455         recieverType == RT_USER        && reciever == NET_ID_MASTER_SERVER && !getNetworkStream()->isUserMasterServer( it->first ) ||  // special case: forward
     456         recieverType == RT_USER        && reciever == NET_ID_MASTER_SERVER && !getNetworkStream()->isUserMasterServer( it->first ) ||  //(*)
    456457         recieverType == RT_NOT_USER    && it->first != reciever ||
    457458         recieverType == RT_SERVER      && getNetworkStream()->isUserMasterServer( it->first ) ||
    458459         recieverType == RT_SERVER      && getNetworkStream()->isUserProxyServerActive( it->first )
    459        )
     460       )// (*) special case: forward
    460461    {
    461462      NetworkMessage msg;
  • branches/proxy/src/lib/network/network_manager.cc

    r9652 r9653  
    3838
    3939SHELL_COMMAND(debug, NetworkManager, debug);
     40SHELL_COMMAND(redirTest, NetworkManager, setRedirectionTest);
     41
    4042
    4143
     
    142144
    143145  // then start the server
    144 //   this->networkStream->createServer( port, port + 1, port + 2);
     146  this->networkStream->createServer( port, port + 1, port + 2);
    145147
    146148  // and to the other proxy servers also, this would be very nice if its works
     
    232234  PRINT(0)("===========================================\n");
    233235}
     236
     237
     238void NetworkManager::setRedirectionTest()
     239{
     240  this->networkStream->setRedirectionTest();
     241}
  • branches/proxy/src/lib/network/network_manager.h

    r9600 r9653  
    4646    void debug();
    4747
     48    void setRedirectionTest();
     49
     50
    4851
    4952  private:
  • 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
  • branches/proxy/src/lib/network/network_stream.h

    r9638 r9653  
    5050
    5151    void reconnectToServer(IP address);
    52     void softReconnectToServer(IP address);
     52    void softReconnectToServer(int serverUserId, IP address);
    5353
    5454
     
    7575    inline PeerInfo* getPeerInfo() { return this->pInfo; }
    7676    inline PeerList getPeerInfoList() { return this->peers; }
     77
     78    inline void setRedirectionTest() { this->bSoftRedirect = true; }
    7779
    7880    /* data processing*/
     
    104106    void handleReconnect( int userId );
    105107    void handleDisconnect( int userId );
     108    void handleSoftDisconnect( int userId);
    106109
    107110    void writeToNewDict( byte * data, int length, bool upstream );
     
    134137    bool                       bRedirect;                   //!< true if the master server sent a redirect command
    135138    int                        redirectionUID;              //!< uid of the redir host
     139    bool                       bSoftRedirect;               //!< tsting
    136140};
    137141#endif /* _NETWORK_STREAM */
  • branches/proxy/src/lib/network/synchronizeable.cc

    r9636 r9653  
    126126int Synchronizeable::getStateDiff( int userId, byte* data, int maxLength, int stateId, int fromStateId, int priorityTH )
    127127{
    128   //make sure this user has his history
     128  // make sure this user has his history or resize for new clients
    129129  if ( (int)sentStates.size() <= userId )
    130130    sentStates.resize( userId+1 );
     
    133133  int neededSize = 0;
    134134
     135  // calculate the needed space for network packet by summing up
    135136  for ( SyncVarList::iterator it = syncVarList.begin(); it != syncVarList.end(); it++ )
    136137  {
  • branches/proxy/src/lib/network/udp_socket.h

    r9406 r9653  
    4141
    4242  private:
     43    void init();
     44
     45    bool writeRawPacket( byte * data, int length );
     46    bool checkUdpCmd( byte udpCmd );
     47    bool checkRandomByte( byte rndByte );
     48    byte generateNewRandomByte();
     49
     50
     51  private:
    4352    UdpServerSocket * serverSocket;   //!< will get packets here
    4453    int               userId;         //!< user id used by serverSocket
     
    4756
    4857    byte              randomByte;     //!< contains random bytes & 0xFC
    49 
    50     bool writeRawPacket( byte * data, int length );
    51     bool checkUdpCmd( byte udpCmd );
    52     bool checkRandomByte( byte rndByte );
    53     byte generateNewRandomByte();
    54 
    55     void init();
    56 
    5758};
    5859
Note: See TracChangeset for help on using the changeset viewer.