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

RTL10a #229

Merged
merged 4 commits into from
Feb 18, 2016
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
6 changes: 2 additions & 4 deletions ably-ios/ARTChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ ART_ASSUME_NONNULL_BEGIN
- (void)publish:(__GENERIC(NSArray, ARTMessage *) *)messages;
- (void)publish:(__GENERIC(NSArray, ARTMessage *) *)messages cb:(art_nullable void (^)(ARTErrorInfo *__art_nullable error))callback;

- (NSError *__art_nullable)history:(void(^)(__GENERIC(ARTPaginatedResult, ARTMessage *) *__art_nullable result, NSError *__art_nullable error))callback;
- (NSError *__art_nullable)history:(art_nullable ARTDataQuery *)query callback:(void(^)(__GENERIC(ARTPaginatedResult, ARTMessage *) *__art_nullable result, NSError *__art_nullable error))callback;
- (BOOL)historyWithError:(NSError *__art_nullable *__art_nullable)errorPtr callback:(void(^)(__GENERIC(ARTPaginatedResult, ARTMessage *) *__art_nullable result, NSError *__art_nullable error))callback;
- (BOOL)history:(art_nullable ARTDataQuery *)query error:(NSError *__art_nullable *__art_nullable)errorPtr callback:(void(^)(__GENERIC(ARTPaginatedResult, ARTMessage *) *__art_nullable result, NSError *__art_nullable error))callback;
- (BOOL)history:(void(^)(__GENERIC(ARTPaginatedResult, ARTMessage *) *__art_nullable result, NSError *__art_nullable error))callback error:(NSError *__art_nullable *__art_nullable)errorPtr;
- (BOOL)history:(art_nullable ARTDataQuery *)query callback:(void(^)(__GENERIC(ARTPaginatedResult, ARTMessage *) *__art_nullable result, NSError *__art_nullable error))callback error:(NSError *__art_nullable *__art_nullable)errorPtr;

@end

Expand Down
18 changes: 3 additions & 15 deletions ably-ios/ARTChannel.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,11 @@ - (ARTMessage *)encodeMessageIfNeeded:(ARTMessage *)message {
return message;
}

- (NSError *)history:(void (^)(ARTPaginatedResult<ARTMessage *> * _Nullable, NSError * _Nullable))callback {
NSError *error = nil;
[self historyWithError:&error callback:callback];
return error;
}

- (NSError *)history:(ARTDataQuery *)query callback:(void (^)(ARTPaginatedResult<ARTMessage *> * _Nullable, NSError * _Nullable))callback {
NSError *error = nil;
[self history:query error:&error callback:callback];
return error;
}

