Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9584 in orxonox.OLD for branches/proxy/src/lib/network/proxy


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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.