Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9584 in orxonox.OLD


Ignore:
Timestamp:
Jul 28, 2006, 10:22:09 PM (18 years ago)
Author:
patrick
Message:

proxy control center now registers joining clients to the network monitor

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

Legend:

Unmodified
Added
Removed
  • branches/proxy/src/lib/network/monitor/network_monitor.h

    r9583 r9584  
    7676
    7777    inline const std::list<NetworkNode*>& getNodeList() const { return this->nodeList; };
    78     inline PeerInfo* getPeerByUserId( int userId) { this->localNode->getPeerByUserId(userId); }
     78    inline PeerInfo* getPeerByUserId( int userId) { return this->localNode->getPeerByUserId(userId); }
    7979
    8080    void toggleGUI();
  • branches/proxy/src/lib/network/network_stream.cc

    r9583 r9584  
    121121  this->pInfo->lastAckedState = 0;
    122122  this->pInfo->lastRecvedState = 0;
     123  this->pInfo->bLocal = true;
    123124
    124125  this->bRedirect = false;
     
    200201  this->peers[node].connectionMonitor = new ConnectionMonitor( NET_ID_MASTER_SERVER );
    201202  this->peers[node].ip = this->peers[node].socket->getRemoteAddress();
     203  this->peers[node].bLocal = true;
    202204}
    203205
     
    219221  this->peers[proxyId].connectionMonitor = new ConnectionMonitor( proxyId );
    220222  this->peers[proxyId].ip = this->peers[proxyId].socket->getRemoteAddress();
     223  this->peers[proxyId].bLocal = true;
    221224}
    222225
     
    257260  // fake the unique id
    258261  hs->setUniqueID( NET_UID_HANDSHAKE );
    259   assert( peers[userId].handshake == NULL );
    260   peers[userId].handshake = hs;
     262  assert( this->peers[userId].handshake == NULL );
     263  this->peers[userId].handshake = hs;
     264  this->peers[userId].bLocal = true;
    261265
    262266  // set the preferred nick name
     
    495499{
    496500  // create new handshake and init its variables
    497   peers[userId].handshake = new Handshake(this->pInfo->nodeType, userId, this->networkGameManager->getUniqueID(), MessageManager::getInstance()->getUniqueID());
    498   peers[userId].handshake->setUniqueID(userId);
    499 
    500   peers[userId].connectionMonitor = new ConnectionMonitor( userId );
    501   peers[userId].userId = userId;
     501  this->peers[userId].handshake = new Handshake(this->pInfo->nodeType, userId, this->networkGameManager->getUniqueID(), MessageManager::getInstance()->getUniqueID());
     502  this->peers[userId].handshake->setUniqueID(userId);
     503
     504  this->peers[userId].connectionMonitor = new ConnectionMonitor( userId );
     505  this->peers[userId].userId = userId;
     506  this->peers[userId].bLocal = true;
    502507
    503508  PRINTF(0)("num sync: %d\n", synchronizeables.size());
     
    508513  if( pi != NULL)
    509514  {
    510     peers[userId].handshake->setProxy1Address( pi->ip);
     515    this->peers[userId].handshake->setProxy1Address( pi->ip);
    511516  }
    512517  pi = this->networkMonitor->getSecondChoiceProxy();
    513518  if( pi != NULL)
    514     peers[userId].handshake->setProxy2Address( pi->ip);
     519    this->peers[userId].handshake->setProxy2Address( pi->ip);
    515520
    516521  // check if the connecting client should reconnect to a proxy server
    517522  if( SharedNetworkData::getInstance()->isMasterServer())
    518     peers[userId].handshake->setRedirect(/*this->networkMonitor->isReconnectNextClient()*/false);
     523    this->peers[userId].handshake->setRedirect(/*this->networkMonitor->isReconnectNextClient()*/false);
    519524
    520525  // the connecting node of course is a client
    521   peers[userId].ip = peers[userId].socket->getRemoteAddress();
     526  this->peers[userId].ip = this->peers[userId].socket->getRemoteAddress();
    522527}
    523528
  • branches/proxy/src/lib/network/peer_info.cc

    r9545 r9584  
    4949  this->lastRecvedState = 0;
    5050  this->connectionMonitor = NULL;
     51  this->bLocal = false;
    5152
    5253  this->ip = IP(0,0);
  • branches/proxy/src/lib/network/peer_info.h

    r9494 r9584  
    3030    static const std::string& nodeTypeToString(unsigned int type);
    3131
     32    inline bool isLocal() { return this->bLocal; }
    3233
    3334
     
    4445    int                 lastRecvedState;         //!< last received state
    4546
     47    bool                bLocal;                  //!< true if this node is localy connected to this node
     48
    4649    static const std::string nodeNames[];
    4750
  • branches/proxy/src/lib/network/proxy/proxy_control.cc

    r9583 r9584  
    1818
    1919
    20 #include "player.h"
    2120#include "state.h"
    2221#include "shared_network_data.h"
    2322#include "network_game_manager.h"
     23#include "ip.h"
     24#include "peer_info.h"
    2425
    2526#include "converter.h"
     
    7778/**
    7879 *  signals new client connected to this local proxy
     80 *
     81 *  byte 0 - 3     :      userId
     82 *  byte 4 - 7     :      ip address (IPaddress.host)
     83 *
    7984 * @param userId userId of the new client
    8085 */
     
    9095  // and the ip as an int
    9196  PeerInfo* pInfo = SharedNetworkData::getInstance()->getNetworkMonitor()->getPeerByUserId(userId);
    92   assert( Converter::intToByteArray( userId, data, INTSIZE ) == INTSIZE );
    93 
    94   MessageManager::getInstance()->sendMessage( MSGID_PROXY_NEWCLIENT, data, INTSIZE, RT_SERVER, NET_UNASSIGNED, MP_HIGHBANDWIDTH );
     97  assert(pInfo != NULL);
     98  assert( Converter::intToByteArray( pInfo->ip.host(), data + INTSIZE, INTSIZE ) == INTSIZE );
     99
     100  MessageManager::getInstance()->sendMessage( MSGID_PROXY_NEWCLIENT, data, 2*INTSIZE, RT_SERVER, NET_UNASSIGNED, MP_HIGHBANDWIDTH );
    95101}
    96102
     
    118124  int newClientId = 0;
    119125  assert( Converter::byteArrayToInt( data, &newClientId) == INTSIZE );
     126  // now read the ip address
     127  int ipHost = 0;
     128  assert( Converter::byteArrayToInt( data + INTSIZE, &ipHost) == INTSIZE );
     129
     130  // register the new node at the network monitor
     131  NetworkMonitor* netMon = SharedNetworkData::getInstance()->getNetworkMonitor();
     132  PeerInfo* pInfo = new PeerInfo();
     133  pInfo->bLocal = false;
     134  pInfo->ip = IP(ipHost, 0);
     135  pInfo->nodeType = NET_CLIENT;
     136  netMon->addNode(pInfo);
    120137
    121138  PRINTF(0)("Got Signal: from %i new player arrived with userId: %i\n", senderId, newClientId);
Note: See TracChangeset for help on using the changeset viewer.