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

Loading…
Cancel
Save