Changeset 8481 in orxonox.OLD for branches/network/src/lib
- Timestamp:
- Jun 15, 2006, 4:59:47 PM (19 years ago)
- Location:
- branches/network/src/lib/network
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/connection_monitor.cc
r8068 r8481 130 130 131 131 /** 132 * remove old packets 133 * @param packetHistory 134 * @param tick 135 */ 136 void ConnectionMonitor::removeOldPackets( std::map< int, int > & packetHistory, int tick ) 137 { 138 while ( packetHistory.begin()->first < tick - MSECS_TO_CALC_BWIDTH ) 139 packetHistory.erase( packetHistory.begin() ); 140 } 141 142 /** 132 143 * calculate bandwidth out of packethistory 133 144 * @param packetHistory packet history … … 135 146 * @return bandwidth in bytes/sec 136 147 */ 137 float ConnectionMonitor::calculateBandWidth( std::map< int, int > packetHistory, int tick ) 138 { 139 // delete old packets 140 while ( packetHistory.begin()->first < tick - MSECS_TO_CALC_BWIDTH ) 141 packetHistory.erase( packetHistory.begin() ); 148 float ConnectionMonitor::calculateBandWidth( std::map< int, int > & packetHistory, int tick ) 149 { 150 removeOldPackets( packetHistory, tick ); 142 151 143 152 float res = 0.0f; -
branches/network/src/lib/network/connection_monitor.h
r8301 r8481 35 35 36 36 private: 37 float calculateBandWidth( std::map<int,int> packetHistory, int tick ); 37 float calculateBandWidth( std::map<int,int> & packetHistory, int tick ); 38 void removeOldPackets( std::map<int,int> & packetHistory, int tick ); 38 39 39 40 int userId; //!< user's id -
branches/network/src/lib/network/network_stream.cc
r8476 r8481 517 517 writeToNewDict( buf, offset ); 518 518 519 //TODO use connectionMonitor 520 //peer->second.connectionMonitor->processUnzippedOutgoingPacket( tick, buf, offset, currentState ); 521 //peer->second.connectionMonitor->processZippedOutgoingPacket( tick, compBuf, compLength, currentState ); 519 peer->second.connectionMonitor->processUnzippedOutgoingPacket( tick, buf, offset, currentState ); 520 peer->second.connectionMonitor->processZippedOutgoingPacket( tick, compBuf, compLength, currentState ); 522 521 523 522 //NETPRINTF(n)("send packet: %d userId = %d\n", offset, peer->second.userId); … … 549 548 while ( 0 < (compLength = peer->second.socket->readPacket( compBuf, UDP_PACKET_SIZE )) ) 550 549 { 551 //TODO use networkMonitor 552 //peer->second.connectionMonitor->processZippedIncomingPacket( tick, compBuf, compLength ); 550 peer->second.connectionMonitor->processZippedIncomingPacket( tick, compBuf, compLength ); 553 551 554 552 //PRINTF(0)("GGGGGOOOOOOOOOOTTTTTTTT: %d\n", compLength); … … 572 570 offset = 4*INTSIZE; 573 571 574 //TODO use connectoinMonitor 575 //peer->second.connectionMonitor->processUnzippedIncomingPacket( tick, buf, offset, state, ackedState ); 572 peer->second.connectionMonitor->processUnzippedIncomingPacket( tick, buf, offset, state, ackedState ); 576 573 577 574 //NETPRINTF(n)("got packet: %d, %d\n", length, packetLength);
Note: See TracChangeset
for help on using the changeset viewer.