Note that there are some explanatory texts on larger screens.

plurals
  1. POWeb Server status checking using timer
    primarykey
    data
    text
    <p>I have to download files from my server. Multiple download is supported. When i click download i have to check for network connectivity and server connectivity, <strong>Which is done</strong>.</p> <p>Here is the problem!</p> <p>During download if the server become unavailable, it creates some problems. So I have to check for server connectivity after 5 sec, and have to display an alert that the server is down. I used a timer to check the connectivity. But the problem is that, during multiple downloads the alert view is displayed as many times as the number of downloads. And if the server becomes available in between then the app freezes. But I could see that the timer code is still working..</p> <p>Sample code:</p> <pre><code> -(void) myFunction { if ([networkCheck isHostReachable]) { if (![ServerConnectivity isServerUp:myUrl]) { serverStatusAlert = YES; } if (serverStatusAlert) { UIAlertView *serverDownAlert = [[UIAlertView alloc]initWithTitle:@"Error" message:@"Server is down. Please try after sometimes." delegate:self cancelButtonTitle:nil otherButtonTitles:@"Ok",nil]; [serverDownAlert show]; [serverDownAlert release]; serverDownAlert = nil; [self cancelAllDownload]; connectivityTimer = [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(checkServerStatus) userInfo:nil repeats:YES]; } } else { NSLog(@"No network connection..."); } } -(void)checkServerStatus { if ([ServerConnectivity isServerUp:myUrl]) { [connectivityTimer invalidate]; connectivityTimer = nil; serverStatusAlert = NO; //function to resume downloads } else { //pause downloads } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload