Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7954 in orxonox.OLD for trunk/src/lib/network/network_manager.cc


Ignore:
Timestamp:
May 29, 2006, 3:28:41 PM (19 years ago)
Author:
patrick
Message:

trunk: merged the network branche back to trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/network/network_manager.cc

    r7256 r7954  
    2828#include "shared_network_data.h"
    2929#include "network_stream.h"
     30#include "preferences.h"
     31#include "network_log.h"
    3032
    3133
     
    5254  this->defaultSyncStream = NULL;
    5355  this->sharedNetworkData = SharedNetworkData::getInstance();
     56  this->elapsedTime = 0.0f;
     57 
     58   
     59  int port = Preferences::getInstance()->getInt( "network", "telnetport", 0 );
     60 
     61  if ( port > 0 )
     62    NetworkLog::getInstance()->listen( port );
    5463
    5564  PRINTF(0)("NetworkManager created\n");
     
    7281  this->netStreamList = ClassList::getList(CL_SYNCHRONIZEABLE);
    7382  PRINTF(0)("NetworkManager initzalized\n");
     83
    7484}
    7585
     
    90100int NetworkManager::establishConnection(const std::string & name, unsigned int port)
    91101{
    92   IPaddress ipAddress;
    93   int error = SDLNet_ResolveHost(&ipAddress, name.c_str(), port);
    94   if( error == -1) {
    95     printf("\n\nerror on address resolution, program inconsistency\n\n");
    96     return -1;
    97   }
    98 
    99   this->defaultSyncStream = new NetworkStream(ipAddress);
     102  this->defaultSyncStream = new NetworkStream( name, port );
    100103  this->sharedNetworkData->setDefaultSyncStream(this->defaultSyncStream);
    101104  this->defaultSyncStream->startHandshake();
     
    130133/**
    131134 *  sync the network
     135 *  @param dtS: the seceonds elapsed since the last synchronize call
    132136 */
    133 void NetworkManager::synchronize()
     137void NetworkManager::synchronize( float dtS)
    134138{
     139  this->elapsedTime += dtS;
     140  if( likely(this->elapsedTime < 1.0f / NETWORK_FREQUENCY))
     141    return;
     142  this->elapsedTime = 0.0f;
     143
    135144  if (this->netStreamList != NULL || (this->netStreamList = ClassList::getList(CL_NETWORK_STREAM)) != NULL)
    136145  {
Note: See TracChangeset for help on using the changeset viewer.