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

RTL6a #193

Merged
merged 6 commits into from
Feb 9, 2016
Merged

RTL6a #193

merged 6 commits into from
Feb 9, 2016

Conversation

ricardopereira
Copy link
Contributor

No description provided.

@ricardopereira
Copy link
Contributor Author

I'm getting errors after the #171:

2016-02-04 18:50:15.161 xctest[85089:13705808] ERROR: ARTDataDecoded failed to decode data as 'json': (__NSCFDictionary){
    value = 1;
}
2016-02-04 18:50:15.162 xctest[85089:13705808] ERROR: ARTRealtimeChannel: error decoding data, status: 2038569904

@tcard Any thoughts?

@ricardopereira
Copy link
Contributor Author

I can debug it later.

@tcard
Copy link
Contributor

tcard commented Feb 4, 2016

@ricardopereira Seems like it's trying to decode a piece of JSON that is already decoded. The data of the incoming message should be a string, not a dictionary.

@ricardopereira
Copy link
Contributor Author

The test is publishing a dictionary. The existing RSL4d4 test is also failing:

2016-02-04 19:03:17.233 xctest[85570:13716774] ERROR: ARTDataDecoded failed to decode data as 'json': (__NSCFArray)(
    John,
    Mary
)
2016-02-04 19:03:17.233 xctest[85570:13716774] ERROR: ARTDataDecoded failed to decode data as 'json': (__NSCFDictionary){
    name = John;
    number = 3;
}

@tcard Should I open an issue?

@tcard
Copy link
Contributor

tcard commented Feb 4, 2016

@ricardopereira Please.


let restBlock: @convention(block) (AspectInfo, ARTMessage) -> Void = { info, message in
let invocation = info.originalInvocation()
invocation.invoke()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how this aspects thing works, but if message here is the original, unencoded message that is passed to encodeMessageIfNeeded, take into account that ARTMessage.encode returns a copy of the ARTMessage instance, and thus this message won't be mutated by invocation.invoke(), and you're assigning the unencoded version to restEncodedMessage.

Ignore this if this message is what's returned by encodeMessageIfNeeded. (But then I don't understand what invocation.invoke() is invoking.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

invocation.invoke() calls the original implementation, so the encodeWithEncoder will write to the current ARTMessage instance (look https://github.com/ably/ably-ios/blob/bff8f901b67e9ab12b38fa477470ed773ae0a902/ably-ios/ARTChannel.m#L54). Even so, I saw the documentation and I think it is possible to retrieve the original return value of the mehotd directly with the NSInvocation.getReturnValue. I think both approaches are correct. What you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That link shows how encodeWithEncoder takes an output argument, where it writes the new message, which is then a different instance than the message passed as argument to encodeMessageIfNeeded, ie. the message in this block. For this to be correct you need to use the returned message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you right, It is doing a copy of the message. I will try to use the NSInvocation.getReturnValue. Ty.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed 357c5db.

 - `testSuite_getReturnValueFrom`: Get each return value generated by
the identified method

Aspects lib allows you to add code to existing methods but it has some
limitations with Swift because the NSInvocation is unavailable:
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Fo
undation/Classes/NSInvocation_Class/
 - `data` is not a value object. It needs to be copied explicitly.
@mattheworiordan
Copy link
Member

Ok, looks good to me

@tcard
Copy link
Contributor

tcard commented Feb 9, 2016

LGTM

ricardopereira added a commit that referenced this pull request Feb 9, 2016
@ricardopereira ricardopereira merged commit 86834f2 into master Feb 9, 2016
@ricardopereira ricardopereira deleted the RTL6a branch February 9, 2016 14:38
maratal pushed a commit that referenced this pull request Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants