From 2bcb4d8e5385b787850d92f0e818e2293a0a70d2 Mon Sep 17 00:00:00 2001 From: Christoph Wendt Date: Thu, 10 Sep 2015 18:53:44 -0700 Subject: [PATCH] Add properties/methods to sender header (testing) --- Classes/BITSender.h | 47 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/Classes/BITSender.h b/Classes/BITSender.h index 2a333f396b..0475eb150c 100644 --- a/Classes/BITSender.h +++ b/Classes/BITSender.h @@ -7,6 +7,7 @@ @class BITPersistence; NS_ASSUME_NONNULL_BEGIN + /** * Utility class that's responsible for sending a bundle of data to the server */ @@ -25,16 +26,16 @@ NS_ASSUME_NONNULL_BEGIN */ - (instancetype)initWithPersistence:(BITPersistence *)persistence serverURL:(NSURL *)serverURL; -/** - * Access to the internal operation queue - */ -@property (nonatomic, strong) NSOperationQueue *operationQueue; - /** * A queue which is used to handle BITHTTPOperation completion blocks. */ @property (nonatomic, strong) dispatch_queue_t senderQueue; +/** + * A queue for processing http operations (iOS < 7) + */ +@property (nonatomic, strong) NSOperationQueue *operationQueue; + /** * The endpoint url of the telemetry server. */ @@ -65,19 +66,49 @@ NS_ASSUME_NONNULL_BEGIN ///----------------------------------------------------------------------------- /** - * Triggers sending the saved data. Does nothing if nothing has been persisted, yet. This method should be called by BITTelemetryManager on app start. + * Creates a request for the given data and forwards that in order to send it out. + * + * @param data the telemetry data which should be sent + * @param path a reference of path to the file which should be sent (needed to delete it after sending) + */ +- (void)sendData:(NSData * __nonnull)data withPath:(NSString * __nonnull)path; + +/** + * Triggers sending the saved data on a background thread. Does nothing if nothing has been persisted, yet. This method should be called by BITTelemetryManager on app start. + */ +- (void)sendSavedDataAsync; + +/** + * Triggers sending the saved data. */ - (void)sendSavedData; /** - * Creates a HTTP operation and puts it to the queue. + * Creates a HTTP operation/session task and puts it to the queue. * * @param request a request for sending a data object to the telemetry server * @param path path to the file which should be sent - * @param urlSessionSupported a flag which determines whether to use NSURLConnection or NSURLSession for sending out data + * @param isUrlSessionSupported a flag which determines whether to use NSURLConnection or NSURLSession for sending out data */ - (void)sendRequest:(NSURLRequest * __nonnull)request path:(NSString * __nonnull)path urlSessionSupported:(BOOL)isUrlSessionSupported; +/** + * Resumes the given NSURLSessionDataTask instance. + * + * @param sessionDataTask the task which should be resumed + */ +- (void)resumeSessionDataTask:(NSURLSessionDataTask *)sessionDataTask; + +/** + * Deletes or unblocks sent file according to the given response code. + * + * @param statusCode the status code of the response + * @param responseCode the data of the response + * @param filePath the path of the file which content has been sent to the server + * @param error an error object sent from the server + */ +- (void)handleResponseWithStatusCode:(NSInteger)statusCode responseData:(NSData *)responseData filePath:(NSString *)filePath error:(NSError *)error; + ///----------------------------------------------------------------------------- /// @name Helper ///-----------------------------------------------------------------------------