Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9347 in orxonox.OLD for branches/proxy/src/lib/network/handshake.cc


Ignore:
Timestamp:
Jul 20, 2006, 11:43:27 AM (19 years ago)
Author:
bensch
Message:

orxonox/proxy: merged the proxy.old back again, and it seems to work.

Merged with command
svn merge -r9247:HEAD https://svn.orxonox.net/orxonox/branches/proxy.old .

no conflicts

File:
1 edited

Legend:

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

    r9235 r9347  
    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);
    34 
     34  // register all variable handlers
    3535  orxId_handler = registerVarId( new SynchronizeableInt( &localState.orxId, &remoteState.orxId, "orxonoxId", PERMISSION_ALL ) );
    3636  version_handler = registerVarId( new SynchronizeableInt( &localState.version, &remoteState.version, "version", PERMISSION_ALL ) );
     
    4242  errorString_handler = registerVarId( new SynchronizeableString( &localState.errorString, &remoteState.errorString, "errorString", PERMISSION_ALL ) );
    4343
     44  this->nodeTypeHandler = registerVarId( new SynchronizeableInt( &localState.nodeType, &remoteState.nodeType, "nodeType", PERMISSION_ALL ) );
     45
    4446  candel_id = registerVarId( new SynchronizeableInt( &localState.canDel, &remoteState.canDel, "canDel", PERMISSION_ALL ) );
    45  
     47
    4648  registerVar( new SynchronizeableString( &localState.preferedNickName, &remoteState.preferedNickName, "preferedNickName", PERMISSION_ALL ) );
     49  // now synchronize only two of the available proxy server addresses
     50  registerVar( new SynchronizeableIP( &localState.proxy1, &remoteState.proxy1, "proxy server 1", PERMISSION_ALL ) );
     51  registerVar( new SynchronizeableIP( &localState.proxy2, &remoteState.proxy1, "proxy server 2", PERMISSION_ALL ) );
    4752
     53  // init the local state
    4854  localState.completed = 0;
    4955  localState.error = 0;
     
    5460  localState.orxId = _ORXONOX_ID;
    5561  localState.version = _ORXONOX_VERSION;
     62  localState.nodeType = nodeType;
    5663  localState.canDel = 0;
     64  localState.redirectProxy = 0;
     65  localState.proxy1 = IP(0, 0);
     66  localState.proxy2 = IP (0, 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;
     80  remoteState.redirectProxy = 0;
     81  remoteState.proxy1 = IP(0, 0);
     82  remoteState.proxy2 = IP(0, 0);
    6783
     84  // activate the synchronization process
    6885  this->setSynchronized(true);
    6986  PRINTF(0)("Handshake created clientId = %d\n", clientId);
    7087}
     88
    7189
    7290/**
     
    7896  for ( std::list<int>::iterator it = id.begin(); it != id.end(); it++ )
    7997  {
    80     if ( *it == orxId_handler )
     98    // orxonox id handler
     99    if ( *it == this->orxId_handler )
    81100    {
    82101      if ( remoteState.orxId != _ORXONOX_ID )
     
    87106        continue;
    88107      }
    89 
    90108    }
    91109
    92     if ( *it == version_handler )
     110    // orxonox version handler
     111    if ( *it == this->version_handler )
    93112    {
    94113      if ( remoteState.version != _ORXONOX_VERSION )
     
    99118        continue;
    100119      }
    101 
    102120    }
    103121
     122    // node type handler: for each node type there is a specific action to be taken
     123    if ( *it == this->nodeTypeHandler)
     124    {
     125      if ( remoteState.nodeType == NET_MASTER_SERVER )
     126      {
     127        continue;
     128      }
     129      else if( remoteState.nodeType == NET_PROXY_SERVER_ACTIVE)
     130      {
     131        continue;
     132      }
     133      else if( remoteState.nodeType == NET_CLIENT)
     134      {
     135        continue;
     136      }
     137    }
     138
     139    // cancel
    104140    if ( *it == candel_id )
    105141    {
     
    109145  }
    110146
    111   if (
    112       remoteState.orxId == _ORXONOX_ID &&
    113       remoteState.version == _ORXONOX_VERSION
    114      )
     147  // handshake completed
     148  if ( remoteState.orxId == _ORXONOX_ID &&
     149       remoteState.version == _ORXONOX_VERSION )
     150  {
    115151    localState.completed = 1;
     152  }
    116153}
    117154
Note: See TracChangeset for help on using the changeset viewer.