當我需要Linphone時,有沒有辦法從SIP註銷並重新註冊?如何從linphone中註銷SIP?
我找不到取消註冊功能。
我應該徹底銷燬linphone內核嗎?
還是有更軟的解決方案?
目前我正試圖在iOS中實現它,但稍後這將是其他平臺所必需的。
謝謝。
當我需要Linphone時,有沒有辦法從SIP註銷並重新註冊?如何從linphone中註銷SIP?
我找不到取消註冊功能。
我應該徹底銷燬linphone內核嗎?
還是有更軟的解決方案?
目前我正試圖在iOS中實現它,但稍後這將是其他平臺所必需的。
謝謝。
未完全給出註銷。刪除SIP擴展名,然後調用刷新寄存器。現在,網絡電話從SIP
[[NSUserDefaults standardUserDefaults] setObject:@"" forKey:@"username_preference"];
if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]
&& [UIApplication sharedApplication].applicationState == UIApplicationStateBackground
&& [[NSUserDefaults standardUserDefaults] boolForKey:@"disable_autoboot_preference"]) {
// autoboot disabled, doing nothing
return;
} else if ([SipManager instance] == nil) {
[self startApplication:caldelegate];
}
[[LinphoneManager instance] becomeActive];
if (callCenter == nil) {
callCenter = [[CTCallCenter alloc] init];
callCenter.callEventHandler = ^(CTCall* call) {
// post on main thread
[self performSelectorOnMainThread:@selector(handleGSMCallInteration:)
withObject:callCenter
waitUntilDone:YES];
};
}
// check call state at startup
[self handleGSMCallInteration:callCenter];
LinphoneCore* lc = [SipManager getLc];
LinphoneCall* call = linphone_core_get_current_call(lc);
if (call == NULL)
return;
SipManager* instance = [SipManager instance];
if (call == instance->currentCallContextBeforeGoingBackground.call) {
const LinphoneCallParams* params = linphone_call_get_current_params(call);
if (linphone_call_params_video_enabled(params)) {
linphone_call_enable_camera(
call,
instance->currentCallContextBeforeGoingBackground.cameraIsEnabled);
}
instance->currentCallContextBeforeGoingBackground.call = 0;
}
// Get the default proxyCfg in Linphone
LinphoneProxyConfig* proxyCfg = NULL;
linphone_core_get_default_proxy([LinphoneManager getLc], &proxyCfg);
// To unregister from SIP
linphone_proxy_config_edit(proxyCfg);
linphone_proxy_config_enable_register(proxyCfg, false);
linphone_proxy_config_done(proxyCfg);
// And re-register when want
linphone_proxy_config_edit(proxyCfg);
linphone_proxy_config_enable_register(proxyCfg, true);
linphone_proxy_config_done(proxyCfg);
註銷有如何使用Linphone中註銷的方式。
獲取LinphoneProxyConfig
LinphoneProxyConfig* proxyCfg = NULL;
linphone_core_get_default_proxy([LinphoneManager getLc], &proxyCfg);
從SIP
linphone_proxy_config_edit(proxyCfg); /*start editing proxy configuration*/
linphone_proxy_config_enable_publish(proxyCfg, TRUE);
linphone_proxy_config_set_publish_expires(proxyCfg, 0);
linphone_proxy_config_enable_register(proxyCfg,FALSE); /*de-activate registration for this proxy config*/
linphone_proxy_config_done(proxyCfg); /*initiate REGISTER with expire = 0*/
while(linphone_proxy_config_get_state(proxyCfg) != LinphoneRegistrationCleared){
NSLog(@"state = %i",linphone_proxy_config_get_state(proxyCfg));
linphone_core_iterate(lc); /*to make sure we receive call backs before shutting down*/
ms_usleep(100000);
}
註銷但它只能當應用前景。在後臺如果操作系統因任何原因殺死你的應用程序,它會被殺死。沒有通知。您無法捕捉到SIGKILL信號。看看殺手的手冊頁。
實際上,sip服務器沒有「取消註冊」選項。位置服務器將更新爲最新的註冊信息(包括最新的IP地址)。
如果您正在討論如何停止linphone迭代註冊,並重新註冊到其他SIP服務器。然後按照@孟俊的指導
LinphoneCore *lc = [LinphoneManager getLc];
LinphoneProxyConfig *config = linphone_core_get_default_proxy_config(lc);
linphone_proxy_config_edit(config);
linphone_proxy_config_set_expires(config, 0);
linphone_proxy_config_done(config);