Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Krey committed Oct 28, 2015
2 parents 5861d2f + 4a0fbc1 commit af8d1f5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion MQTTClient/MQTTClient/MQTTSessionManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ - (void)connectTo:(NSString *)host
securityPolicy:(MQTTSSLSecurityPolicy *)securityPolicy
certificates:(NSArray *)certificates
{
BOOL shouldReconnect = self.session != nil;
if (!self.session ||
![host isEqualToString:self.host] ||
port != self.port ||
Expand Down Expand Up @@ -255,7 +256,14 @@ - (void)connectTo:(NSString *)host
self.reconnectTime = RECONNECT_TIMER;
self.reconnectFlag = FALSE;
}
[self connectToInternal];
if(shouldReconnect){
NSLog(@"MQTTSessionManager reconnecting");
[self disconnect];
[self reconnect];
}else{
NSLog(@"MQTTSessionManager connecting");
[self connectToInternal];
}
}

- (UInt16)sendData:(NSData *)data topic:(NSString *)topic qos:(MQTTQosLevel)qos retain:(BOOL)retainFlag
Expand Down

0 comments on commit af8d1f5

Please sign in to comment.