- (BOOL)historyWithError:(NSError *__autoreleasing _Nullable *)errorPtr callback:(void (^)(ARTPaginatedResult<ARTMessage *> * _Nullable, NSError * _Nullable))callback {
return [self history:[[ARTDataQuery alloc] init] error:errorPtr callback:callback];
- (BOOL)history:(void (^)(__GENERIC(ARTPaginatedResult, ARTMessage *) *, NSError *))callback error:(NSError **)errorPtr {
return [self history:[[ARTDataQuery alloc] init] callback:callback error:errorPtr];
}

- (BOOL)history:(ARTDataQuery *)query error:(NSError **)errorPtr callback:(void (^)(__GENERIC(ARTPaginatedResult, ARTMessage *) *, NSError *))callback {
- (BOOL)history:(ARTDataQuery *)query callback:(void (^)(__GENERIC(ARTPaginatedResult, ARTMessage *) *, NSError *))callback error:(NSError **)errorPtr {
NSAssert(false, @"-[%@ %@] should always be overriden.", self.class, NSStringFromSelector(_cmd));
return NO;
}
Expand Down
6 changes: 2 additions & 4 deletions ably-ios/ARTRealtimeChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ ART_ASSUME_NONNULL_BEGIN
- (void)unsubscribe:(__GENERIC(ARTEventListener, ARTMessage *) *)listener;
- (void)unsubscribe:(NSString *)name listener:(__GENERIC(ARTEventListener, ARTMessage *) *)listener;

- (NSError *__art_nullable)history:(void(^)(__GENERIC(ARTPaginatedResult, ARTMessage *) *__art_nullable result, NSError *__art_nullable error))callback;
- (NSError *__art_nullable)history:(art_nullable ARTRealtimeHistoryQuery *)query callback:(void(^)(__GENERIC(ARTPaginatedResult, ARTMessage *) *__art_nullable result, NSError *__art_nullable error))callback;
- (BOOL)historyWithError:(NSError *__art_nullable *__art_nullable)errorPtr callback:(void(^)(__GENERIC(ARTPaginatedResult, ARTMessage *) *__art_nullable result, NSError *__art_nullable error))callback;
- (BOOL)history:(art_nullable ARTRealtimeHistoryQuery *)query error:(NSError *__art_nullable *__art_nullable)errorPtr callback:(void(^)(__GENERIC(ARTPaginatedResult, ARTMessage *) *__art_nullable result, NSError *__art_nullable error))callback;
- (BOOL)history:(void(^)(__GENERIC(ARTPaginatedResult, ARTMessage *) *__art_nullable result, NSError *__art_nullable error))callback error:(NSError *__art_nullable *__art_nullable)errorPtr;
- (BOOL)history:(art_nullable ARTRealtimeHistoryQuery *)query callback:(void(^)(__GENERIC(ARTPaginatedResult, ARTMessage *) *__art_nullable result, NSError *__art_nullable error))callback error:(NSError *__art_nullable *__art_nullable)errorPtr;

ART_EMBED_INTERFACE_EVENT_EMITTER(ARTRealtimeChannelState, ARTErrorInfo *)

Expand Down
20 changes: 4 additions & 16 deletions ably-ios/ARTRealtimeChannel.m
Original file line number Diff line number Diff line change
Expand Up @@ -495,24 +495,12 @@ - (NSString *)getClientId {
return self.realtime.auth.clientId;
}

- (NSError *)history:(void (^)(ARTPaginatedResult<ARTMessage *> * _Nullable, NSError * _Nullable))callback {
NSError *error = nil;
[self historyWithError:&error callback:callback];
return error;
- (BOOL)history:(void (^)(__GENERIC(ARTPaginatedResult, ARTMessage *) *, NSError *))callback error:(NSError **)errorPtr {
return [self history:[[ARTRealtimeHistoryQuery alloc] init] callback:callback error:errorPtr];
}

- (NSError *)history:(ARTRealtimeHistoryQuery *)query callback:(void (^)(ARTPaginatedResult<ARTMessage *> * _Nullable, NSError * _Nullable))callback {
NSError *error = nil;
[self history:query error:&error callback:callback];
return error;
}

- (BOOL)historyWithError:(NSError *__autoreleasing _Nullable *)errorPtr callback:(void (^)(ARTPaginatedResult<ARTMessage *> * _Nullable, NSError * _Nullable))callback {
return [self history:[[ARTRealtimeHistoryQuery alloc] init] error:errorPtr callback:callback];
}

- (BOOL)history:(ARTRealtimeHistoryQuery *)query error:(NSError *__autoreleasing _Nullable *)errorPtr callback:(void (^)(ARTPaginatedResult<ARTMessage *> * _Nullable, NSError * _Nullable))callback {
return [super history:query error:errorPtr callback:callback];
- (BOOL)history:(ARTRealtimeHistoryQuery *)query callback:(void (^)(__GENERIC(ARTPaginatedResult, ARTMessage *) *, NSError *))callback error:(NSError **)errorPtr {
return [super history:query callback:callback error:errorPtr];
}

@end
2 changes: 1 addition & 1 deletion ably-ios/ARTRestChannel.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ - (ARTRestPresence *)getPresence {
return _restPresence;
}

- (BOOL)history:(ARTDataQuery *)query error:(NSError **)errorPtr callback:(void(^)(__GENERIC(ARTPaginatedResult, ARTMessage *) *result, NSError *error))callback {
- (BOOL)history:(ARTDataQuery *)query callback:(void(^)(__GENERIC(ARTPaginatedResult, ARTMessage *) *result, NSError *error))callback error:(NSError **)errorPtr {
if (query.limit > 1000) {
if (errorPtr) {
*errorPtr = [NSError errorWithDomain:ARTAblyErrorDomain
Expand Down
6 changes: 3 additions & 3 deletions ably-iosTests/ARTReadmeExamples.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ - (void)testSubscribeAndPublishingToChannel {

[channel history:^(ARTPaginatedResult<ARTMessage *> *messagesPage, NSError *error) {
NSLog(@"%@", messagesPage.items);
}];
} error:nil];
}];
}

Expand All @@ -89,7 +89,7 @@ - (void) testQueryingTheHistory {
// retrieved the next page in nextPage
}];
NSLog(@"%d", messagesPage.hasNext); // true, there are more pages
}];
} error:nil];
}];
}

Expand Down Expand Up @@ -150,7 +150,7 @@ - (void)testRestQueryingTheHistory {
// retrieved the next page in nextPage
}];
NSLog(@"%d", messagesPage.hasNext); // true, there are more pages
}];
} error:nil];
}];
}

