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

RTN15f #438

Merged
merged 4 commits into from
Apr 29, 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
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