Skip to content

Commit

Permalink
RTL6h (#425)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcard committed Apr 25, 2016
1 parent c0b25d9 commit 6c947f2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
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

0 comments on commit 6c947f2

Please sign in to comment.