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

Fix: connection resume does not fire channel detached #539

Merged
merged 9 commits into from
Nov 24, 2016
5 changes: 4 additions & 1 deletion Source/ARTRealtime.m
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ - (void)onConnected:(ARTProtocolMessage *)message {

// Resuming
if (_resuming) {
if (message.error && ![message.connectionId isEqualToString:self.connection.id]) {
if (![message.connectionId isEqualToString:self.connection.id]) {
[self.logger warn:@"R:%p ARTRealtime: connection has reconnected, but resume failed. Detaching all channels", self];
// Fatal error, detach all channels
for (ARTRealtimeChannel *channel in self.channels) {
Expand Down Expand Up @@ -449,6 +449,7 @@ - (void)onConnected:(ARTProtocolMessage *)message {
case ARTRealtimeConnected:
// Renewing token.
[self transitionSideEffects:[[ARTConnectionStateChange alloc] initWithCurrent:ARTRealtimeConnected previous:ARTRealtimeConnected reason:nil]];
[self transition:ARTRealtimeConnected withErrorInfo:message.error];
default:
break;
}
Expand All @@ -466,6 +467,8 @@ - (void)onDisconnected:(ARTProtocolMessage *)message {
}
if (!_renewingToken && error && error.statusCode == 401 && error.code >= 40140 && error.code < 40150 && [self isTokenRenewable]) {
[self connectWithRenewedToken];
[self transition:ARTRealtimeDisconnected withErrorInfo:error];
[self.connection setErrorReason:nil];
return;
}
[self transition:ARTRealtimeDisconnected withErrorInfo:error];
Expand Down
8 changes: 7 additions & 1 deletion Source/ARTRealtimeChannel.m
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,13 @@ - (void)setAttached:(ARTProtocolMessage *)message {

[self sendQueuedMessages];

[self transition:ARTRealtimeChannelAttached status:[ARTStatus state:ARTStateOk]];
if (message.error) {
_errorReason = message.error;
[self transition:ARTRealtimeChannelAttached status:[ARTStatus state:ARTStateError info:message.error]];
}
else {
[self transition:ARTRealtimeChannelAttached status:[ARTStatus state:ARTStateOk]];
}
[_attachedEventEmitter emit:[NSNull null] with:nil];
}

Expand Down
Loading