Changeset 9655 in orxonox.OLD for branches/proxy/src
- Timestamp:
- Aug 1, 2006, 1:34:47 AM (18 years ago)
- Location:
- branches/proxy/src/lib/network
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/proxy/src/lib/network/message_manager.cc
r9653 r9655 263 263 messageHandlerMap[(MessageType)messageType].someData, senderId, destinationId ) ) 264 264 { 265 // if the message is not handled correctly, bush it back to the incoming packets 265 // if the message is not handled correctly, bush it back to the incoming packets therefore trying it later 266 266 NetworkMessage msg; 267 267 … … 313 313 } 314 314 315 316 //walk throu message queue and remove acked messages 317 for ( std::list<NetworkMessage>::iterator it = outgoingMessageQueue[userId].messages.begin(); it != outgoingMessageQueue[userId].messages.end(); ) 318 { 319 if ( std::find( acks.begin(), acks.end(), it->number) != acks.end() ) 320 { 321 std::list<NetworkMessage>::iterator delIt = it; 322 it++; 323 outgoingMessageQueue[userId].messages.erase( delIt ); 324 continue; 325 } 326 it++; 327 } 328 329 //TODO find bether way. maybe with timestamp 330 if ( outgoingMessageQueue[userId].recievedMessages.size() > 1000 ) 331 { 332 for ( int j = 0; j < (int)outgoingMessageQueue[userId].recievedMessages.size() - 1000; j++ ) 333 outgoingMessageQueue[userId].recievedMessages.erase( outgoingMessageQueue[userId].recievedMessages.begin() ); 334 } 335 336 return i; 337 } 338 339 340 341 342 /** 343 * processes the message manager data, specialy check for localy generated messages 344 */ 345 void MessageManager::processData() 346 { 315 347 // now call the message handlers with the new message 316 //TODO maybe handle incomingMessage in tick function. else local messages will not be handled if no clients are connected317 348 for ( std::list<NetworkMessage>::iterator it = incomingMessageQueue.begin(); it != incomingMessageQueue.end(); ) 318 349 { 350 PRINTF(0)("<<< MessageManager: got local msg with type: %i, from sender %i, to rec: %i\n", (*it).messageType, (*it).senderId, (*it).destinationId); 351 319 352 if ( (*(messageHandlerMap[it->messageType].cb))( it->messageType, it->data, it->length, messageHandlerMap[it->messageType].someData, 320 353 /*it->number, */it->senderId, it->destinationId ) ) … … 330 363 } 331 364 332 //walk throu message queue and remove acked messages 333 for ( std::list<NetworkMessage>::iterator it = outgoingMessageQueue[userId].messages.begin(); it != outgoingMessageQueue[userId].messages.end(); ) 334 { 335 if ( std::find( acks.begin(), acks.end(), it->number) != acks.end() ) 336 { 337 std::list<NetworkMessage>::iterator delIt = it; 338 it++; 339 outgoingMessageQueue[userId].messages.erase( delIt ); 340 continue; 341 } 342 it++; 343 } 344 345 //TODO find bether way. maybe with timestamp 346 if ( outgoingMessageQueue[userId].recievedMessages.size() > 1000 ) 347 { 348 for ( int j = 0; j < (int)outgoingMessageQueue[userId].recievedMessages.size() - 1000; j++ ) 349 outgoingMessageQueue[userId].recievedMessages.erase( outgoingMessageQueue[userId].recievedMessages.begin() ); 350 } 351 352 return i; 353 } 365 } 366 354 367 355 368 … … 480 493 481 494 // if the message is also for myself, handle it here 482 if ( recieverType == RT_ALL_ME ) 495 if ( recieverType == RT_ALL_ME || 496 recieverType == RT_USER && reciever == SharedNetworkData::getInstance()->getHostID() 497 ) 483 498 { 484 499 NetworkMessage msg; … … 494 509 msg.priority = messagePriority; 495 510 496 incomingMessageQueue.push_back( msg );497 } 498 } 499 500 511 this->incomingMessageQueue.push_back( msg ); 512 } 513 } 514 515 -
branches/proxy/src/lib/network/message_manager.h
r9599 r9655 95 95 //! A class for sending messages over network 96 96 class MessageManager : public Synchronizeable { 97 protected: 98 MessageManager(); 97 98 99 99 public: 100 100 inline static MessageManager * getInstance(){ if (!singletonRef) singletonRef = new MessageManager(); return singletonRef; } … … 108 108 109 109 void initUser( int userId ); 110 111 void processData(); 112 113 114 protected: 115 MessageManager(); 110 116 111 117 -
branches/proxy/src/lib/network/network_stream.cc
r9654 r9655 390 390 this->handleDownstream( tick ); 391 391 this->handleUpstream( tick ); 392 393 // process the local data of the message manager 394 MessageManager::getInstance()->processData(); 392 395 393 396 if( this->bSoftRedirect)
Note: See TracChangeset
for help on using the changeset viewer.