Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 27, 2006, 8:29:32 PM (19 years ago)
Author:
patrick
Message:

new the message handler is checking, if this message is also for the local host. if not the system tries to relay the message

File:
1 edited

Legend:

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

    r9521 r9522  
    227227         outgoingMessageQueue[userId].recievedMessages.end() )
    228228    {
     229
     230//       RT_ALL_BUT_ME = 1,   //!< message is sent to all users but myself
     231//       RT_ALL_ME,           //!< message is sent to all users
     232//       RT_USER,             //!< message is only sent to reciever
     233//       RT_NOT_USER,         //!< message is sent to all but reciever
     234//       RT_SERVER
     235
     236      // find out if this message is addressed for this client too
     237      if( messageType == RT_ALL_BUT_ME ||
     238          messageType == RT_ALL_ME ||
     239          messageType == RT_USER  && SharedNetworkData::getInstance()->getHostID() == destinationId ||
     240          messageType == RT_SERVER && SharedNetworkData::getInstance()->isMasterServer())
     241      {
     242
    229243      // call the handler function and handle errors
    230       if ( !(*(messageHandlerMap[(MessageType)messageType].cb))( (MessageType)messageType, data + i, messageLength,
    231                                                                  messageHandlerMap[(MessageType)messageType].someData, senderId, destinationId ) )
     244        if ( !(*(messageHandlerMap[(MessageType)messageType].cb))( (MessageType)messageType, data + i, messageLength,
     245                 messageHandlerMap[(MessageType)messageType].someData, senderId, destinationId ) )
     246        {
     247        // if the message is not handled correctly, bush it back to the incoming packets
     248          NetworkMessage msg;
     249
     250          msg.data = new byte[messageLength];
     251          memcpy( msg.data, data + i, messageLength );
     252          msg.length = messageLength;
     253          msg.messageType = (MessageType)messageType;
     254          msg.number = userId;
     255          msg.senderId = senderId;
     256          msg.destinationId = destinationId;
     257
     258          incomingMessageQueue.push_back( msg );
     259        }
     260      // save the serial number for ack signaling
     261        outgoingMessageQueue[userId].recievedMessages.push_back( number );
     262        PRINTF(0)("<<< MessageManager: got msg with type: %i, from sender %i, to rec: %i\n", messageType, senderId, destinationId);
     263      }
     264      // or else forward the message to the other servers
     265      else
    232266      {
    233         // if the message is not handled correctly, bush it back to the incoming packets
     267        PRINTF(0)("===========>> Forwarding Message\n");
    234268        NetworkMessage msg;
    235269
     
    244278        incomingMessageQueue.push_back( msg );
    245279      }
    246       // save the serial number for ack signaling
    247       outgoingMessageQueue[userId].recievedMessages.push_back( number );
    248       PRINTF(0)("<<< MessageManager: got msg with type: %i\n", messageType);
    249     }
     280    }
     281
    250282    i += messageLength;
    251283  }
Note: See TracChangeset for help on using the changeset viewer.