From c88249d3be3d98df6f267264f228984e877fca14 Mon Sep 17 00:00:00 2001 From: Christoph Wendt Date: Thu, 3 Sep 2015 23:22:04 -0700 Subject: [PATCH] Initialise channel with persistence and context --- Classes/BITChannel.h | 28 +++++++++++----------------- Classes/BITChannel.m | 9 +++++++++ 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Classes/BITChannel.h b/Classes/BITChannel.h index fc97be9f41..83f1722531 100644 --- a/Classes/BITChannel.h +++ b/Classes/BITChannel.h @@ -36,15 +36,15 @@ @class BITOrderedDictionary; @class BITConfiguration; @class BITTelemetryData; - +@class BITTelemetryContext; +@class BITPersistence; NS_ASSUME_NONNULL_BEGIN @interface BITChannel : NSObject -///----------------------------------------------------------------------------- -/// @name Queue management -///----------------------------------------------------------------------------- +@property (nonatomic, strong) BITTelemetryContext *telemetryContext; +@property (nonatomic, strong) BITPersistence *persistence; /** * A queue which makes array operations thread safe. */ @@ -55,6 +55,13 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, assign) NSUInteger dataItemCount; +/** + * A timer source which is used to flush the queue after a cretain time. + */ +@property (nonatomic, strong, null_unspecified) dispatch_source_t timerSource; + +- (instancetype)initWithTelemetryContext:(BITTelemetryContext *)telemetryContext persistence:(BITPersistence *) persistence; + /** * Enqueue telemetry data (events, metrics, exceptions, traces) before processing it. * @@ -67,10 +74,6 @@ NS_ASSUME_NONNULL_BEGIN */ - (void)persistDataItemQueue; -///----------------------------------------------------------------------------- -/// @name JSON Stream -///----------------------------------------------------------------------------- - /** * Adds the specified dictionary to the JSON Stream string. * @@ -93,15 +96,6 @@ void bit_appendStringToSafeJsonStream(NSString *string, char *__nonnull*__nonnul */ void bit_resetSafeJsonStream(char *__nonnull*__nonnull jsonStream); -///----------------------------------------------------------------------------- -/// @name Batching -///----------------------------------------------------------------------------- - -/** - * A timer source which is used to flush the queue after a cretain time. - */ -@property (nonatomic, strong, null_unspecified) dispatch_source_t timerSource; - /** * Starts the timer. */ diff --git a/Classes/BITChannel.m b/Classes/BITChannel.m index eb1c5b4224..bdfadc5723 100644 --- a/Classes/BITChannel.m +++ b/Classes/BITChannel.m @@ -3,6 +3,7 @@ #if HOCKEYSDK_FEATURE_TELEMETRY #import "HockeySDK.h" +#import "BITTelemetryContext.h" #import "BITTelemetryData.h" #import "HockeySDKPrivate.h" @@ -28,6 +29,14 @@ static BITChannel *_sharedChannel = nil; return self; } +- (instancetype)initWithTelemetryContext:(BITTelemetryContext *)telemetryContext persistence:(BITPersistence *) persistence { + if(self = [self init]) { + _telemetryContext = telemetryContext; + _persistence = persistence; + } + return self; +} + #pragma mark - Queue management - (BOOL)isQueueBusy{