Bug in PublicMessageRequest validation
Posted: 26 Oct 2011, 14:17
line 57 in GenericMessageRequest.m
-(void)validatePublicMessage:(SmartFoxiPhoneClient *)sfs errors:(NSMutableArray *)errors {
if(_message == nil || [_message length] == 0) {
[errors addObject:@"Public message is empty!"];
}
if (_room != nil && ![sfs.mySelf isJoinedInRoom:_room]) {
[errors addObject:[NSString stringWithFormat:@"You are not joined in the target Room: %@", _room]];
}
}
[/code]
in some circumstances
shows the client not joined, while the server has it right and ROOM isJoined property is also correct, every other message will go out just fine. Replacing this check with
]
fixes the problem and it is much faster, as it checks single boolean value vs going through isJoinedInRoom , which involves search in array.[/code]
-(void)validatePublicMessage:(SmartFoxiPhoneClient *)sfs errors:(NSMutableArray *)errors {
if(_message == nil || [_message length] == 0) {
[errors addObject:@"Public message is empty!"];
}
if (_room != nil && ![sfs.mySelf isJoinedInRoom:_room]) {
[errors addObject:[NSString stringWithFormat:@"You are not joined in the target Room: %@", _room]];
}
}
[/code]
in some circumstances
Code: Select all
[sfs.mySelf isJoinedInRoom:_room]
Code: Select all
[_room isJoined]
fixes the problem and it is much faster, as it checks single boolean value vs going through isJoinedInRoom , which involves search in array.[/code]