Expand Down
36 changes: 18 additions & 18 deletions ably-iosTests/ARTRealtimeChannelHistoryTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ - (void)testHistory {
XCTAssertNil(errorInfo);
[channel publish:nil data:@"testString2" cb:^(ARTErrorInfo *errorInfo) {
XCTAssertNil(errorInfo);
[channel history:[[ARTRealtimeHistoryQuery alloc] init] error:nil callback:^(ARTPaginatedResult *result, NSError *error) {
[channel history:^(ARTPaginatedResult *result, NSError *error) {
XCTAssert(!error);
NSArray *messages = [result items];
XCTAssertEqual(2, messages.count);
Expand All @@ -64,7 +64,7 @@ - (void)testHistory {
XCTAssertEqualObjects(@"testString", [m1 data]);

[expectation fulfill];
}];
} error:nil];
}];
}];
}
Expand Down Expand Up @@ -115,7 +115,7 @@ - (void) testHistoryBothChannels {
XCTAssertNil(errorInfo);
[channel2 publish:nil data:@"testString2" cb:^(ARTErrorInfo *errorInfo) {
XCTAssertNil(errorInfo);
[channel1 history:[[ARTRealtimeHistoryQuery alloc] init] error:nil callback:^(ARTPaginatedResult *result, NSError *error) {
[channel1 history:^(ARTPaginatedResult *result, NSError *error) {
XCTAssert(!error);
NSArray *messages = [result items];
XCTAssertEqual(2, messages.count);
Expand All @@ -125,8 +125,8 @@ - (void) testHistoryBothChannels {
XCTAssertEqualObjects(@"testString", [m1 data]);
[expectation1 fulfill];

}];
[channel2 history:[[ARTRealtimeHistoryQuery alloc] init] error:nil callback:^(ARTPaginatedResult *result, NSError *error) {
} error:nil];
[channel2 history:^(ARTPaginatedResult *result, NSError *error) {
XCTAssert(!error);
NSArray *messages = [result items];
XCTAssertEqual(2, messages.count);
Expand All @@ -135,7 +135,7 @@ - (void) testHistoryBothChannels {
XCTAssertEqualObjects(@"testString2", [m0 data]);
XCTAssertEqualObjects(@"testString", [m1 data]);
[expectation2 fulfill];
}];
} error:nil];
}];
}];
}];
Expand All @@ -154,7 +154,7 @@ - (void)testHistoryForward {
XCTAssertNil(errorInfo);
ARTRealtimeHistoryQuery* query = [[ARTRealtimeHistoryQuery alloc] init];
query.direction = ARTQueryDirectionForwards;
[channel history:query error:nil callback:^(ARTPaginatedResult *result, NSError *error) {
[channel history:query callback:^(ARTPaginatedResult *result, NSError *error) {
XCTAssert(!error);
NSArray *messages = [result items];
XCTAssertEqual(2, messages.count);
Expand All @@ -164,7 +164,7 @@ - (void)testHistoryForward {
XCTAssertEqualObjects(@"testString2", [m1 data]);

[expectation fulfill];
}];
} error:nil];
}];
}];
}];
Expand All @@ -184,7 +184,7 @@ -(void) testHistoryForwardPagination {
query.limit = 2;
query.direction = ARTQueryDirectionForwards;

[channel history:query error:nil callback:^(ARTPaginatedResult *result, NSError *error) {
[channel history:query callback:^(ARTPaginatedResult *result, NSError *error) {
XCTAssert(!error);
XCTAssertTrue([result hasNext]);
NSArray * items = [result items];
Expand Down Expand Up @@ -222,7 +222,7 @@ -(void) testHistoryForwardPagination {
}];
}];
}];
}];
} error:nil];
}];
}];

