- Timestamp:
- May 18, 2006, 12:58:08 PM (19 years ago)
- Location:
- branches/network/src/lib/network
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/message_manager.cc
r7671 r7678 130 130 int nAcks; 131 131 132 assert( i + INTSIZE <= length ); 132 133 n = Converter::byteArrayToInt( data + i, &nAcks ); 133 134 assert( n == INTSIZE ); … … 140 141 for ( int j = 0; j < nAcks; j++ ) 141 142 { 143 assert( i + INTSIZE <= length ); 142 144 n = Converter::byteArrayToInt( data + i, &number ); 143 145 assert( n == INTSIZE ); … … 149 151 int nMessages; 150 152 153 assert( i + INTSIZE <= length ); 151 154 n = Converter::byteArrayToInt( data + i, &nMessages ); 152 155 assert( n == INTSIZE ); 153 156 i += n; 157 158 int messageLength, messageId; 154 159 155 160 for ( int j = 0; j < nMessages; j++ ) 156 161 { 157 } 162 assert( i + INTSIZE <= length ); 163 n = Converter::byteArrayToInt( data + i, &messageLength ); 164 assert( n == INTSIZE ); 165 i += n; 166 167 assert( i + INTSIZE <= length ); 168 n = Converter::byteArrayToInt( data + i, &number ); 169 assert( n == INTSIZE ); 170 i += n; 171 172 assert( i + INTSIZE <= length ); 173 n = Converter::byteArrayToInt( data + i, &messageId ); 174 assert( n == INTSIZE ); 175 i += n; 176 177 if ( number > 0 ) 178 messageQueue[userId].toAck.push_back( number ); 179 180 assert( i + messageLength <= length ); 181 assert( messageHandlerMap.find( (MessageId)messageId ) != messageHandlerMap.end() ); 182 (*(messageHandlerMap[(MessageId)messageId].cb))( (MessageId)messageId, data + i, messageLength, messageHandlerMap[(MessageId)messageId].someData, userId ); 183 i += messageLength; 184 } 185 186 return i; 158 187 } 159 188 … … 164 193 void MessageManager::cleanUpUser( int userId ) 165 194 { 195 if ( messageQueue.find( userId ) == messageQueue.end() ) 196 return; 197 198 for ( std::list<NetworkMessage>::iterator it = messageQueue[userId].messages.begin(); it != messageQueue[userId].messages.end(); it++ ) 199 { 200 if ( it->data ) 201 delete it->data; 202 it->data = NULL; 203 } 204 205 messageQueue[userId].toAck.clear(); 206 207 messageQueue.erase( userId ); 166 208 } 167 209 … … 175 217 bool MessageManager::registerMessageHandler( MessageId messageId, MessageCallback cb, void * someData ) 176 218 { 219 MessageHandler messageHandler; 220 221 messageHandler.cb = cb; 222 messageHandler.messageId = messageId; 223 messageHandler.someData = someData; 224 225 messageHandlerMap[messageId] = messageHandler; 226 227 return true; 177 228 } 178 229 … … 183 234 void MessageManager::initUser( int userId ) 184 235 { 185 } 236 // just do something so map creates a new entry 237 messageQueue[userId].toAck.clear(); 238 assert( messageQueue[userId].messages.size() == 0 ); 239 } -
branches/network/src/lib/network/message_manager.h
r7671 r7678 20 20 int length 21 21 int number 22 byteMessageId22 int MessageId 23 23 byte * data 24 24 )[1..nmsg] 25 25 */ 26 27 typedef void (*MessageCallback)( byte * data, int dataLength, void * someData, int userId );28 26 29 27 … … 31 29 { 32 30 }; 31 32 typedef void (*MessageCallback)( MessageId messageId, byte * data, int dataLength, void * someData, int userId ); 33 33 34 34 enum RecieverType … … 59 59 MessageCallback cb; 60 60 MessageId messageId; 61 void * someData; 61 62 }; 62 63 -
branches/network/src/lib/network/synchronizeable.cc
r7631 r7678 174 174 if ( ( hasPermission && (*it)->getPriority() >= priorityTH ) || sizeIter == stateFrom->sizeList.end() ) 175 175 { 176 (*it)->debug();176 //(*it)->debug(); 177 177 n = (*it)->writeToBuf( stateTo->data+i, stateTo->dataLength - i ); 178 178 stateTo->sizeList.push_back( n ); … … 183 183 for ( int j = 0; j < (*it)->getSize(); j++ ) 184 184 { 185 //TODO this should be called!!!!!!!!!!1 185 186 assert(false); 186 187 stateTo->data[i] = 0; … … 310 311 else 311 312 { 312 PRINTF(0)("DONT SET VAR BECAUSE OF PERMISSION: %s %d %d %d %d %d %d\n", (*it)->getName().c_str(), (*it)->checkPermission( PERMISSION_SERVER ), (*it)->checkPermission( PERMISSION_OWNER ), (*it)->checkPermission( PERMISSION_ALL ), networkStream->isUserServer( userId ), this->owner, userId );313 // PRINTF(0)("DONT SET VAR BECAUSE OF PERMISSION: %s %d %d %d %d %d %d\n", (*it)->getName().c_str(), (*it)->checkPermission( PERMISSION_SERVER ), (*it)->checkPermission( PERMISSION_OWNER ), (*it)->checkPermission( PERMISSION_ALL ), networkStream->isUserServer( userId ), this->owner, userId ); 313 314 i += (*it)->getSizeFromBuf( stateTo->data + i, stateTo->dataLength - i ); 314 315 }
Note: See TracChangeset
for help on using the changeset viewer.