Skip to content

Commit

Permalink
RTN15f (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardopereira authored and tcard committed Apr 29, 2016
1 parent 1eabb38 commit bc22dae
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Source/ARTProtocolMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,27 @@ - (NSString *)description {
return description;
}

- (id)copyWithZone:(NSZone *)zone {
ARTProtocolMessage *pm = [[[self class] allocWithZone:zone] init];
pm.action = self.action;
pm.count = self.count;
pm.id = self.id;
pm.channel = self.channel;
pm.channelSerial = self.channelSerial;
pm.connectionId = self.connectionId;
pm.connectionKey = self.connectionKey;
pm.connectionSerial = self.connectionSerial;
pm.hasConnectionSerial = self.hasConnectionSerial;
pm.msgSerial = self.msgSerial;
pm.timestamp = self.timestamp;
pm.messages = self.messages;
pm.presence = self.presence;
pm.flags = self.flags;
pm.error = self.error;
pm.connectionDetails = self.connectionDetails;
return pm;
}

- (BOOL)mergeFrom:(ARTProtocolMessage *)other {
if (![other.channel isEqualToString:self.channel] || other.action != self.action) {
return NO;
Expand Down
1 change: 1 addition & 0 deletions Source/ARTRealtimeChannel+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ ART_ASSUME_NONNULL_BEGIN

- (void)sendQueuedMessages;
- (void)failQueuedMessages:(ARTStatus *)status;
- (void)sendMessage:(ARTProtocolMessage *)pm callback:(void (^)(ARTStatus *))cb;

- (void)setSuspended:(ARTStatus *)error;
- (void)setFailed:(ARTStatus *)error;
Expand Down
37 changes: 37 additions & 0 deletions Spec/RealtimeClientConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1981,6 +1981,43 @@ class RealtimeClientConnection: QuickSpec {

}

// RTN15f
it("ACK and NACK responses for published messages can only ever be received on the transport connection on which those messages were sent") {
let options = AblyTests.commonAppSetup()
options.disconnectedRetryTimeout = 0.5
let client = AblyTests.newRealtime(options)
defer { client.close() }
let channel = client.channels.get("test")

var resumed = false
waitUntil(timeout: testTimeout) { done in
client.connection.once(.Connected) { _ in
var sentQueuedMessage: ARTMessage?
channel.publish(nil, data: "message") { _ in
if resumed {
let transport = client.transport as! TestProxyTransport
expect(transport.protocolMessagesReceived.filter{ $0.action == .Ack }).to(haveCount(1))
let sentTransportMessage = transport.protocolMessagesSent.filter{ $0.action == .Message }.first!.messages![0]
expect(sentQueuedMessage).to(beIdenticalTo(sentTransportMessage))
done()
}
else {
fail("Shouldn't be called")
}
}
client.onDisconnected()
client.connection.once(.Connected) { _ in
resumed = true
channel.testSuite_injectIntoMethodBefore(#selector(channel.sendQueuedMessages)) {
channel.testSuite_getArgumentFrom(#selector(channel.sendMessage(_:callback:)), atIndex: 0) { arg0 in
sentQueuedMessage = (arg0 as? ARTProtocolMessage)?.messages?[0]
}
}
}
}
}
}

// RTN15g
it("when the connection resume has failed, all channels should be detached with an error reason") {
let options = AblyTests.commonAppSetup()
Expand Down

0 comments on commit bc22dae

Please sign in to comment.