From ee851696186a5f410f0029d43de25e5104abf22c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20Ca=CC=81rdenas?= Date: Mon, 25 Apr 2016 11:01:14 +0200 Subject: [PATCH] RTL6h --- Source/ARTRealtimeChannel.m | 16 ++++++---------- Spec/RealtimeClientChannel.swift | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/Source/ARTRealtimeChannel.m b/Source/ARTRealtimeChannel.m index 11d2dde90..371996d96 100644 --- a/Source/ARTRealtimeChannel.m +++ b/Source/ARTRealtimeChannel.m @@ -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 *)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); }]; } diff --git a/Spec/RealtimeClientChannel.swift b/Spec/RealtimeClientChannel.swift index d94245f98..b8480f884 100644 --- a/Spec/RealtimeClientChannel.swift +++ b/Spec/RealtimeClientChannel.swift @@ -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