Skip to content

Instantly share code, notes, and snippets.

@ejknapp
Created November 24, 2009 02:30
Show Gist options
  • Save ejknapp/241581 to your computer and use it in GitHub Desktop.
Save ejknapp/241581 to your computer and use it in GitHub Desktop.
// How to poll
// Property
NSTimer *keepLoggedInTimer;
// Methods
- (void)keepLoginAlive:(NSTimer *)timer;
- (void)startTimerForKeepAlive;
// Start method
#pragma mark Keep Login Alive
- (void)startTimerForKeepAlive {
// NSLog(@"In startTimerForKeepAlive");
NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
NSTimer *keepAliveTimer =
[NSTimer scheduledTimerWithTimeInterval:180
target:self
selector:@selector(keepLoginAlive:)
userInfo:nil
repeats:YES];
[runLoop addTimer:keepAliveTimer forMode:NSDefaultRunLoopMode];
self.keepLoggedInTimer = keepAliveTimer;
}
// Method called by timer
- (void)keepLoginAlive:(NSTimer *)timer {
BOOL isAlive = [self.serverManager testForFlakServer:hostURL];
// NSLog(@"In keepLoginAlive: %@", [timer fireDate]);
if (!isAlive) {
[self.serverManager createSession];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment