Merge branch 'charlesmchen/cleanupTimerUsage'

pull/1/head
Matthew Chen 8 years ago
commit 888943a047

@ -2,15 +2,15 @@
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// //
#import "SubProtocol.pb.h" #import "TSSocketManager.h"
#import "Cryptography.h" #import "Cryptography.h"
#import "NSTimer+OWS.h"
#import "OWSSignalService.h" #import "OWSSignalService.h"
#import "OWSWebsocketSecurityPolicy.h" #import "OWSWebsocketSecurityPolicy.h"
#import "SubProtocol.pb.h"
#import "TSAccountManager.h" #import "TSAccountManager.h"
#import "TSConstants.h" #import "TSConstants.h"
#import "TSMessagesManager.h" #import "TSMessagesManager.h"
#import "TSSocketManager.h"
#import "TSStorageManager+keyingMaterial.h" #import "TSStorageManager+keyingMaterial.h"
#import "Threading.h" #import "Threading.h"
@ -533,11 +533,11 @@ NSString *const kNSNotification_SocketManagerStateDidChange = @"kNSNotification_
[self.backgroundKeepAliveTimer invalidate]; [self.backgroundKeepAliveTimer invalidate];
// Start a new timer that will fire every second while the socket is open in the background. // Start a new timer that will fire every second while the socket is open in the background.
// This timer will ensure we close the websocket when the time comes. // This timer will ensure we close the websocket when the time comes.
self.backgroundKeepAliveTimer = [NSTimer scheduledTimerWithTimeInterval:1.f self.backgroundKeepAliveTimer = [NSTimer weakScheduledTimerWithTimeInterval:1.f
target:self target:self
selector:@selector(backgroundKeepAliveFired) selector:@selector(backgroundKeepAliveFired)
userInfo:nil userInfo:nil
repeats:YES]; repeats:YES];
// Additionally, we want the reconnect timer to work in the background too. // Additionally, we want the reconnect timer to work in the background too.
[[NSRunLoop mainRunLoop] addTimer:self.backgroundKeepAliveTimer forMode:NSDefaultRunLoopMode]; [[NSRunLoop mainRunLoop] addTimer:self.backgroundKeepAliveTimer forMode:NSDefaultRunLoopMode];

Loading…
Cancel
Save