Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9655 in orxonox.OLD for branches/proxy/src


Ignore:
Timestamp:
Aug 1, 2006, 1:34:47 AM (18 years ago)
Author:
patrick
Message:

local messages now get also delivered via an externaly polled function

Location:
branches/proxy/src/lib/network
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/proxy/src/lib/network/message_manager.cc

    r9653 r9655  
    263263                 messageHandlerMap[(MessageType)messageType].someData, senderId, destinationId ) )
    264264        {
    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
    266266          NetworkMessage msg;
    267267
     
    313313  }
    314314
     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 */
     345void MessageManager::processData()
     346{
    315347  // 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 connected
    317348  for ( std::list<NetworkMessage>::iterator it = incomingMessageQueue.begin(); it != incomingMessageQueue.end();  )
    318349  {
     350    PRINTF(0)("<<< MessageManager: got local msg with type: %i, from sender %i, to rec: %i\n", (*it).messageType, (*it).senderId, (*it).destinationId);
     351
    319352    if ( (*(messageHandlerMap[it->messageType].cb))( it->messageType, it->data, it->length, messageHandlerMap[it->messageType].someData,
    320353                                                     /*it->number, */it->senderId, it->destinationId ) )
     
    330363  }
    331364
    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
    354367
    355368
     
    480493
    481494  // 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     )
    483498  {
    484499    NetworkMessage msg;
     
    494509    msg.priority = messagePriority;
    495510
    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  
    9595//! A class for sending messages over network
    9696class MessageManager : public Synchronizeable {
    97  protected:
    98    MessageManager();
     97
     98
    9999 public:
    100100   inline static MessageManager * getInstance(){ if (!singletonRef) singletonRef = new MessageManager();  return singletonRef; }
     
    108108
    109109   void initUser( int userId );
     110
     111   void processData();
     112
     113
     114  protected:
     115    MessageManager();
    110116
    111117
  • branches/proxy/src/lib/network/network_stream.cc

    r9654 r9655  
    390390  this->handleDownstream( tick );
    391391  this->handleUpstream( tick );
     392
     393  // process the local data of the message manager
     394  MessageManager::getInstance()->processData();
    392395
    393396  if( this->bSoftRedirect)
Note: See TracChangeset for help on using the changeset viewer.