SYIOS-40: Any HTTP request can fail due to rate-limiting on the server, and need to be retried.

SDK: Introduced MXHTTPOperation. It replaces NSOperation objects returned by all MXRestClient methods. MXHTTPOperation will help to manage request retries.
This commit is contained in:
manuroe 2015-02-17 10:54:09 +01:00
parent 21de5f2800
commit 736e2fe4e4
5 changed files with 7 additions and 6 deletions

View file

@ -16,6 +16,8 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "MatrixSDKHandler.h"
// Provide the download progress // Provide the download progress
// object: URL // object: URL
// userInfo: kMediaLoaderProgressRateKey : progress value nested in a NSNumber (range 0->1) // userInfo: kMediaLoaderProgressRateKey : progress value nested in a NSNumber (range 0->1)
@ -66,7 +68,7 @@ typedef void (^blockMediaLoader_onError)(NSError *error);
NSString *uploadId; NSString *uploadId;
CGFloat initialRange; CGFloat initialRange;
CGFloat range; CGFloat range;
NSOperation* operation; MXHTTPOperation* operation;
} }
@property (strong, readonly) NSMutableDictionary* statisticsDict; @property (strong, readonly) NSMutableDictionary* statisticsDict;

View file

@ -15,7 +15,6 @@
*/ */
#import "MediaManager.h" #import "MediaManager.h"
#import "MatrixSDKHandler.h"
#import "MXCTools.h" #import "MXCTools.h"
NSString *const kMediaDownloadProgressNotification = @"kMediaDownloadProgressNotification"; NSString *const kMediaDownloadProgressNotification = @"kMediaDownloadProgressNotification";
@ -45,7 +44,7 @@ NSString *const kMediaLoaderProgressDownloadRateKey = @"kMediaLoaderProgressDown
downloadData = nil; downloadData = nil;
} }
else { else {
if (operation.executing) { if (operation.operation.executing) {
NSLog(@"media upload has been cancelled (%@)", mediaURL); NSLog(@"media upload has been cancelled (%@)", mediaURL);
[operation cancel]; [operation cancel];
operation = nil; operation = nil;

View file

@ -22,7 +22,7 @@ NSString *const kRecentRoomUpdatedByBackPagination = @"kRecentRoomUpdatedByBackP
@interface RecentRoom() { @interface RecentRoom() {
MXRoom *mxRoom; MXRoom *mxRoom;
id backPaginationListener; id backPaginationListener;
NSOperation *backPaginationOperation; MXHTTPOperation *backPaginationOperation;
// Keep reference on last event (used in case of redaction) // Keep reference on last event (used in case of redaction)
MXEvent *lastEvent; MXEvent *lastEvent;

View file

@ -22,7 +22,7 @@
@interface AuthenticationViewController () { @interface AuthenticationViewController () {
// Current request in progress // Current request in progress
NSOperation *mxAuthFlowRequest; MXHTTPOperation *mxAuthFlowRequest;
// Array of flows supported by the home server and implemented by the app (for the current auth type) // Array of flows supported by the home server and implemented by the app (for the current auth type)
NSMutableArray *supportedFlows; NSMutableArray *supportedFlows;

View file

@ -80,7 +80,7 @@ NSString *const kCmdResetUserPowerLevel = @"/deop";
BOOL isFirstPagination; BOOL isFirstPagination;
NSUInteger backPaginationAddedMsgNb; NSUInteger backPaginationAddedMsgNb;
NSUInteger backPaginationHandledEventsNb; NSUInteger backPaginationHandledEventsNb;
NSOperation *backPaginationOperation; MXHTTPOperation *backPaginationOperation;
CGFloat backPaginationSavedFirstMsgHeight; CGFloat backPaginationSavedFirstMsgHeight;
// Members list // Members list