From 2b197197be2e9db7f58bb06623391e3daa159e00 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 30 May 2017 12:17:33 -0400 Subject: [PATCH] Clean up timer usage. // FREEBIE --- src/Network/WebSockets/TSSocketManager.m | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Network/WebSockets/TSSocketManager.m b/src/Network/WebSockets/TSSocketManager.m index 30e8bd63c..2c6c7a9e2 100644 --- a/src/Network/WebSockets/TSSocketManager.m +++ b/src/Network/WebSockets/TSSocketManager.m @@ -2,15 +2,15 @@ // Copyright (c) 2017 Open Whisper Systems. All rights reserved. // -#import "SubProtocol.pb.h" - +#import "TSSocketManager.h" #import "Cryptography.h" +#import "NSTimer+OWS.h" #import "OWSSignalService.h" #import "OWSWebsocketSecurityPolicy.h" +#import "SubProtocol.pb.h" #import "TSAccountManager.h" #import "TSConstants.h" #import "TSMessagesManager.h" -#import "TSSocketManager.h" #import "TSStorageManager+keyingMaterial.h" #import "Threading.h" @@ -533,11 +533,11 @@ NSString *const kNSNotification_SocketManagerStateDidChange = @"kNSNotification_ [self.backgroundKeepAliveTimer invalidate]; // 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. - self.backgroundKeepAliveTimer = [NSTimer scheduledTimerWithTimeInterval:1.f - target:self - selector:@selector(backgroundKeepAliveFired) - userInfo:nil - repeats:YES]; + self.backgroundKeepAliveTimer = [NSTimer weakScheduledTimerWithTimeInterval:1.f + target:self + selector:@selector(backgroundKeepAliveFired) + userInfo:nil + repeats:YES]; // Additionally, we want the reconnect timer to work in the background too. [[NSRunLoop mainRunLoop] addTimer:self.backgroundKeepAliveTimer forMode:NSDefaultRunLoopMode];