Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9406 in orxonox.OLD for trunk/src/lib/network/handshake.cc


Ignore:
Timestamp:
Jul 24, 2006, 11:09:47 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the proxy back

merged with commandsvn merge -r9346:HEAD https://svn.orxonox.net/orxonox/branches/proxy .

no conflicts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/network/handshake.cc

    r9235 r9406  
    1010
    1111### File Specific:
    12    main-programmer: christoph
    13    co-programmer:
     12   main-programmer: Christoph Renner (rennerc@ee.ethz.ch)
     13   co-programmer: Patirck Boenzli (boenzlip@orxonox.ethz.ch)
    1414*/
    1515
    1616
    17 /* this is for debug output. It just says, that all calls to PRINT() belong to the DEBUG_MODULE_NETWORK module
    18    For more information refere to https://www.orxonox.net/cgi-bin/trac.cgi/wiki/DebugOutput
    19 */
    2017#define DEBUG_MODULE_NETWORK
    2118
     
    2522#include "debug.h"
    2623
    27 Handshake::Handshake( bool server, int clientId, int networkGameManagerId, int messageManagerId )
     24
     25
     26
     27
     28 Handshake::Handshake( int nodeType, int clientId, int networkGameManagerId, int messageManagerId )
    2829  : Synchronizeable()
    2930{
     
    3132  this->setClassID(CL_HANDSHAKE, "Handshake");
    3233
    33   this->setIsServer(server);
    3434
     35  // register all variable handlers
    3536  orxId_handler = registerVarId( new SynchronizeableInt( &localState.orxId, &remoteState.orxId, "orxonoxId", PERMISSION_ALL ) );
    3637  version_handler = registerVarId( new SynchronizeableInt( &localState.version, &remoteState.version, "version", PERMISSION_ALL ) );
     
    4243  errorString_handler = registerVarId( new SynchronizeableString( &localState.errorString, &remoteState.errorString, "errorString", PERMISSION_ALL ) );
    4344
     45  this->nodeTypeHandler = registerVarId( new SynchronizeableInt( &localState.nodeType, &remoteState.nodeType, "nodeType", PERMISSION_ALL ) );
     46
    4447  candel_id = registerVarId( new SynchronizeableInt( &localState.canDel, &remoteState.canDel, "canDel", PERMISSION_ALL ) );
    45  
     48
    4649  registerVar( new SynchronizeableString( &localState.preferedNickName, &remoteState.preferedNickName, "preferedNickName", PERMISSION_ALL ) );
     50  // now synchronize only two of the available proxy server addresses
     51  registerVar( new SynchronizeableIP( &this->proxy1, &this->proxy1, "proxy server 1", PERMISSION_MASTER_SERVER ) );
     52  registerVar( new SynchronizeableIP( &this->proxy2, &this->proxy2, "proxy server 2", PERMISSION_MASTER_SERVER ) );
     53  registerVar( new SynchronizeableInt( &this->redirectProxy, &this->redirectProxy, "proxy server redirection flag", PERMISSION_MASTER_SERVER ) );
    4754
     55
     56  // init the local state
    4857  localState.completed = 0;
    4958  localState.error = 0;
     
    5463  localState.orxId = _ORXONOX_ID;
    5564  localState.version = _ORXONOX_VERSION;
     65  localState.nodeType = nodeType;
    5666  localState.canDel = 0;
    5767
     68
     69  // init the remote state
    5870  remoteState.completed = 0;
    5971  remoteState.error = 0;
     
    6476  remoteState.orxId = 0;
    6577  remoteState.version = 0;
     78  remoteState.nodeType = NET_CLIENT;
    6679  remoteState.canDel = 0;
    6780
     81
     82  this->proxy1 = IP(0, 0);
     83  this->proxy2 = IP(0, 0);
     84  this->redirectProxy = 0;
     85
     86
     87  // activate the synchronization process
    6888  this->setSynchronized(true);
    6989  PRINTF(0)("Handshake created clientId = %d\n", clientId);
    7090}
     91
    7192
    7293/**
     
    7899  for ( std::list<int>::iterator it = id.begin(); it != id.end(); it++ )
    79100  {
    80     if ( *it == orxId_handler )
     101    // orxonox id handler
     102    if ( *it == this->orxId_handler )
    81103    {
    82104      if ( remoteState.orxId != _ORXONOX_ID )
     
    87109        continue;
    88110      }
    89 
    90111    }
    91112
    92     if ( *it == version_handler )
     113    // orxonox version handler
     114    if ( *it == this->version_handler )
    93115    {
    94116      if ( remoteState.version != _ORXONOX_VERSION )
     
    99121        continue;
    100122      }
    101 
    102123    }
    103124
     125    // node type handler: for each node type there is a specific action to be taken
     126    if ( *it == this->nodeTypeHandler)
     127    {
     128      if ( remoteState.nodeType == NET_MASTER_SERVER )
     129      {
     130        continue;
     131      }
     132      else if( remoteState.nodeType == NET_PROXY_SERVER_ACTIVE)
     133      {
     134        continue;
     135      }
     136      else if( remoteState.nodeType == NET_CLIENT)
     137      {
     138        continue;
     139      }
     140    }
     141
     142    // cancel
    104143    if ( *it == candel_id )
    105144    {
    106145      PRINTF(0)("handshake finished candel changed\n");
    107146    }
    108 
    109147  }
    110148
    111   if (
    112       remoteState.orxId == _ORXONOX_ID &&
    113       remoteState.version == _ORXONOX_VERSION
    114      )
     149  // handshake completed
     150  if ( remoteState.orxId == _ORXONOX_ID &&
     151       remoteState.version == _ORXONOX_VERSION )
     152  {
    115153    localState.completed = 1;
     154  }
    116155}
    117156
Note: See TracChangeset for help on using the changeset viewer.