Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AMFRemotingCall isn't differenciating between onResult and onStatus results #7

Open
schristmann opened this issue Aug 18, 2010 · 0 comments

Comments

@schristmann
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant