Changeset 6695 in orxonox.OLD for trunk/src/lib/network/network_stream.cc
- Timestamp:
- Jan 25, 2006, 2:39:53 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/network/network_stream.cc
r6634 r6695 53 53 } 54 54 55 55 56 NetworkStream::NetworkStream(IPaddress& address) 56 57 { … … 60 61 this->networkProtocol = new NetworkProtocol(); 61 62 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());68 63 this->maxConnections = 1; 69 64 } … … 81 76 this->handshakes.push_back( NULL ); 82 77 this->bActive = true; 83 this->networkGameManager = NetworkGameManager::getInstance();84 // setUniqueID( maxCon+2 ) because we need one id for every handshake85 // and one for handshake to reject client maxCon+186 this->networkGameManager->setUniqueID( this->maxConnections+2 );87 this->connectSynchronizeable( *(this->networkGameManager) );88 89 this->setMaxConnections( 10 );90 78 } 91 79 … … 132 120 133 121 122 void 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 133 void 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 134 143 void NetworkStream::connectSynchronizeable(Synchronizeable& sync) 135 144 { … … 140 149 this->bActive = true; 141 150 } 151 142 152 143 153 void NetworkStream::disconnectSynchronizeable(Synchronizeable& sync) … … 184 194 if ( type != NET_SERVER ) 185 195 { 186 NetworkManager::getInstance()->setHostID( handshakes[i]->getHostId() );196 SharedNetworkData::getInstance()->setHostID( handshakes[i]->getHostId() ); 187 197 myHostId = NetworkManager::getInstance()->getHostID(); 188 198 189 199 this->networkGameManager = NetworkGameManager::getInstance(); 190 200 this->networkGameManager->setUniqueID( handshakes[i]->getNetworkGameManagerId() ); 191 this->connectSynchronizeable( *(this->networkGameManager) );201 //this->connectSynchronizeable( *(this->networkGameManager) ); 192 202 } 193 203 else … … 216 226 /* DOWNSTREAM */ 217 227 228 229 218 230 int dataLength; 219 231 int reciever; … … 221 233 for (SynchronizeableList::iterator it = synchronizeables.begin(); it!=synchronizeables.end(); it++) 222 234 { 223 if ( (*it)!=NULL /*&& (*it)->getOwner() == myHostId*/ )235 if ( (*it)!=NULL && (*it)->beSynchronized() /*&& (*it)->getOwner() == myHostId*/ ) 224 236 { 225 237 do { … … 357 369 PRINTF(0)("New Client: %d\n", clientId); 358 370 359 this->connectSynchronizeable(*handshakes[clientId]);371 //this->connectSynchronizeable(*handshakes[clientId]); 360 372 } 361 373 … … 416 428 417 429 430 431 void 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 450 int 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.