Use sending queue in websocket send failover to REST.

pull/1/head
Matthew Chen 7 years ago
parent 677b898bfc
commit 3f4cd15f5b

@ -989,21 +989,23 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
success:successHandler];
}
failure:^(NSInteger statusCode, NSData *_Nullable responseData, NSError *error) {
// Websockets can fail in different ways, so we don't decrement remainingAttempts for websocket failure.
// Instead we fall back to REST, which will decrement retries.
// e.g. after linking a new device, sync messages will fail until the websocket re-opens.
[self sendMessageToService:message
recipient:recipient
thread:thread
attempts:remainingAttemptsParam
useWebsocketIfAvailable:NO
success:successHandler
failure:failureHandler];
dispatch_async([OWSDispatch sendingQueue], ^{
DDLogDebug(
@"%@ in %s falling back to REST since first attempt failed.", self.logTag, __PRETTY_FUNCTION__);
// Websockets can fail in different ways, so we don't decrement remainingAttempts for websocket
// failure. Instead we fall back to REST, which will decrement retries. e.g. after linking a new
// device, sync messages will fail until the websocket re-opens.
[self sendMessageToService:message
recipient:recipient
thread:thread
attempts:remainingAttemptsParam
useWebsocketIfAvailable:NO
success:successHandler
failure:failureHandler];
});
}];
} else {
if (!useWebsocketIfAvailable && TSSocketManager.canMakeRequests) {
DDLogDebug(@"%@ in %s falling back to REST since first attempt failed.", self.logTag, __PRETTY_FUNCTION__);
}
[self.networkManager makeRequest:request
success:^(NSURLSessionDataTask *task, id responseObject) {
[self messageSendDidSucceed:message

Loading…
Cancel
Save