Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6695 in orxonox.OLD for trunk/src/lib/network/network_stream.cc


Ignore:
Timestamp:
Jan 25, 2006, 2:39:53 PM (18 years ago)
Author:
patrick
Message:

merged the network branche to the trunk

File:
1 edited

Legend:

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

    r6634 r6695  
    5353}
    5454
     55
    5556NetworkStream::NetworkStream(IPaddress& address)
    5657{
     
    6061  this->networkProtocol = new NetworkProtocol();
    6162  this->connectionMonitor = new ConnectionMonitor();
    62 
    63   Handshake* hs = new Handshake(false);
    64   hs->setUniqueID( 0 );
    65   this->handshakes.push_back(hs);
    66   this->connectSynchronizeable(*hs);
    67   PRINTF(0)("NetworkStream: %s\n", hs->getName());
    6863  this->maxConnections = 1;
    6964}
     
    8176  this->handshakes.push_back( NULL );
    8277  this->bActive = true;
    83   this->networkGameManager = NetworkGameManager::getInstance();
    84   // setUniqueID( maxCon+2 ) because we need one id for every handshake
    85   // and one for handshake to reject client maxCon+1
    86   this->networkGameManager->setUniqueID( this->maxConnections+2 );
    87   this->connectSynchronizeable( *(this->networkGameManager) );
    88 
    89   this->setMaxConnections( 10 );
    9078}
    9179
     
    132120
    133121
     122void NetworkStream::createNetworkGameManager()
     123{
     124  this->networkGameManager = NetworkGameManager::getInstance();
     125  // setUniqueID( maxCon+2 ) because we need one id for every handshake
     126  // and one for handshake to reject client maxCon+1
     127  this->networkGameManager->setUniqueID( this->maxConnections + 2 );
     128  //this->connectSynchronizeable( *(this->networkGameManager) );
     129  this->setMaxConnections( 10 );
     130}
     131
     132
     133void NetworkStream::startHandshake()
     134{
     135  Handshake* hs = new Handshake(false);
     136  hs->setUniqueID( 0 );
     137  this->handshakes.push_back(hs);
     138  //this->connectSynchronizeable(*hs);
     139  PRINTF(0)("NetworkStream: %s\n", hs->getName());
     140}
     141
     142
    134143void NetworkStream::connectSynchronizeable(Synchronizeable& sync)
    135144{
     
    140149    this->bActive = true;
    141150}
     151
    142152
    143153void NetworkStream::disconnectSynchronizeable(Synchronizeable& sync)
     
    184194          if ( type != NET_SERVER )
    185195          {
    186             NetworkManager::getInstance()->setHostID( handshakes[i]->getHostId() );
     196            SharedNetworkData::getInstance()->setHostID( handshakes[i]->getHostId() );
    187197            myHostId = NetworkManager::getInstance()->getHostID();
    188198
    189199            this->networkGameManager = NetworkGameManager::getInstance();
    190200            this->networkGameManager->setUniqueID( handshakes[i]->getNetworkGameManagerId() );
    191             this->connectSynchronizeable( *(this->networkGameManager) );
     201            //this->connectSynchronizeable( *(this->networkGameManager) );
    192202          }
    193203          else
     
    216226  /* DOWNSTREAM */
    217227
     228
     229
    218230  int dataLength;
    219231  int reciever;
     
    221233  for (SynchronizeableList::iterator it = synchronizeables.begin(); it!=synchronizeables.end(); it++)
    222234  {
    223     if ( (*it)!=NULL /*&& (*it)->getOwner() == myHostId*/ )
     235    if ( (*it)!=NULL && (*it)->beSynchronized() /*&& (*it)->getOwner() == myHostId*/ )
    224236    {
    225237      do {
     
    357369    PRINTF(0)("New Client: %d\n", clientId);
    358370
    359     this->connectSynchronizeable(*handshakes[clientId]);
     371    //this->connectSynchronizeable(*handshakes[clientId]);
    360372  }
    361373
     
    416428
    417429
     430
     431void NetworkStream::debug()
     432{
     433  if( this->isServer())
     434    PRINT(0)(" Host ist Server with ID: %i\n", this->myHostId);
     435  else
     436    PRINT(0)(" Host ist Client with ID: %i\n", this->myHostId);
     437
     438  PRINT(0)(" Got %i connected Synchronizeables, showing active Syncs:\n", this->synchronizeables.size());
     439  for (SynchronizeableList::iterator it = synchronizeables.begin(); it!=synchronizeables.end(); it++)
     440  {
     441    if( (*it)->beSynchronized() == true)
     442      PRINT(0)("  Synchronizeable of class: %s::%s, with unique ID: %i, Synchronize: %i\n", (*it)->getClassName(), (*it)->getName(),
     443               (*it)->getUniqueID(), (*it)->beSynchronized());
     444  }
     445  PRINT(0)(" Maximal Connections: %i\n", this->maxConnections);
     446
     447}
     448
     449
     450int NetworkStream::getSyncCount()
     451{
     452  int n = 0;
     453  for (SynchronizeableList::iterator it = synchronizeables.begin(); it!=synchronizeables.end(); it++)
     454    if( (*it)->beSynchronized() == true)
     455      ++n;
     456
     457  //return synchronizeables.size();
     458  return n;
     459}
     460
     461
     462
     463
     464
     465
Note: See TracChangeset for help on using the changeset viewer.