Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9360 in orxonox.OLD


Ignore:
Timestamp:
Jul 20, 2006, 3:49:57 PM (18 years ago)
Author:
patrick
Message:

network ip synchronization work

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

Legend:

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

    r9353 r9360  
    4848  registerVar( new SynchronizeableString( &localState.preferedNickName, &remoteState.preferedNickName, "preferedNickName", PERMISSION_ALL ) );
    4949  // now synchronize only two of the available proxy server addresses
    50   proxy1Handler = registerVarId( new SynchronizeableIP( &localState.proxy1, &remoteState.proxy1, "proxy server 1", PERMISSION_ALL ) );
    51   proxy2Handler = registerVarId( new SynchronizeableIP( &localState.proxy2, &remoteState.proxy2, "proxy server 2", PERMISSION_ALL ) );
     50//   registerVar( new SynchronizeableIP( &this->proxy1, &this->proxy1, "proxy server 1", PERMISSION_ALL ) );
     51//   registerVar( new SynchronizeableIP( &this->proxy2, &this->proxy2, "proxy server 2", PERMISSION_ALL ) );
     52  registerVar( new SynchronizeableInt( this->proxy1.hostRef(), this->proxy1.hostRef(), "proxy server 1", PERMISSION_ALL));
     53  registerVar( new SynchronizeableInt( this->proxy1.portRef(), this->proxy1.portRef(), "proxy server 1", PERMISSION_ALL));
     54  registerVar( new SynchronizeableInt( this->proxy2.hostRef(), this->proxy2.hostRef(), "proxy server 2", PERMISSION_ALL));
     55  registerVar( new SynchronizeableInt( this->proxy2.portRef(), this->proxy2.portRef(), "proxy server 2", PERMISSION_ALL));
    5256
    5357  // init the local state
     
    6266  localState.nodeType = nodeType;
    6367  localState.canDel = 0;
    64   localState.redirectProxy = 0;
    65   localState.proxy1 = IP(0, 0);
    66   localState.proxy2 = IP (0, 0);
    6768
    6869
     
    7879  remoteState.nodeType = NET_CLIENT;
    7980  remoteState.canDel = 0;
    80   remoteState.redirectProxy = 0;
    81   remoteState.proxy1 = IP(0, 0);
    82   remoteState.proxy2 = IP(0, 0);
    8381
    8482
    85   this->proxyAddressesSynched = 0;
     83  this->proxyAddressesSynched = 2;
     84  this->proxy1 = IP(0, 0);
     85  this->proxy2 = IP(0, 0);
     86  this->redirectProxy = 0;
    8687
    8788
     
    151152    {
    152153      this->proxyAddressesSynched++;
    153       PRINTF(0)("got proxy1: %i, %i\n", this->remoteState.proxy1.host(), this->remoteState.proxy1.port());
     154      PRINTF(0)("got proxy1: %i, %i\n", this->proxy1.host(), this->proxy1.port());
    154155    }
    155156
     
    158159    {
    159160      this->proxyAddressesSynched++;
    160       PRINTF(0)("got proxy2: %i, %i\n", this->remoteState.proxy2.host(), this->remoteState.proxy2.port());
     161      PRINTF(0)("got proxy2: %i, %i\n", this->proxy2.host(), this->proxy2.port());
    161162    }
    162163
  • branches/proxy/src/lib/network/handshake.h

    r9350 r9360  
    1414#include "ip.h"
    1515#include "synchronizeable.h"
     16#include "shared_network_data.h"
    1617
    1718//!< a struct to save the handshakes to
     
    3536  //additional data
    3637  std::string   preferedNickName;              //!< prefered nick name
    37 
    38   int           redirectProxy;                 //!< true if the client should reconnect to a proxy server (either 1 or 2 )
    39   IP            proxy1;                        //!< ip address of the first proxy (0.0.0.0 of not available)
    40   IP            proxy2;                        //!< ip address of the second proxy (0.0.0.0 of not available)
    4138};
    4239
     
    8178
    8279    /** @returns if true the local client should reconnect to a proxy server from the proxy server list */
    83     inline bool redirect() { return this->remoteState.redirectProxy;}
     80    inline bool redirect() { return this->redirectProxy;}
    8481    /** @param flag: indicating if the client should be redirected */
    85     inline void setRedirect(bool flag) { this->localState.redirectProxy = flag; }
     82    inline void setRedirect(bool flag) { this->redirectProxy = flag; }
    8683
    8784    /** @param address: the address of the proxy server 1 if any */
    88     inline void setProxy1Address(IP address) { this->localState.proxy1 = address; }
     85    inline void setProxy1Address(IP address) { if( !SharedNetworkData::getInstance()->isMasterServer()) return; this->proxy1 = address; }
    8986    /** @returns the address of the proxy server 1 if any */
    90     inline IP getProxy1Address() { return this->remoteState.proxy1; }
     87    inline IP getProxy1Address() { return this->proxy1; }
    9188    /** @param address: the address of the proxy server 2 if any */
    92     inline void setProxy2Address(IP address) { this->localState.proxy2 = address; }
     89    inline void setProxy2Address(IP address) { this->proxy2 = address; }
    9390    /** @returns the address of the proxy server 2 if any */
    94     inline IP getProxy2Address() { return this->remoteState.proxy2; }
     91    inline IP getProxy2Address() { return this->proxy2; }
    9592
    9693
     
    119116
    120117    int                proxyAddressesSynched;                 //!< number of addresses synched
    121 
     118    int                redirectProxy;                         //!< true if the client should reconnect to a proxy server
     119    IP                 proxy1;                               //!< ip address of the first proxy (0.0.0.0 of not available)
     120    IP                 proxy2;                               //!< ip address of the second proxy (0.0.0.0 of not available)
    122121};
    123122
  • branches/proxy/src/lib/network/ip.cc

    r9347 r9360  
    256256
    257257/// default port definition.
    258 short IP::_defaultPort = 9999;
     258int IP::_defaultPort = 9999;
    259259
    260260/**
     
    262262 * @param defaultPort The default port.
    263263 */
    264 void IP::setDefaultPort(short defaultPort)
     264void IP::setDefaultPort(int defaultPort)
    265265{
    266266  IP::_defaultPort = defaultPort;
  • branches/proxy/src/lib/network/ip.h

    r9347 r9360  
    3636    /** @returns the IP */
    3737    int host() const { return this->_ip; };
     38    int* hostRef()  { return &this->_ip; }
    3839    /** @returns the Port */
    39     short port() const { return this->_port; };
     40    int port() const { return this->_port; };
     41    int* portRef() { return &this->_port; };
     42
    4043    inline IPaddress getSDLNotation() { IPaddress sdlIP; sdlIP.host = this->_ip; sdlIP.port = this->_port; return sdlIP; }
    4144
     
    5255    static std::string ipToString(int ip, int port = -1);
    5356
    54     static void setDefaultPort(short defaultPort);
    55     static short defaultPort(short defaultPort) { return IP::_defaultPort; };
     57    static void setDefaultPort(int defaultPort);
     58    static int defaultPort(int defaultPort) { return IP::_defaultPort; };
    5659
    5760  private:
    5861    int           _ip;           //!< The IP in int form.
    59     short         _port;         //!< The Port number of the IP
     62    int         _port;         //!< The Port number of the IP
    6063
    61     static short  _defaultPort;  //!< Default Port
     64    static int  _defaultPort;  //!< Default Port
    6265};
    6366
  • branches/proxy/src/lib/network/network_stream.cc

    r9357 r9360  
    488488        if ( it->second.handshake->ok() )
    489489        {
     490          // the server gave it free for deletion
    490491          if ( !it->second.handshake->allowDel() )
    491492          {
     
    568569  PRINTF(0)("Client is redirected to the other proxy servers\n");
    569570  PRINTF(0)("===============================================\n");
     571
     572  return;
    570573
    571574  PeerInfo* pInfo = &this->peers[userId];
  • branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_ip.cc

    r9349 r9360  
    5151  n += res;
    5252
     53
    5354  res = Converter::intToByteArray( (int)vPtrIn->port(), buf, maxLength);
    5455  assert(res > 0);
     
    8990
    9091  printf(" %s old: %i, %i -- new: %i, %i\n", name.c_str(), oldVal.host(), oldVal.port(), this->vPtrOut->host(), this->vPtrOut->port());
    91   setHasChanged( *this->vPtrOut != oldVal);
     92  this->setHasChanged( *this->vPtrOut != oldVal);
    9293
    93   assert( n == 2 * INTSIZE);
     94//   assert( n == 2 * INTSIZE);
    9495
    9596  return n;
Note: See TracChangeset for help on using the changeset viewer.