Changeset 9520 in orxonox.OLD for branches/proxy/src
- Timestamp:
- Jul 27, 2006, 7:40:42 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/proxy/src/lib/network/message_manager.cc
r9519 r9520 102 102 assert( n == INTSIZE ); 103 103 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 104 107 for ( std::list<NetworkMessage>::iterator it = outgoingMessageQueue[userId].messages.begin(); it != outgoingMessageQueue[userId].messages.end(); it++ ) 105 108 { … … 113 116 114 117 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 ); 115 126 i += n; 116 127 assert( n == INTSIZE ); … … 169 180 170 181 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 173 185 for ( int j = 0; j < nMessages; j++ ) 174 186 { 187 // read the length 175 188 assert( i + INTSIZE <= length ); 176 189 n = Converter::byteArrayToInt( data + i, &messageLength ); … … 178 191 i += n; 179 192 193 // read the serial number 180 194 assert( i + INTSIZE <= length ); 181 195 n = Converter::byteArrayToInt( data + i, &number ); … … 183 197 i += n; 184 198 199 // read the message type 185 200 assert( i + INTSIZE <= length ); 186 201 n = Converter::byteArrayToInt( data + i, &messageType ); 187 202 assert( n == INTSIZE ); 188 203 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 189 217 190 218 if ( number > 0 ) … … 203 231 messageHandlerMap[(MessageType)messageType].someData, userId ) ) 204 232 { 233 // if the message is not handled correctly, bush it back to the incoming packets 205 234 NetworkMessage msg; 206 235 … … 210 239 msg.messageType = (MessageType)messageType; 211 240 msg.number = userId; 241 msg.senderId = senderId; 242 msg.destinationId = destinationId; 212 243 213 244 incomingMessageQueue.push_back( msg ); 214 245 } 246 // save the serial number for ack signaling 215 247 outgoingMessageQueue[userId].recievedMessages.push_back( number ); 216 248 PRINTF(0)("<<< MessageManager: got msg with type: %i\n", messageType);
Note: See TracChangeset
for help on using the changeset viewer.