Changeset 3542
- Timestamp:
- 01/07/07 14:17:32 (2 years ago)
- Files:
-
- trunk/Chat Core/MVDirectChatConnection.m (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Chat Core/MVDirectChatConnection.m
r3539 r3542 198 198 - (void) directClientConnection:(MVDirectClientConnection *) connection didReadData:(NSData *) data withTag:(long) tag { 199 199 const char *bytes = (const char *)[data bytes]; 200 BOOL ctcp = ( *bytes == '\001' && [data length] > 2 ); 200 unsigned int len = [data length]; 201 const char *end = bytes + len - 2; // minus the line endings 202 BOOL ctcp = ( *bytes == '\001' && [data length] > 3 ); // three is the one minimum line ending and two \001 chars 203 204 if( *end != '\x0D' ) 205 end = bytes + len - 1; // this client only uses \x0A for the message line ending, lets work with it 201 206 202 207 if( ctcp ) { 203 const char *line = bytes + 1; // skip the \001 char 204 unsigned int len = [data length]; 205 const char *end = bytes + len - 2; // minus the line endings 208 const char *line = bytes + 1; // skip the first \001 char 206 209 const char *current = line; 207 208 if( *end != '\x0D' )209 end = bytes + len - 1; // this client only uses \x0A for the message line ending, lets work with it210 210 211 211 if( *( end - 1 ) == '\001' ) … … 229 229 [arguments release]; 230 230 } else { 231 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVDirectChatConnectionGotMessageNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:data, @"message", [NSString locallyUniqueString], @"identifier", nil]]; 231 NSData *msg = [[NSData allocWithZone:nil] initWithBytes:bytes length:(end - bytes)]; 232 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVDirectChatConnectionGotMessageNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:msg, @"message", [NSString locallyUniqueString], @"identifier", nil]]; 233 [msg release]; 232 234 } 233 235
