Pothagani / idoubs

Automatically exported from code.google.com/p/idoubs
0 stars 0 forks source link

handle network changes from wifi to 3g or vice versa. #48

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run idoubs on the iphone with wifi connection on.
2. Go to the Settings app -> disable wifi. iPhone switches to 3g connection.
3. iDoubs doesn't handle this network settings change and stops 
receiving/sending packets.

What is the expected output? What do you see instead?

The app needs to correctly identify when the network settings change and reinit 
the sip stack.

What version of the product or source code revision are you using? On what
operating system?

Latest idoubs from svn. iOS 4.2.

Original issue reported on code.google.com by kir...@emergingbanking.com on 7 Jul 2011 at 6:35

GoogleCodeExporter commented 9 years ago
We have stated to work on the issue. In the meanwhile, if you want to add this 
feature, here is the steps:

1. Add an observer for network change in -didFinishLaunchingWithOptions:
[[NSNotificationCenter defaultCenter]
     addObserver:self selector:@selector(onNetworkEvent:) name:kNgnNetworkEventArgs_Name object:nil];

2. Implement -onNetworkEvent: like this:
-(void) onNetworkEvent:(NSNotification*)notification {
    NgnNetworkEventArgs *eargs = [notification object];

    switch (eargs.eventType) {
        case NETWORK_EVENT_STATE_CHANGED:
        default:
        {
            NgnNSLog(TAG,@"NetworkEvent reachable=%@ networkType=%i", 
                     [NgnEngine getInstance].networkService.reachable ? @"YES" : @"NO", [NgnEngine getInstance].networkService.networkType);

            if([NgnEngine getInstance].networkService.reachable){
                BOOL onMobileNework = ([NgnEngine getInstance].networkService.networkType & NetworkType_WWAN);

                if(onMobileNework){ // 3G, 4G, EDGE ...
                    //MediaSessionMgr::defaultsSetBandwidthLevel(tmedia_bl_medium); // QCIF, SQCIF
                }
                else {// WiFi
                    //MediaSessionMgr::defaultsSetBandwidthLevel(tmedia_bl_unrestricted);// SQCIF, QCIF, CIF ...
                }

                // unregister the application and schedule another registration
                BOOL on3G = onMobileNework; // Downgraded to 3G even if it could be 4G or EDGE
                BOOL use3G = [[NgnEngine getInstance].configurationService getBoolWithKey:NETWORK_USE_3G];
                if(on3G && !use3G){
                    // [self networkAlert:kNetworkAlertMsgThreedGNotEnabled];
                    [[NgnEngine getInstance].sipService stopStackSynchronously];
                }
                else { // "on3G and use3G" or on WiFi
                    // stop stack => clean up all dialogs
                    [[NgnEngine getInstance].sipService stopStackSynchronously];
                    [[NgnEngine getInstance].sipService registerIdentity];
                }
            }

            break;
        }
    }
}

Original comment by boss...@yahoo.fr on 8 Jul 2011 at 12:28

GoogleCodeExporter commented 9 years ago

Original comment by boss...@yahoo.fr on 23 Jul 2011 at 4:57