Skip to content

Commit

Permalink
Rename Timer to GCDTimer
Browse files Browse the repository at this point in the history
  • Loading branch information
jcavar committed Jan 2, 2018
1 parent 925e326 commit 6099723
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 97 deletions.
4 changes: 2 additions & 2 deletions MQTTClient.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Pod::Spec.new do |mqttc|
"MQTTClient/MQTTClient/MQTTSessionLegacy.{h,m}",
"MQTTClient/MQTTClient/MQTTSessionSynchron.{h,m}",
"MQTTClient/MQTTClient/MQTTTransport.{h,m}",
"MQTTClient/MQTTClient/Timer.{h,m}"
"MQTTClient/MQTTClient/GCDTimer.{h,m}"
end

mqttc.subspec 'MinL' do |minl|
Expand All @@ -70,7 +70,7 @@ Pod::Spec.new do |mqttc|
"MQTTClient/MQTTClient/MQTTSessionLegacy.{h,m}",
"MQTTClient/MQTTClient/MQTTSessionSynchron.{h,m}",
"MQTTClient/MQTTClient/MQTTTransport.{h,m}",
"MQTTClient/MQTTClient/Timer.{h,m}"
"MQTTClient/MQTTClient/GCDTimer.{h,m}"
minl.xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'LUMBERJACK=1' }
end

