Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9450 in orxonox.OLD for branches/proxy


Ignore:
Timestamp:
Jul 25, 2006, 10:34:28 AM (18 years ago)
Author:
patrick
Message:

using the new id scheme

Location:
branches/proxy/src/lib/network
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/proxy/src/lib/network/README.NETWORK

    r9449 r9450  
    2929NET_MAX_CONNECTION   Last client
    3030
     31The proxy server ids are assigned as stated in the data/trunk/config/network_settings.conf, the first proxy server in the list gets the id NET_ID_PROXY_01 and so on.
     32
    3133
    3234
  • branches/proxy/src/lib/network/netdefs.h

    r9449 r9450  
    6262};
    6363
    64 //!< the type of the user id (special number never used elsewhere)
     64//!< the type of the unique id (special number never used elsewhere)
    6565typedef enum {
    6666  NET_UID_UNASSIGNED = -1,
     67
     68  NET_UID_HANDSHAKE  =  0,
     69
    6770
    6871  NET_UID_NUMBER
     
    7073
    7174
    72 //!< the id of the node
     75//!< the network id list
    7376typedef enum nodeId {
    7477  NET_ID_UNASSIGNED       =-1,
  • branches/proxy/src/lib/network/network_manager.cc

    r9449 r9450  
    133133  this->networkStream->createServer( port);
    134134  // and connect to the master server for synchronization
    135   int userId = this->networkStream->connectToMasterServer(NetworkSettings::getInstance()->getMasterAddr().ipString(), 9999);
     135  this->networkStream->connectToMasterServer(NetworkSettings::getInstance()->getMasterAddr().ipString(), 9999);
    136136  // and to the other proxy servers also, this would be very nice if its works
    137137
  • branches/proxy/src/lib/network/network_stream.cc

    r9449 r9450  
    182182 * @param port: the port number
    183183 */
    184 int NetworkStream::connectToMasterServer(std::string host, int port)
    185 {
    186   int node = this->peers.size();
     184void NetworkStream::connectToMasterServer(std::string host, int port)
     185{
     186  int node = NET_ID_MASTER_SERVER;
    187187  // this create the new node in the peers map
    188188  this->peers[node].socket = new UdpSocket( host, port );
    189   this->peers[node].userId = 0;
     189  this->peers[node].userId = NET_ID_MASTER_SERVER;
    190190
    191191  this->peers[node].nodeType = NET_MASTER_SERVER;
    192   this->peers[node].connectionMonitor = new ConnectionMonitor( 0 );
     192  this->peers[node].connectionMonitor = new ConnectionMonitor( NET_ID_MASTER_SERVER );
    193193  this->peers[node].ip = this->peers[node].socket->getRemoteAddress();
    194 
    195   return node;
    196194}
    197195
     
    202200 * @param port: the port number
    203201 */
    204 int NetworkStream::connectToProxyServer(std::string host, int port)
    205 {
    206   int node = this->peers.size();
    207   PRINTF(0)("connect to proxy %s, this is node %i\n", host.c_str(), node);
    208 
    209   // this creates the new node in the peers map
    210   this->peers[node].socket = new UdpSocket( host, port );
    211   this->peers[node].userId = 0;
    212 
    213   this->peers[node].nodeType = NET_PROXY_SERVER_ACTIVE;
    214   this->peers[node].connectionMonitor = new ConnectionMonitor( 0 );
    215   this->peers[node].ip = this->peers[node].socket->getRemoteAddress();
    216 
    217   return node;
     202void NetworkStream::connectToProxyServer(int proxyId,std::string host, int port)
     203{
     204  PRINTF(0)("connect to proxy %s, this is proxyId %i\n", host.c_str(), proxyId);
     205
     206  // this creates the new proxyId in the peers map
     207  this->peers[proxyId].socket = new UdpSocket( host, port );
     208  this->peers[proxyId].userId = proxyId;
     209
     210  this->peers[proxyId].nodeType = NET_PROXY_SERVER_ACTIVE;
     211  this->peers[proxyId].connectionMonitor = new ConnectionMonitor( proxyId );
     212  this->peers[proxyId].ip = this->peers[proxyId].socket->getRemoteAddress();
    218213}
    219214
     
    250245{
    251246  Handshake* hs = new Handshake(this->pInfo->nodeType);
    252   hs->setUniqueID( 0 );
     247  // fake the unique id
     248  hs->setUniqueID( NET_UID_HANDSHAKE );
    253249  assert( peers[userId].handshake == NULL );
    254250  peers[userId].handshake = hs;
     
    327323  {
    328324    // check if the connection is ok else terminate and remove
    329     if ( !peers.empty() && peers[0].socket && ( !peers[0].socket->isOk() || peers[0].connectionMonitor->hasTimedOut() ) )
    330     {
    331       this->handleDisconnect( 0);
     325#warning make this more modular: every proxy/master server connection should be watched for termination
     326    if ( !peers.empty() && peers[NET_ID_MASTER_SERVER].socket &&
     327          ( !peers[NET_ID_MASTER_SERVER].socket->isOk() ||
     328          peers[NET_ID_MASTER_SERVER].connectionMonitor->hasTimedOut() ) )
     329    {
     330      this->handleDisconnect( NET_ID_MASTER_SERVER);
    332331      PRINTF(1)("lost connection to server\n");
    333332    }
     
    335334    if( this->bRedirect)
    336335    {
    337       this->handleReconnect( 0);
     336      this->handleReconnect( NET_ID_MASTER_SERVER);
    338337    }
    339338  }
     
    625624  // disconnect from the current server and reconnect to proxy server
    626625  this->handleDisconnect( userId);
    627   this->connectToProxyServer(proxyIP.ipString(), 9999);
     626  this->connectToProxyServer(NET_ID_PROXY_SERVER_01, proxyIP.ipString(), 9999);
    628627  #warning the ports are not yet integrated correctly in the ip class
    629628
     
    707706
    708707      // do not include synchronizeables with uninit id and syncs that don't want to be synchronized
    709       if ( !sync.beSynchronized() || sync.getUniqueID() < 0 )
     708      if ( !sync.beSynchronized() || sync.getUniqueID() <= NET_UID_UNASSIGNED )
    710709        continue;
    711710
     
    769768      Synchronizeable & sync = **it;
    770769
    771       if ( !sync.beSynchronized() || sync.getUniqueID() < 0 )
     770      // again exclude all unwanted syncs
     771      if ( !sync.beSynchronized() || sync.getUniqueID() <= NET_UID_UNASSIGNED)
    772772        continue;
    773773
     
    969969        Synchronizeable & sync = **it;
    970970
    971         if ( !sync.beSynchronized() || sync.getUniqueID() < 0 )
     971        if ( !sync.beSynchronized() || sync.getUniqueID() <= NET_UID_UNASSIGNED )
    972972          continue;
    973973
  • branches/proxy/src/lib/network/network_stream.h

    r9449 r9450  
    4141    void init();
    4242
    43     int connectToMasterServer(std::string host, int port);
    44     int connectToProxyServer(std::string host, int port);
     43    void connectToMasterServer(std::string host, int port);
     44    void connectToProxyServer(int proxyId, std::string host, int port);
    4545    void createServer(int port);
    4646
    4747    void createNetworkGameManager();
    48     void startHandshake(int userId = 0);
     48    void startHandshake(int userId = NET_ID_MASTER_SERVER);
    4949
    5050    /* synchronizeable interface */
Note: See TracChangeset for help on using the changeset viewer.