diff options
author | Muller, Alexander (A.) <amulle19@ford.com> | 2017-01-20 12:51:38 -0800 |
---|---|---|
committer | Muller, Alexander (A.) <amulle19@ford.com> | 2017-01-20 12:51:38 -0800 |
commit | a802bd47a1bacac9052b15f2e1243498b59c8bdd (patch) | |
tree | c6fea3b98636a4605dc88fe067d38f0f329b5e39 | |
parent | faf1427f72172235a82b7a8d389267653db7f553 (diff) | |
download | sdl_ios-a802bd47a1bacac9052b15f2e1243498b59c8bdd.tar.gz |
Fixed issue with stopping the proxy didn't actually stop it.
-rw-r--r-- | SmartDeviceLink/SDLLifecycleManager.h | 3 | ||||
-rw-r--r-- | SmartDeviceLink/SDLLifecycleManager.m | 21 | ||||
-rw-r--r-- | SmartDeviceLink_Example/Classes/ProxyManager.m | 3 |
3 files changed, 22 insertions, 5 deletions
diff --git a/SmartDeviceLink/SDLLifecycleManager.h b/SmartDeviceLink/SDLLifecycleManager.h index ae63f92d2..9ee943a13 100644 --- a/SmartDeviceLink/SDLLifecycleManager.h +++ b/SmartDeviceLink/SDLLifecycleManager.h @@ -36,6 +36,7 @@ NS_ASSUME_NONNULL_BEGIN typedef NSString SDLLifecycleState; +extern SDLLifecycleState *const SDLLifecycleStateReconnecting; extern SDLLifecycleState *const SDLLifecycleStateDisconnected; extern SDLLifecycleState *const SDLLifecycleStateTransportConnected; extern SDLLifecycleState *const SDLLifecycleStateRegistered; @@ -117,4 +118,4 @@ typedef void (^SDLManagerReadyBlock)(BOOL success, NSError *_Nullable error); @end -NS_ASSUME_NONNULL_END
\ No newline at end of file +NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLink/SDLLifecycleManager.m b/SmartDeviceLink/SDLLifecycleManager.m index 806265fe9..4fc9879fa 100644 --- a/SmartDeviceLink/SDLLifecycleManager.m +++ b/SmartDeviceLink/SDLLifecycleManager.m @@ -43,6 +43,7 @@ NS_ASSUME_NONNULL_BEGIN +SDLLifecycleState *const SDLLifecycleStateReconnecting = @"Reconnecting"; SDLLifecycleState *const SDLLifecycleStateDisconnected = @"TransportDisconnected"; SDLLifecycleState *const SDLLifecycleStateTransportConnected = @"TransportConnected"; SDLLifecycleState *const SDLLifecycleStateRegistered = @"Registered"; @@ -63,6 +64,7 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready"; @property (strong, nonatomic, readwrite) SDLNotificationDispatcher *notificationDispatcher; @property (strong, nonatomic, readwrite) SDLResponseDispatcher *responseDispatcher; @property (strong, nonatomic, readwrite) SDLStateMachine *lifecycleStateMachine; +@property (assign, nonatomic, readwrite, getter=shouldRestartProxy) BOOL restartProxy; // Deprecated internal proxy object #pragma clang diagnostic push @@ -89,6 +91,8 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready"; if (!self) { return nil; } + + _restartProxy = YES; // Dependencies _configuration = configuration; @@ -115,6 +119,9 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready"; } - (void)startWithReadyHandler:(SDLManagerReadyBlock)readyHandler { + // We will always try to restart the proxy, unless stop is called. + _restartProxy = YES; + self.readyHandler = [readyHandler copy]; // Set up our logging capabilities based on the config @@ -132,6 +139,7 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready"; } - (void)stop { + _restartProxy = NO; if ([self.lifecycleStateMachine isCurrentState:SDLLifecycleStateReady]) { [self.lifecycleStateMachine transitionToState:SDLLifecycleStateUnregistering]; } else { @@ -155,7 +163,8 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready"; + (NSDictionary<SDLState *, SDLAllowableStateTransitions *> *)sdl_stateTransitionDictionary { return @{ - SDLLifecycleStateDisconnected: @[SDLLifecycleStateTransportConnected], + SDLLifecycleStateReconnecting: @[SDLLifecycleStateTransportConnected], + SDLLifecycleStateDisconnected: @[SDLLifecycleStateReconnecting, SDLLifecycleStateTransportConnected], SDLLifecycleStateTransportConnected: @[SDLLifecycleStateDisconnected, SDLLifecycleStateRegistered], SDLLifecycleStateRegistered: @[SDLLifecycleStateDisconnected, SDLLifecycleStateSettingUpManagers], SDLLifecycleStateSettingUpManagers: @[SDLLifecycleStateDisconnected, SDLLifecycleStatePostManagerProcessing], @@ -165,6 +174,10 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready"; }; } +- (void)didEnterStateReconnecting { + [self startWithReadyHandler:self.readyHandler]; +} + - (void)didEnterStateTransportDisconnected { [self.fileManager stop]; [self.permissionManager stop]; @@ -177,8 +190,10 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready"; [self sdl_disposeProxy]; // call this method instead of stopProxy to avoid double-dispatching [self.delegate managerDidDisconnect]; - - [self startWithReadyHandler:self.readyHandler]; // Start up again to start watching for new connections + + if (self.shouldRestartProxy) { + [self.lifecycleStateMachine transitionToState:SDLLifecycleStateReconnecting]; + } } - (void)didEnterStateTransportConnected { diff --git a/SmartDeviceLink_Example/Classes/ProxyManager.m b/SmartDeviceLink_Example/Classes/ProxyManager.m index 55dbe2a3a..a26773ac9 100644 --- a/SmartDeviceLink_Example/Classes/ProxyManager.m +++ b/SmartDeviceLink_Example/Classes/ProxyManager.m @@ -91,7 +91,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)startManager { __weak typeof (self) weakSelf = self; [self.sdlManager startWithReadyHandler:^(BOOL success, NSError * _Nullable error) { - if (!success) { + if (!weakSelf.sdlManager.registerResponse.success.boolValue) { NSLog(@"SDL errored starting up: %@", error); [weakSelf sdlex_updateProxyState:ProxyStateStopped]; } else { @@ -108,6 +108,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)reset { [self.sdlManager stop]; + [self startManager]; } - (void)showInitialData { |