mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-03 20:46:28 +00:00
Fix: trigger networkChanged notification also when wifi SSID changed (not only when connectivity changed)
This commit is contained in:
parent
1159b70ae2
commit
d1361ac4d3
1 changed files with 22 additions and 0 deletions
|
|
@ -955,6 +955,10 @@ static void linphone_iphone_is_composing_received(LinphoneCore *lc, LinphoneChat
|
|||
|
||||
#pragma mark - Network Functions
|
||||
|
||||
- (SCNetworkReachabilityRef) getProxyReachability {
|
||||
return proxyReachability;
|
||||
}
|
||||
|
||||
+ (void)kickOffNetworkConnection {
|
||||
/*start a new thread to avoid blocking the main ui in case of peer host failure*/
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
|
|
@ -989,6 +993,14 @@ static void showNetworkFlags(SCNetworkReachabilityFlags flags){
|
|||
[LinphoneLogger logc:LinphoneLoggerLog format:"kSCNetworkReachabilityFlagsIsWWAN"];
|
||||
}
|
||||
|
||||
static void networkReachabilityNotification(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
|
||||
LinphoneManager *mgr = [LinphoneManager instance];
|
||||
SCNetworkReachabilityFlags flags;
|
||||
if (SCNetworkReachabilityGetFlags([mgr getProxyReachability], &flags)) {
|
||||
networkReachabilityCallBack([mgr getProxyReachability],flags,nil);
|
||||
}
|
||||
}
|
||||
|
||||
void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* nilCtx){
|
||||
showNetworkFlags(flags);
|
||||
LinphoneManager* lLinphoneMgr = [LinphoneManager instance];
|
||||
|
|
@ -1069,6 +1081,15 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach
|
|||
proxyReachability = nil;
|
||||
}
|
||||
|
||||
// This notification is used to detect SSID change (switch of Wifi network). The ReachabilityCallback is
|
||||
// not triggered when switching between 2 private Wifi...
|
||||
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(),
|
||||
NULL,
|
||||
networkReachabilityNotification,
|
||||
CFSTR("com.apple.system.config.network_change"),
|
||||
NULL,
|
||||
CFNotificationSuspensionBehaviorDeliverImmediately);
|
||||
|
||||
proxyReachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr*)&zeroAddress);
|
||||
|
||||
if (!SCNetworkReachabilitySetCallback(proxyReachability, (SCNetworkReachabilityCallBack)networkReachabilityCallBack, ctx)){
|
||||
|
|
@ -1079,6 +1100,7 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach
|
|||
[LinphoneLogger logc:LinphoneLoggerError format:"Cannot register schedule reachability cb: %s", SCErrorString(SCError())];
|
||||
return;
|
||||
}
|
||||
|
||||
// this check is to know network connectivity right now without waiting for a change. Don'nt remove it unless you have good reason. Jehan
|
||||
SCNetworkReachabilityFlags flags;
|
||||
if (SCNetworkReachabilityGetFlags(proxyReachability, &flags)) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue