Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9406 in orxonox.OLD for trunk/src/lib/network/network_manager.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/network_manager.cc

    r9059 r9406  
    1010
    1111   ### File Specific:
    12    main-programmer: Patrick Boenzli
    13    co-programmer: ...
     12   main-programmer: Patrick Boenzli (patrick@orxonox.ethz.ch)
     13   co-programmer: Christoph Renner (rennerc@ee.ethz.ch)
    1414*/
    1515
     
    3434
    3535/* using namespace std is default, this needs to be here */
    36 using namespace std;
     36
    3737
    3838SHELL_COMMAND(debug, NetworkManager, debug);
     
    5353  this->networkStream = NULL;
    5454  this->elapsedTime = 0.0f;
    55  
    56    
     55
     56
    5757  int port = Preferences::getInstance()->getInt( "network", "telnetport", 0 );
    58  
     58
    5959  if ( port > 0 )
    6060    NetworkLog::getInstance()->listen( port );
     
    7575    this->networkStream = NULL;
    7676  }
    77  
     77
    7878  NetworkManager::singletonRef = NULL;
    7979}
     
    9595{
    9696
     97}
     98
     99
     100
     101/**
     102 *  creates a new NetworkStream of server type
     103 * @param port: number of the TCP port
     104 */
     105int NetworkManager::createMasterServer(unsigned int port)
     106{
     107  // load the network settings
     108  NetworkSettings::getInstance()->loadData();
     109
     110  // create the network stream
     111  this->networkStream = new NetworkStream(NET_MASTER_SERVER);
     112  this->networkStream->createServer( port);
     113
     114  // start the network game manager
     115  this->networkStream->createNetworkGameManager();
     116
     117  PRINTF(0)("Created Network Master Server\n");
     118  SDL_Delay(20);
     119  return 1;
     120}
     121
     122/**
     123 *  creates a new network stream of proxy server type
     124 * @param port: number of the TCP port
     125 */
     126int NetworkManager::createProxyServer(unsigned int port)
     127{
     128  // load the network settings
     129  NetworkSettings::getInstance()->loadData();
     130
     131  // create the network stream
     132  this->networkStream = new NetworkStream(NET_PROXY_SERVER_ACTIVE);
     133  this->networkStream->createServer( port);
     134  // and connect to the master server for synchronization
     135//   this->networkStream->connectToMasterServer(NetworkSettings::getInstance()->getMasterAddr());
     136  // and to the other proxy servers
     137
     138
     139
     140  // start the network game manager
     141  this->networkStream->createNetworkGameManager();
     142
     143
     144  PRINTF(0)("Created Network Proxy Server\n");
     145  SDL_Delay(20);
     146  return 1;
    97147}
    98148
     
    102152 * @param hostName: the name of the destination host
    103153 */
    104 int NetworkManager::establishConnection(const std::string & name, unsigned int port)
    105 {
    106   this->networkStream = new NetworkStream( name, port );
    107   SharedNetworkData::getInstance()->setDefaultSyncStream(this->networkStream);
     154int NetworkManager::createClient(const std::string & name, unsigned int port)
     155{
     156  // load the network settings
     157  NetworkSettings::getInstance()->loadData();
     158
     159  // create the network stream
     160  this->networkStream = new NetworkStream(NET_CLIENT);
     161  // connect to the master server, if a redirection should occure, this is handled in the NetworkStream itself
     162  this->networkStream->connectToMasterServer( name, port);
     163
     164  // and start the handshake
    108165  this->networkStream->startHandshake();
     166
     167  PRINTF(0)("Created Network Client");
    109168  return 1;
    110169}
     
    112171
    113172/**
    114  *  creates a new NetworkStream of server type
    115  * @param port: number of the TCP port
    116  */
    117 int NetworkManager::createServer(unsigned int port)
    118 {
    119   SharedNetworkData::getInstance()->setHostID(0);
    120   SharedNetworkData::getInstance()->setGameServer(true);
    121   this->networkStream = new NetworkStream(port);
    122   SharedNetworkData::getInstance()->setDefaultSyncStream(this->networkStream);
    123   this->networkStream->createNetworkGameManager();
    124   PRINTF(0)("CREATE SERVER\n");
    125   SDL_Delay(20);
    126   return 1;
    127 }
    128 
    129 
     173 * connects a synchronizeable to the network stream
     174 * @param sync: synchronizeable to connect
     175 */
    130176void NetworkManager::connectSynchronizeable(Synchronizeable& sync)
    131177{
     
    144190  if( likely(this->elapsedTime < 1.0f / NETWORK_FREQUENCY))
    145191    return;
     192
    146193  this->elapsedTime = 0.0f;
    147194
    148   if ( networkStream )
     195  if ( this->networkStream )
    149196    networkStream->processData();
    150  
     197
    151198  NetworkGameManager::getInstance()->tick( this->elapsedTime );
    152199}
Note: See TracChangeset for help on using the changeset viewer.