繁体   English   中英

如何在linphone中注销SIP?

[英]How to unregister from SIP in linphone?

有没有办法在 Linphone 中注销 SIP 并在需要时重新注册?

我找不到注销 function。

我应该为此彻底摧毁 linphone 内核吗?
或者有更软的解决方案吗?

目前我正在尝试在 iOS 中实现它,但稍后将需要其他平台。

谢谢。

// 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);

您可能有多个 SIP 帐户。 首先,指定您想要的帐户并从getProxyConfigList获取您的代理。 然后通过removeProxyConfig方法从 linphone 的核心移除你想要的代理:

private static AuthInfo mAuthInfo;
private static ProxyConfig mProxyConfig;

Core core = LinphoneManager.getCore();
ProxyConfig[] proxyConfigs = core.getProxyConfigList();
if (proxyConfigs.length != 0) {
  mProxyConfig = proxyConfigs[0];
  mAuthInfo = mProxyConfig.findAuthInfo();
}

if (core != null) {
{
 if (mProxyConfig != null) {
        core.removeProxyConfig(mProxyConfig);
  }
 if (mAuthInfo != null) {
        core.removeAuthInfo(mAuthInfo);
  }
}

有如何使用 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 信号。 查看 kill 的手册页。

未完全给出取消注册。 删除 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;
    }
  • 实际上,sip 服务器没有“注销”选项。 位置服务器将更新为最新的注册信息(包括您最新的 IP 地址)。

  • 如果你在谈论如何停止linphone迭代注册,并重新注册到其他SIP服务器。 然后按照@Mun Chun 的指南进行操作

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);

我在 Linphone 上工作了几个月,我从 SIP 注销的功能是:

- (void)clearProxies {
    LinphoneProxyConfig *config = linphone_core_get_default_proxy_config(LC); // Get the default proxy configured.

    const LinphoneAuthInfo *ai = linphone_proxy_config_find_auth_info(config);
    linphone_core_remove_proxy_config(LC, config); // Remove the selected proxy config.
    if (ai) {
        linphone_core_remove_auth_info(LC, ai); // Remove the authentication infos.
    }

    linphone_proxy_config_done(config); // Confirm the actual configuration.
}

您必须清除代理配置和身份验证信息并确认新配置。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM