|
From: | IVAN FERNANDEZ |
Subject: | [Linphone-developers] Network reachability callback problem in Linphone iPhone |
Date: | Wed, 20 Jun 2012 13:48:34 +0200 |
void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* nilCtx) {
ms_message("Network connection flag [%x]",flags);
LinphoneManager* lLinphoneMgr = [LinphoneManager instance];
SCNetworkReachabilityFlags networkDownFlags=kSCNetworkReachabilityFlagsConnectionRequired |kSCNetworkReachabilityFlagsConnectionOnTraffic;
if ([LinphoneManager getLc] != nil) {
LinphoneProxyConfig* proxy;
linphone_core_get_default_proxy([LinphoneManager getLc], &proxy);
struct NetworkReachabilityContext* ctx = nilCtx ? ((struct NetworkReachabilityContext*)nilCtx) : 0;
if ((flags == 0) | (flags & networkDownFlags)) {
[lLinphoneMgr kickOffNetworkConnection];
//COMMENTING THE FOLLOWING LINE THE PROBLEM IS PARCIALLY SOLVED !!!!!!!!!!!!
linphone_core_set_network_reachable([LinphoneManager getLc],false);
lLinphoneMgr.connectivity = none;
} else {
Connectivity newConnectivity;
BOOL isWifiOnly = [[NSUserDefaults standardUserDefaults] boolForKey:@"wifi_only_preference"];
if (!ctx || ctx->testWWan)
newConnectivity = flags & kSCNetworkReachabilityFlagsIsWWAN ? wwan:wifi;
else
newConnectivity = wifi;
if (newConnectivity == wwan && proxy && isWifiOnly && (lLinphoneMgr.connectivity == newConnectivity || lLinphoneMgr.connectivity == none)) {
linphone_proxy_config_expires(proxy, 0);
} else if (proxy){
linphone_proxy_config_expires(proxy, DEFAULT_EXPIRES); //might be better to save the previous value
}
if (lLinphoneMgr.connectivity == none) {
linphone_core_set_network_reachable([LinphoneManager getLc],true);
} else if (lLinphoneMgr.connectivity != newConnectivity) {
// connectivity has changed
linphone_core_set_network_reachable([LinphoneManager getLc],false);
if (newConnectivity == wwan && proxy && isWifiOnly) {
linphone_proxy_config_expires(proxy, 0);
}
linphone_core_set_network_reachable([LinphoneManager getLc],true);
}
lLinphoneMgr.connectivity=newConnectivity;
ms_message("new network connectivity of type [%s]",(newConnectivity==wifi?"wifi":"wwan"));
}
if (ctx && ctx->networkStateChanged) {
(*ctx->networkStateChanged)(lLinphoneMgr.connectivity);
}
}
}
The most curious thing is that if I comment the invocation to "linphone_core_set_network_reachable" that I've pointed in the callback the first test works great and the callback is called on both on/off wifi changes (what makes me suspect that the problem can be caused by a silly issue), but the second test remains failing.
¿Anyone has that point running? ¿Any ideas about why the callback is not called any more at some point?
PD: On Android, the same test with reachability works great on all the cases.
Thanks in advanced..
[Prev in Thread] | Current Thread | [Next in Thread] |