Re: Detecting Internet (w/code, part 2)
Re: Detecting Internet (w/code, part 2)
- Subject: Re: Detecting Internet (w/code, part 2)
- From: John Pannell <email@hidden>
- Date: Mon, 26 Jun 2006 17:44:15 -0600
(Continued from part 1)
3. Take action based on what the flags are saying...
- (void)networkStatusChanged:(int)flags
{
/*
NSLog(@"*** hostReachabilityChangedCallback got flags: %c%c%c%c%c
%c%c \n",
(flags & kSCNetworkFlagsTransientConnection) ? 't' : '-',
(flags & kSCNetworkFlagsReachable) ? 'r' : '-',
(flags & kSCNetworkFlagsConnectionRequired) ? 'c' : '-',
(flags & kSCNetworkFlagsConnectionAutomatic) ? 'C' : '-',
(flags & kSCNetworkFlagsInterventionRequired) ? 'i' : '-',
(flags & kSCNetworkFlagsIsLocalAddress) ? 'l' : '-',
(flags & kSCNetworkFlagsIsDirect) ? 'd' : '-');
*/
if(!_isSleeping){ // don't mess with this on wake from sleep!
if((flags & kSCNetworkFlagsConnectionRequired) || (flags &
kSCNetworkFlagsInterventionRequired)){
// trouble - notify and pause
[[self sessionArray] makeObjectsPerformSelector:@selector
(pauseEngine)];
NSAlert *networkAlert = [NSAlert
alertWithMessageText:@"Network Issue" defaultButton:@"OK"
alternateButton:nil otherButton:nil
informativeTextWithFormat:@"Pandora can no longer connect to the
Internet for some reason. Please check your network settings and
status. Pandora will pause all processing for the time being, and
automatically restart all processes when the network comes back
online."];
[networkAlert beginSheetModalForWindow:[NSApp keyWindow]
modalDelegate:self didEndSelector:nil contextInfo:nil];
} else {
[[self sessionArray] makeObjectsPerformSelector:@selector
(resumeEngine)];
}
}
}
I check a flag to see if the computer is going/waking from sleep
(network changes there too), and then stop processing and send up an
alert if bad network things are happening. If good things are
happening, I tell my network-dependent subprocesses to get back to
work. You can uncomment the NSLog for testing purposes.
Hope this helps!
John
John Pannell
Positive Spin Media
http://www.positivespinmedia.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden