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

RTL6h #425

Merged
merged 1 commit into from
Apr 25, 2016
Merged

RTL6h #425

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
16 changes: 6 additions & 10 deletions Source/ARTRealtimeChannel.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,16 @@ - (ARTRealtimePresence *)getPresence {
return _realtimePresence;
}

- (void)publish:(NSString *)name data:(id)data callback:(void (^)(ARTErrorInfo * _Nullable))cb {
NSArray *messages = [NSArray arrayWithObject:[[ARTMessage alloc] initWithName:name data:data]];
[self publish:messages callback:cb];
}

-(void)publish:(NSArray<ARTMessage *> *)messages callback:(void (^)(ARTErrorInfo * _Nullable))cb {
- (void)internalPostMessages:(id)data callback:(void (^)(ARTErrorInfo *__art_nullable error))callback {
ARTProtocolMessage *msg = [[ARTProtocolMessage alloc] init];
msg.action = ARTProtocolMessageMessage;
msg.channel = self.name;
msg.messages = [messages artMap:^id(ARTMessage *message) {
return [self encodeMessageIfNeeded:message];
}];
if (![data isKindOfClass:[NSArray class]]) {
data = @[data];
}
msg.messages = data;
[self publishProtocolMessage:msg callback:^void(ARTStatus *status) {
if (cb) cb(status.errorInfo);
if (callback) callback(status.errorInfo);
}];
}

Expand Down
21 changes: 21 additions & 0 deletions Spec/RealtimeClientChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,27 @@ class RealtimeClientChannel: QuickSpec {

}

// RTL6h
it("should provide an optional argument that allows the clientId value to be specified") {
let client = ARTRealtime(options: AblyTests.commonAppSetup())
defer { client.close() }
let channel = client.channels.get("test")

waitUntil(timeout: testTimeout) { done in
channel.subscribe { message in
expect(message.name).to(equal("event"))
expect(message.data as? NSObject).to(equal("data"))
expect(message.clientId).to(equal("foo"))
done()
}

channel.publish("event", data: "data", clientId: "foo") { errorInfo in
expect(errorInfo).to(beNil())
}
}
}


}

// RTL7
Expand Down