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

Fix attach callbacks, and add to RealtimeChannel.subscribe. #232

Merged
merged 2 commits into from Feb 22, 2016

Conversation

tcard
Copy link
Contributor

@tcard tcard commented Feb 19, 2016

Had to fix channel attach first. You can more easily review first one commit and then the other.

Fixes #220.

waitUntil(timeout: testTimeout) { done in
expect(channel.state).to(equal(ARTRealtimeChannelState.Initialised))

channel.subscribeWithAttachCallback({ errorInfo in
Copy link
Member

Choose a reason for hiding this comment

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

Does this method need to be overloaded given we've "preferred" to stick with the overloaded IDL?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's already a subscribe:cb: method that takes a message name in its first parameter. Objective-C doesn't let you overload only by type, you need to either have different number of params, different names for them, or just take any type (id, the equivalent to Java's Object) and downcast it manually, which we don't do anywhere else and is strongly anti-idiomatic.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, @tcard is right. Swift conversion could be better with this. 😞 It should be imported by Swift like the initialisers where if the method takes an argument, the With is removed and the rest of the selector is divided up into named parameters accordingly.

Copy link
Member

Choose a reason for hiding this comment

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

OK

@mattheworiordan
Copy link
Member

This PR looks good, but should we not also have a scenario for calling attach when failed, or calling attach when channel becomes failed, or calling detach when failed, or calling detach when becomes failed to ensure the callback is called with an error in those cases?

@tcard
Copy link
Contributor Author

tcard commented Feb 19, 2016

@mattheworiordan That's already done for attach, see https://github.com/ably/ably-ios/blob/subscribe-cb/ablySpec/RealtimeClientChannel.swift#L257 onwards. For detach it's still pending, I guess because it's not in the prioritization list.

@mattheworiordan
Copy link
Member

@mattheworiordan That's already done for attach, see https://github.com/ably/ably-ios/blob/subscribe-cb/ablySpec/RealtimeClientChannel.swift#L257

Nope, that is different. A channel can be FAILED or become FAILED because of a permissions issue, whereas that test is for a connection state issue blocking the attach

For detach it's still pending, I guess because it's not in the prioritization list.

Ok, well perhaps we should defer to later. I thought it would be easy enough to add given you simply need to copy & paste the current test and cause the channel to fail, using permissions is the easiest way

@tcard
Copy link
Contributor Author

tcard commented Feb 19, 2016

@ricardopereira Could you take a look at this? It's blocking a couple of other changes.

@ricardopereira
Copy link
Contributor

LGTM

The callback was being subscribed to the message's ACK, while for
ATTACH and DETACH there's no ACK. Instead, an {AT,DE}TACHED
message is received. I've moved the callback call there, using
EventEmitter.

There was only a test for the attach timeout, which did work for
the subtle behavior that channel transitioning always cancels the
timeout. I've added tests for the happy paths as well.
tcard added a commit that referenced this pull request Feb 22, 2016
Fix attach callbacks, and add to RealtimeChannel.subscribe.
@tcard tcard merged commit b642c20 into master Feb 22, 2016
@tcard tcard deleted the subscribe-cb branch February 22, 2016 11:16
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.

None yet

3 participants