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

When setting realtime channel options, pass through to REST channel #1266

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Source/ARTRealtimeChannel.m
Original file line number Diff line number Diff line change
Expand Up @@ -1235,6 +1235,7 @@ - (void)setOptions:(ARTRealtimeChannelOptions *_Nullable)options callback:(nulla

- (void)setOptions_nosync:(ARTRealtimeChannelOptions *_Nullable)options callback:(nullable ARTCallback)callback {
[self setOptions_nosync:options];
[self.restChannel setOptions_nosync:options];

if (!options.modes && !options.params) {
if (callback)
Expand Down
2 changes: 1 addition & 1 deletion Spec/Test Utilities/NSObject+TestSuite.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ @implementation NSObject (TestSuite)
return [self aspect_hookSelector:selector withOptions:AspectPositionAfter usingBlock:^(id<AspectInfo> info) {
__autoreleasing id arg;
[[info originalInvocation] getArgument:&arg atIndex:2+index];
callback([arg copy]);
callback(arg);
QuintinWillison marked this conversation as resolved.
Show resolved Hide resolved
} error:nil];
}

Expand Down
33 changes: 33 additions & 0 deletions Spec/Tests/RealtimeClientChannelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4188,6 +4188,39 @@ class RealtimeClientChannelTests: XCTestCase {
expect(lastAttach.flags & subscribeFlag).to(equal(subscribeFlag))
expect(lastAttach.params).to(equal(channelOptions.params))
}

func test__Channel_options__setOptions__shouldUpdateOptionsOfRestChannel() {
let client = AblyTests.newRealtime(AblyTests.commonAppSetup())
defer { client.dispose(); client.close() }
let channel = client.channels.get("foo")

waitUntil(timeout: testTimeout) { done in
client.connection.once(.connected) { _ in
done()
}
}

var restChannelSetOptions: ARTChannelOptions?
let token = channel.internal.restChannel.testSuite_getArgument(from: #selector(ARTRestChannelInternal.setOptions_nosync(_:)), at: 0) { arg in
guard let optionsArg = arg as? ARTChannelOptions else {
XCTFail("Expected setOptions: to have been called with an ARTChannelOptions instance")
return
}
restChannelSetOptions = optionsArg
}
defer { token.remove() }

let channelOptions = ARTRealtimeChannelOptions(cipherKey: ARTCrypto.generateRandomKey() as NSData)

waitUntil(timeout: testTimeout) { done in
channel.setOptions(channelOptions) { error in
XCTAssertNil(error)
done()
}
}

expect(restChannelSetOptions).to(beIdenticalTo(channelOptions))
}

// RTL17
func test__122__Channel__history__should_not_emit_messages_to_subscribers_if_the_channel_is_in_any_state_other_than_ATTACHED() {
Expand Down