Expand Down
32 changes: 16 additions & 16 deletions MQTTClient/MQTTClient.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,9 @@
84E2C45C1EC34E9A00BC02CE /* MQTTProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = 84E2C4561EC34E8500BC02CE /* MQTTProperties.m */; };
84E2C45D1EC34E9B00BC02CE /* MQTTProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = 84E2C4561EC34E8500BC02CE /* MQTTProperties.m */; };
84FED2171C35515800741A77 /* MQTTClientSubscriptionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C21D3C6E1B1EBB0E0012DD2F /* MQTTClientSubscriptionTests.m */; };
C701E3381FB0A70600B0CEB5 /* Timer.h in Headers */ = {isa = PBXBuildFile; fileRef = C701E3361FB0A70600B0CEB5 /* Timer.h */; settings = {ATTRIBUTES = (Public, ); }; };
C701E3391FB0A70600B0CEB5 /* Timer.h in Headers */ = {isa = PBXBuildFile; fileRef = C701E3361FB0A70600B0CEB5 /* Timer.h */; settings = {ATTRIBUTES = (Public, ); }; };
C701E33A1FB0A70600B0CEB5 /* Timer.h in Headers */ = {isa = PBXBuildFile; fileRef = C701E3361FB0A70600B0CEB5 /* Timer.h */; settings = {ATTRIBUTES = (Public, ); }; };
C701E33B1FB0A70600B0CEB5 /* Timer.m in Sources */ = {isa = PBXBuildFile; fileRef = C701E3371FB0A70600B0CEB5 /* Timer.m */; };
C701E33C1FB0A70600B0CEB5 /* Timer.m in Sources */ = {isa = PBXBuildFile; fileRef = C701E3371FB0A70600B0CEB5 /* Timer.m */; };
C701E33D1FB0A70600B0CEB5 /* Timer.m in Sources */ = {isa = PBXBuildFile; fileRef = C701E3371FB0A70600B0CEB5 /* Timer.m */; };
C701E33B1FB0A70600B0CEB5 /* GCDTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = C701E3371FB0A70600B0CEB5 /* GCDTimer.m */; };
C701E33C1FB0A70600B0CEB5 /* GCDTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = C701E3371FB0A70600B0CEB5 /* GCDTimer.m */; };
C701E33D1FB0A70600B0CEB5 /* GCDTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = C701E3371FB0A70600B0CEB5 /* GCDTimer.m */; };
C7095E7C1FBDD1E900D73DD9 /* MQTTSSLSecurityPolicyTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C21D3C701B1EBD730012DD2F /* MQTTSSLSecurityPolicyTests.m */; };
C7095F221FBF329500D73DD9 /* alamofire-root-ca.cer in Resources */ = {isa = PBXBuildFile; fileRef = C7095F161FBF329500D73DD9 /* alamofire-root-ca.cer */; };
C7095F231FBF329500D73DD9 /* alamofire-root-ca.cer in Resources */ = {isa = PBXBuildFile; fileRef = C7095F161FBF329500D73DD9 /* alamofire-root-ca.cer */; };
Expand Down Expand Up @@ -149,6 +146,9 @@
C7515EC01F4C6A710071CFFE /* ForegroundReconnection.m in Sources */ = {isa = PBXBuildFile; fileRef = C7515EBC1F4C6A710071CFFE /* ForegroundReconnection.m */; };
C7515EC11F4C6A710071CFFE /* ForegroundReconnection.m in Sources */ = {isa = PBXBuildFile; fileRef = C7515EBC1F4C6A710071CFFE /* ForegroundReconnection.m */; };
C7515EC21F4C6A710071CFFE /* ForegroundReconnection.m in Sources */ = {isa = PBXBuildFile; fileRef = C7515EBC1F4C6A710071CFFE /* ForegroundReconnection.m */; };
C7A48D7A1FFB836600248055 /* GCDTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = C701E3361FB0A70600B0CEB5 /* GCDTimer.h */; };
C7A48D7B1FFB836600248055 /* GCDTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = C701E3361FB0A70600B0CEB5 /* GCDTimer.h */; };
C7A48D7C1FFB836700248055 /* GCDTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = C701E3361FB0A70600B0CEB5 /* GCDTimer.h */; };
C7AA17E31FB6F04800098AA9 /* MQTTTestHelpers.m in Sources */ = {isa = PBXBuildFile; fileRef = 84517CF31C182F06006FE09B /* MQTTTestHelpers.m */; };
C7AA17E41FB6F04F00098AA9 /* MQTTTestHelpers.plist in Resources */ = {isa = PBXBuildFile; fileRef = 84BE348F1C348BFD007EF8F3 /* MQTTTestHelpers.plist */; };
C7AA17F11FB6F07900098AA9 /* MQTTSessionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C74489951FA74D58002751B2 /* MQTTSessionTests.m */; };
Expand Down Expand Up @@ -375,8 +375,8 @@
C21D3C701B1EBD730012DD2F /* MQTTSSLSecurityPolicyTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MQTTSSLSecurityPolicyTests.m; sourceTree = "<group>"; };
C21D3CA71B1ED2F40012DD2F /* server.der */ = {isa = PBXFileReference; lastKnownFileType = file; path = server.der; sourceTree = "<group>"; };
C53615C962DC60ED0FD7E799 /* Pods-MQTTClientOSXTestsNOLumberjack.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MQTTClientOSXTestsNOLumberjack.debug.xcconfig"; path = "Pods/Target Support Files/Pods-MQTTClientOSXTestsNOLumberjack/Pods-MQTTClientOSXTestsNOLumberjack.debug.xcconfig"; sourceTree = "<group>"; };
C701E3361FB0A70600B0CEB5 /* Timer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Timer.h; sourceTree = "<group>"; };
C701E3371FB0A70600B0CEB5 /* Timer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Timer.m; sourceTree = "<group>"; };
C701E3361FB0A70600B0CEB5 /* GCDTimer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GCDTimer.h; sourceTree = "<group>"; };
C701E3371FB0A70600B0CEB5 /* GCDTimer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GCDTimer.m; sourceTree = "<group>"; };
C7095F161FBF329500D73DD9 /* alamofire-root-ca.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = "alamofire-root-ca.cer"; sourceTree = "<group>"; };
C7095F171FBF329500D73DD9 /* alamofire-signing-ca1.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = "alamofire-signing-ca1.cer"; sourceTree = "<group>"; };
C7095F181FBF329500D73DD9 /* alamofire-signing-ca2.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = "alamofire-signing-ca2.cer"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -626,8 +626,8 @@
840D3CEA1F264AD00072019B /* MQTTStrict.m */,
C7515E881F4B1BA80071CFFE /* SessionManager */,
846191301883E56800101409 /* Supporting Files */,
C701E3361FB0A70600B0CEB5 /* Timer.h */,
C701E3371FB0A70600B0CEB5 /* Timer.m */,
C701E3361FB0A70600B0CEB5 /* GCDTimer.h */,
C701E3371FB0A70600B0CEB5 /* GCDTimer.m */,
);
path = MQTTClient;
sourceTree = "<group>";
Expand Down Expand Up @@ -812,8 +812,8 @@
DE9EF5D71C062907009EF667 /* MQTTDecoder.h in Headers */,
DE9EF5D91C062907009EF667 /* MQTTMessage.h in Headers */,
DE9EF5DA1C062907009EF667 /* MQTTSession.h in Headers */,
C7A48D7A1FFB836600248055 /* GCDTimer.h in Headers */,
845922A81C175AA400CCE27E /* MQTTCFSocketTransport.h in Headers */,
C701E3381FB0A70600B0CEB5 /* Timer.h in Headers */,
841D0AA31C358843006A82DC /* MQTTInMemoryPersistence.h in Headers */,
841D0A9C1C358826006A82DC /* MQTTSSLSecurityPolicyTransport.h in Headers */,
845922A51C175AA400CCE27E /* MQTTCFSocketEncoder.h in Headers */,
Expand Down Expand Up @@ -844,8 +844,8 @@
F6D08FC01E535BF900CD2566 /* MQTTSSLSecurityPolicyEncoder.h in Headers */,
F6D08FC41E535BF900CD2566 /* MQTTCFSocketDecoder.h in Headers */,
F6D08FBD1E535BF900CD2566 /* MQTTTransport.h in Headers */,
C7A48D7C1FFB836700248055 /* GCDTimer.h in Headers */,
F6D08FC71E535BF900CD2566 /* MQTTMessage.h in Headers */,
C701E33A1FB0A70600B0CEB5 /* Timer.h in Headers */,
F6D08FC61E535BF900CD2566 /* MQTTDecoder.h in Headers */,
F6D08FC81E535BF900CD2566 /* MQTTSession.h in Headers */,
F6D08FC31E535BF900CD2566 /* MQTTCFSocketEncoder.h in Headers */,
Expand Down Expand Up @@ -878,7 +878,6 @@
F6D08FF71E535F2A00CD2566 /* MQTTCFSocketDecoder.h in Headers */,
F6D08FF21E535F2A00CD2566 /* MQTTSSLSecurityPolicy.h in Headers */,
F6D08FFA1E535F2A00CD2566 /* MQTTMessage.h in Headers */,
C701E3391FB0A70600B0CEB5 /* Timer.h in Headers */,
F6D08FF91E535F2A00CD2566 /* MQTTDecoder.h in Headers */,
F6D08FFB1E535F2A00CD2566 /* MQTTSession.h in Headers */,
C7515EB01F4C51600071CFFE /* ReconnectTimer.h in Headers */,
Expand All @@ -896,6 +895,7 @@
F6D08FF81E535F2A00CD2566 /* MQTTCFSocketTransport.h in Headers */,
F6D090011E535F2A00CD2566 /* MQTTSessionManager.h in Headers */,
F6D090021E535F2F00CD2566 /* MQTTClient.h in Headers */,
C7A48D7B1FFB836600248055 /* GCDTimer.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1355,7 +1355,7 @@
84A5921A1C3C64A9008C5199 /* MQTTSSLSecurityPolicyEncoder.m in Sources */,
840D3CED1F264AE20072019B /* MQTTStrict.m in Sources */,
84A5921B1C3C64A9008C5199 /* MQTTSSLSecurityPolicyTransport.m in Sources */,
C701E33B1FB0A70600B0CEB5 /* Timer.m in Sources */,
C701E33B1FB0A70600B0CEB5 /* GCDTimer.m in Sources */,
84A5921C1C3C64A9008C5199 /* MQTTCoreDataPersistence.m in Sources */,
84A5921D1C3C64A9008C5199 /* MQTTInMemoryPersistence.m in Sources */,
8439D5831C2EB3F000C24F4D /* MQTTSession.m in Sources */,
Expand Down Expand Up @@ -1384,7 +1384,7 @@
F6D08FAE1E535BCB00CD2566 /* MQTTSSLSecurityPolicyDecoder.m in Sources */,
840D3CEF1F264AE40072019B /* MQTTStrict.m in Sources */,
F6D08FAF1E535BCB00CD2566 /* MQTTSSLSecurityPolicyEncoder.m in Sources */,
C701E33D1FB0A70600B0CEB5 /* Timer.m in Sources */,
C701E33D1FB0A70600B0CEB5 /* GCDTimer.m in Sources */,
F6D08FB01E535BCB00CD2566 /* MQTTSSLSecurityPolicyTransport.m in Sources */,
F6D08FB21E535BCB00CD2566 /* MQTTCFSocketEncoder.m in Sources */,
F6D08FB31E535BCB00CD2566 /* MQTTCFSocketDecoder.m in Sources */,
Expand Down Expand Up @@ -1413,7 +1413,7 @@
F6D08FE31E535F1000CD2566 /* MQTTSSLSecurityPolicyDecoder.m in Sources */,
840D3CEE1F264AE30072019B /* MQTTStrict.m in Sources */,
F6D08FE41E535F1000CD2566 /* MQTTSSLSecurityPolicyEncoder.m in Sources */,
C701E33C1FB0A70600B0CEB5 /* Timer.m in Sources */,
C701E33C1FB0A70600B0CEB5 /* GCDTimer.m in Sources */,
F6D08FE51E535F1000CD2566 /* MQTTSSLSecurityPolicyTransport.m in Sources */,
F6D08FE61E535F1000CD2566 /* MQTTCFSocketEncoder.m in Sources */,
F6D08FE71E535F1000CD2566 /* MQTTCFSocketDecoder.m in Sources */,
Expand Down
19 changes: 19 additions & 0 deletions MQTTClient/MQTTClient/GCDTimer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// Timer.h
// MQTTClient
//
// Created by Josip Cavar on 06/11/2017.
// Copyright © 2017 Christoph Krey. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface GCDTimer: NSObject

