Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9520 in orxonox.OLD


Ignore:
Timestamp:
Jul 27, 2006, 7:40:42 PM (18 years ago)
Author:
patrick
Message:

sender now also include the source and destination userId so they can be propageted correctly through the network

File:
1 edited

Legend:

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

    r9519 r9520  
    102102  assert( n == INTSIZE );
    103103
     104  // write the message down, a message has this structure:
     105  //   | data_length | serial_number | message_type | source_id | dest_id | ...data... |
     106  //      4byte        4byte            4byte         4byte      4byte     data_length
    104107  for ( std::list<NetworkMessage>::iterator it = outgoingMessageQueue[userId].messages.begin(); it != outgoingMessageQueue[userId].messages.end(); it++ )
    105108  {
     
    113116
    114117    n = Converter::intToByteArray( it->messageType, data + i, maxLength );
     118    i += n;
     119    assert( n == INTSIZE );
     120
     121    n = Converter::intToByteArray( it->senderId, data + i, maxLength );
     122    i += n;
     123    assert( n == INTSIZE );
     124
     125    n = Converter::intToByteArray( it->destinationId, data + i, maxLength );
    115126    i += n;
    116127    assert( n == INTSIZE );
     
    169180
    170181  int messageLength, messageType;
    171 
    172   // now go through all newly received messages
     182  int senderId, destinationId;
     183
     184  // now go through all newly received messages and assemble them
    173185  for ( int j = 0; j < nMessages; j++ )
    174186  {
     187    // read the length
    175188    assert( i + INTSIZE <= length );
    176189    n = Converter::byteArrayToInt( data + i, &messageLength );
     
    178191    i += n;
    179192
     193    // read the serial number
    180194    assert( i + INTSIZE <= length );
    181195    n = Converter::byteArrayToInt( data + i, &number );
     
    183197    i += n;
    184198
     199    // read the message type
    185200    assert( i + INTSIZE <= length );
    186201    n = Converter::byteArrayToInt( data + i, &messageType );
    187202    assert( n == INTSIZE );
    188203    i += n;
     204
     205    // read the sender id
     206    assert( i + INTSIZE <= length );
     207    n = Converter::byteArrayToInt( data + i, &senderId );
     208    assert( n == INTSIZE );
     209    i += n;
     210
     211    //read the destination id
     212    assert( i + INTSIZE <= length );
     213    n = Converter::byteArrayToInt( data + i, &destinationId);
     214    assert( n == INTSIZE );
     215    i += n;
     216
    189217
    190218    if ( number > 0 )
     
    203231                                                                 messageHandlerMap[(MessageType)messageType].someData, userId ) )
    204232      {
     233        // if the message is not handled correctly, bush it back to the incoming packets
    205234        NetworkMessage msg;
    206235
     
    210239        msg.messageType = (MessageType)messageType;
    211240        msg.number = userId;
     241        msg.senderId = senderId;
     242        msg.destinationId = destinationId;
    212243
    213244        incomingMessageQueue.push_back( msg );
    214245      }
     246      // save the serial number for ack signaling
    215247      outgoingMessageQueue[userId].recievedMessages.push_back( number );
    216248      PRINTF(0)("<<< MessageManager: got msg with type: %i\n", messageType);
Note: See TracChangeset for help on using the changeset viewer.