Code: Select all
[sfsClient setReconnectionSeconds:(NSInteger)];
WHen the client comes back into the foreground, reset that value to something greater than zero to handle network issues when you want the client to be able to reconnect.
Code: Select all
[sfsClient setReconnectionSeconds:(NSInteger)];
Code: Select all
[self setSfs:[SmartFox2XClient smartFoxWithDebugMode:NO delegate:self]];
[self.sfs setReconnectSeconds:0];
- (void)handleApplicationNotification:(NSNotification *)notification {
NSString *name = [notification name];
if ([name isEqualToString:UIApplicationDidBecomeActiveNotification]) {
[self.sfs connect:socket_ip port:9933];
} else {
[self.sfs disconnect];
}
}
Code: Select all
[self setSfs:[SmartFox2XClient smartFoxWithDebugMode:NO delegate:self]];
[self.sfs setReconnectSeconds:0];
- (void)handleApplicationNotification:(NSNotification *)notification {
NSString *name = [notification name];
if ([name isEqualToString:UIApplicationDidBecomeActiveNotification]) {
[self.sfs connect:socket_ip port:9933];
} else if ([name isEqualToString:UIApplicationWillResignActiveNotification]){
[self.sfs disconnect];
}
}
Code: Select all
if ([name isEqualToString:UIApplicationDidBecomeActiveNotification]) {
[self.sfs setReconnectSeconds:1]; //or some other custom value so legitimate network issues are resolved automatically
[self.sfs connect:socket_ip port:9933];
} else if ([name isEqualToString:UIApplicationWillResignActiveNotification]){
[self.sfs setReconnectSeconds:0];
[self.sfs disconnect];
}
Return to “SFS2X iPhone / iPad / OSX API”
Users browsing this forum: No registered users and 3 guests