+ (GCDTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)interval
repeats:(BOOL)repeats
queue:(dispatch_queue_t)queue
block:(void (^)(void))block;
- (void)invalidate;

@end
22 changes: 11 additions & 11 deletions MQTTClient/MQTTClient/Timer.m → MQTTClient/MQTTClient/GCDTimer.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@
// Copyright © 2017 Christoph Krey. All rights reserved.
//

#import "Timer.h"
#import "GCDTimer.h"

@interface Timer ()
@interface GCDTimer ()

@property (strong, nonatomic) dispatch_source_t timer;

@end

@implementation Timer
@implementation GCDTimer

+ (Timer *)scheduledTimerWithTimeInterval:(NSTimeInterval)interval
repeats:(BOOL)repeats
queue:(dispatch_queue_t)queue
block:(void (^)(void))block {
Timer *timer = [[Timer alloc] initWithInterval:interval
repeats:repeats
queue:queue
block:block];
+ (GCDTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)interval
repeats:(BOOL)repeats
queue:(dispatch_queue_t)queue
block:(void (^)(void))block {
GCDTimer *timer = [[GCDTimer alloc] initWithInterval:interval
repeats:repeats
queue:queue
block:block];
return timer;
}

Expand Down
29 changes: 15 additions & 14 deletions MQTTClient/MQTTClient/MQTTSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#import "MQTTProperties.h"
#import "MQTTMessage.h"
#import "MQTTCoreDataPersistence.h"
#import "Timer.h"
#import "GCDTimer.h"

@class MQTTSSLSecurityPolicy;

Expand All @@ -25,10 +25,10 @@ @interface MQTTSession() <MQTTDecoderDelegate, MQTTTransportDelegate>
@property (nonatomic, readwrite) MQTTSessionStatus status;
@property (nonatomic, readwrite) BOOL sessionPresent;

@property (strong, nonatomic) Timer *keepAliveTimer;
@property (strong, nonatomic) GCDTimer *keepAliveTimer;
@property (strong, nonatomic) NSNumber *serverKeepAlive;
@property (nonatomic) UInt16 effectiveKeepAlive;
@property (strong, nonatomic) Timer *checkDupTimer;
@property (strong, nonatomic) GCDTimer *checkDupTimer;

@property (strong, nonatomic) MQTTDecoder *decoder;

Expand Down Expand Up @@ -784,11 +784,12 @@ - (void)decoder:(MQTTDecoder *)sender didReceiveMessage:(NSData *)data {
self.sessionPresent = false;
}
__weak typeof(self) weakSelf = self;
self.checkDupTimer = [Timer scheduledTimerWithTimeInterval:DUPLOOP
repeats:YES
queue:self.queue
block:^{
[weakSelf checkDup]; }];
self.checkDupTimer = [GCDTimer scheduledTimerWithTimeInterval:DUPLOOP
repeats:YES
queue:self.queue
block:^{
[weakSelf checkDup];
}];
[self checkDup];

if (message.properties) {
Expand All @@ -801,12 +802,12 @@ - (void)decoder:(MQTTDecoder *)sender didReceiveMessage:(NSData *)data {
}

if (self.effectiveKeepAlive > 0) {
self.keepAliveTimer = [Timer scheduledTimerWithTimeInterval:self.effectiveKeepAlive
repeats:YES
queue: self.queue
block:^() {
[weakSelf keepAlive];
}];
self.keepAliveTimer = [GCDTimer scheduledTimerWithTimeInterval:self.effectiveKeepAlive
repeats:YES
queue: self.queue
block:^() {
[weakSelf keepAlive];
}];
}

if ([self.delegate respondsToSelector:@selector(handleEvent:event:error:)]) {
Expand Down
16 changes: 8 additions & 8 deletions MQTTClient/MQTTClient/ReconnectTimer.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
//

#import "ReconnectTimer.h"
#import "Timer.h"
#import "GCDTimer.h"

@interface ReconnectTimer()

@property (strong, nonatomic) Timer *timer;
@property (strong, nonatomic) GCDTimer *timer;
@property (assign, nonatomic) NSTimeInterval retryInterval;
@property (assign, nonatomic) NSTimeInterval currentRetryInterval;
@property (assign, nonatomic) NSTimeInterval maxRetryInterval;
Expand Down Expand Up @@ -39,12 +39,12 @@ - (instancetype)initWithRetryInterval:(NSTimeInterval)retryInterval

- (void)schedule {
__weak typeof(self) weakSelf = self;
self.timer = [Timer scheduledTimerWithTimeInterval:self.currentRetryInterval
repeats:NO
queue:self.queue
block:^{
[weakSelf reconnect];
}];
self.timer = [GCDTimer scheduledTimerWithTimeInterval:self.currentRetryInterval
repeats:NO
queue:self.queue
block:^{
[weakSelf reconnect];
}];
}

- (void)stop {
Expand Down
19 changes: 0 additions & 19 deletions MQTTClient/MQTTClient/Timer.h

This file was deleted.

Loading

0 comments on commit 6099723

Please sign in to comment.