Expand All @@ -241,7 +241,7 @@ -(void) testHistoryBackwardPagination {
query.limit = 2;
query.direction = ARTQueryDirectionBackwards;

[channel history:query error:nil callback:^(ARTPaginatedResult *result, NSError *error) {
[channel history:query callback:^(ARTPaginatedResult *result, NSError *error) {
XCTAssert(!error);
XCTAssertTrue([result hasNext]);
NSArray * items = [result items];
Expand Down Expand Up @@ -290,7 +290,7 @@ -(void) testHistoryBackwardPagination {
}];
}];
}];
}];
} error:nil];
}];
}];
[self waitForExpectationsWithTimeout:[ARTTestUtil timeout] handler:nil];
Expand Down Expand Up @@ -348,7 +348,7 @@ - (void)testTimeBackwards {
query.end = [NSDate dateWithTimeIntervalSince1970:intervalEnd/1000];
query.direction = ARTQueryDirectionBackwards;

[channel history:query error:nil callback:^(ARTPaginatedResult *result, NSError *error) {
[channel history:query callback:^(ARTPaginatedResult *result, NSError *error) {
XCTAssert(!error);
XCTAssertFalse([result hasNext]);
NSArray *items = [result items];
Expand All @@ -361,7 +361,7 @@ - (void)testTimeBackwards {
XCTAssertEqualObjects(goalStr, [m data]);
}
[expectation fulfill];
}];
} error:nil];
}];
}];
}];
Expand Down Expand Up @@ -421,7 +421,7 @@ - (void)testTimeForwards {
query.end = [NSDate dateWithTimeIntervalSince1970:intervalEnd/1000];
query.direction = ARTQueryDirectionForwards;

[channel history:query error:nil callback:^(ARTPaginatedResult *result, NSError *error) {
[channel history:query callback:^(ARTPaginatedResult *result, NSError *error) {
XCTAssert(!error);
XCTAssertFalse([result hasNext]);
NSArray * items = [result items];
Expand All @@ -435,7 +435,7 @@ - (void)testTimeForwards {
XCTAssertEqualObjects(goalStr, [m data]);
}
[expectation fulfill];
}];
} error:nil];
}];
}];
}];
Expand Down Expand Up @@ -476,7 +476,7 @@ - (void)testHistoryFromAttach {
ARTRealtimeHistoryQuery *query = [[ARTRealtimeHistoryQuery alloc] init];
query.direction = ARTQueryDirectionBackwards;

[channel2 history:query error:nil callback:^(ARTPaginatedResult *result, NSError *error) {
[channel2 history:query callback:^(ARTPaginatedResult *result, NSError *error) {
XCTAssert(!error);
XCTAssertFalse([result hasNext]);
NSArray * items = [result items];
Expand All @@ -488,7 +488,7 @@ - (void)testHistoryFromAttach {
XCTAssertEqualObjects(goalStr, [m data]);
}
[expecation fulfill];
}];
} error:nil];
}
}];
}
Expand Down
8 changes: 4 additions & 4 deletions ably-iosTests/ARTRealtimeCryptoTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ - (void)testSendEncodedMessage {
[channel publish:nil data:stringPayload cb:^(ARTErrorInfo *errorInfo) {
XCTAssertNil(errorInfo);
ARTRealtimeHistoryQuery *query = [[ARTRealtimeHistoryQuery alloc] init];
[channel history:query error:nil callback:^(ARTPaginatedResult *result, NSError *error) {
[channel history:query callback:^(ARTPaginatedResult *result, NSError *error) {
XCTAssert(!error);
XCTAssertFalse([result hasNext]);
NSArray *page = [result items];
Expand All @@ -73,7 +73,7 @@ - (void)testSendEncodedMessage {
XCTAssertEqualObjects([dataMessage data], dataPayload);
XCTAssertEqualObjects([stringMessage data], stringPayload);
[exp fulfill];
}];
} error:nil];
}];
}];
}];
Expand Down Expand Up @@ -102,7 +102,7 @@ - (void)testSendEncodedMessageOnExistingChannel {
XCTAssertNil(errorInfo);
[c publish:nil data:stringPayload cb:^(ARTErrorInfo *errorInfo) {
XCTAssertNil(errorInfo);
[c history:[[ARTRealtimeHistoryQuery alloc] init] error:nil callback:^(ARTPaginatedResult *result, NSError *error) {
[c history:^(ARTPaginatedResult *result, NSError *error) {
XCTAssert(!error);
XCTAssertFalse([result hasNext]);
NSArray * page = [result items];
Expand All @@ -115,7 +115,7 @@ - (void)testSendEncodedMessageOnExistingChannel {
XCTAssertEqualObjects([stringMessage data], stringPayload);
XCTAssertEqualObjects([firstMessage data], firstMessageText);
[exp fulfill];
}];
} error:nil];
}];
}];
}];
Expand Down
4 changes: 2 additions & 2 deletions ably-iosTests/ARTRealtimeMessageTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ - (void)testConnectionIdsInMessage {
ARTRealtimeChannel *c2 = [_realtime2.channels get:channelName];
[c2 publish:nil data:@"message2" cb:^(ARTErrorInfo *errorInfo) {
XCTAssertNil(errorInfo);
[c1 history:[[ARTRealtimeHistoryQuery alloc] init] error:nil callback:^(ARTPaginatedResult *result, NSError *error) {
[c1 history:^(ARTPaginatedResult *result, NSError *error) {
XCTAssert(!error);
NSArray *messages = [result items];
XCTAssertEqual(2, messages.count);
Expand All @@ -315,7 +315,7 @@ - (void)testConnectionIdsInMessage {
XCTAssertEqualObjects(m1.connectionId, _realtime.connection.id);
XCTAssertFalse([m0.connectionId isEqualToString:m1.connectionId]);
[exp fulfill];
}];
} error:nil];
}];
}];
}];
Expand Down
Loading