Skip to content

Commit

Permalink
fixup! Fix RTN7c: notify publish callbacks of broken connection.
Browse files Browse the repository at this point in the history
  • Loading branch information
tcard committed Feb 23, 2016
1 parent 714c632 commit fb5ccdd
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions ably-ios/ARTRealtimeChannel.m
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,12 @@ - (void)publishProtocolMessage:(ARTProtocolMessage *)pm cb:(ARTStatusCallback)cb
- (void)sendMessage:(ARTProtocolMessage *)pm cb:(ARTStatusCallback)cb {
__block BOOL gotFailure = false;
NSString *oldConnectionId = self.realtime.connection.id;
__block ARTEventListener *listener = [self.realtime.connection on:^(ARTConnectionStateChange *stateChange) {
__block ARTEventListener *listener = [self.realtime.connection once:^(ARTConnectionStateChange *stateChange) {
if (!(stateChange.current == ARTRealtimeClosed || stateChange.current == ARTRealtimeFailed
|| (stateChange.current == ARTRealtimeConnected && ![oldConnectionId isEqual:self.realtime.connection.id] /* connection state lost */))) {
return;
}
gotFailure = true;
[self.realtime.connection off:listener];
if (!cb) return;
ARTErrorInfo *reason = stateChange.reason ? stateChange.reason : [ARTErrorInfo createWithCode:0 message:@"connection broken before receiving publishing acknowledgement."];
cb([ARTStatus state:ARTStateError info:reason]);
Expand Down

0 comments on commit fb5ccdd

Please sign in to comment.