nesium / cocoa-amf

Objective-C implementation of the Flash Remoting format (AMF0/AMF3) for servers and clients.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AMFRemotingCall isn't differenciating between onResult and onStatus results

schristmann opened this issue · comments

Your code has been extremely helpful and is implemented really well, however we had to customize it a bit to handle status errors differently and thought you should know.
Inside AMFRemotingCall connectionDidFinish is the following line of code

AMFActionMessage *message = [[AMFActionMessage alloc] initWithData:m_receivedData];
AMFMessageBody *body = [message.bodies objectAtIndex:0];
objc_msgSend(m_delegate, @selector(remotingCallDidFinishLoading:receivedObject:), self, data);
[message release];

This code indiscriminately returns the user whatever the body of the message is without providing the context of the message. A body can either be an onResult or onStatus message, both of these messages will be fully encoded amf packets, but on onStatus usually means that an exception has been encoded as the body instead of the usual expected result. this was the solution we used, but you may have a better thought on how to accomplish it.

AMFActionMessage *message = [[AMFActionMessage alloc] initWithData:m_receivedData];
AMFMessageBody *body = [message.bodies objectAtIndex:0];
NSObject *data = [[message.bodies objectAtIndex:0] data];
NSRange range = [body.targetURI rangeOfString:@"onStatus"];
if (range.location != NSNotFound) {
    objc_msgSend(m_delegate, @selector(remotingCallOnStatus:receivedObject:),  self, data);
}else {
    objc_msgSend(m_delegate, @selector(remotingCallOnResult:receivedObject:), self, data);
}
[message release];

Sean