0

使用 pjsua2 文档,演示代码如下:

// Configure an AccountConfig
AccountConfig acfg;
acfg.idUri = "sip:test@pjsip.org";
acfg.regConfig.registrarUri = "sip:pjsip.org";
AuthCredInfo cred("digest", "*", "test", 0, "secret");
acfg.sipConfig.authCreds.push_back( cred );
// Create the account
MyAccount *acc = new MyAccount;
acc->create(acfg);
// Here we don't have anything else to do..
pj_thread_sleep(10000);
// Delete the account. This will unregister from server
delete acc;
// This will implicitly shutdown the library
return 0;

pj_thread_sleep(10000)用于避免应用程序退出。

我需要 pjsua2 应用程序始终作为服务器端运行,不应该退出。

所以我应该使用这个函数来代替pj_thread_sleep,比如“loop_forever”,谢谢。

4

2 回答 2

1

您可以使用Endpoint.libHandleEvents. 我使用 Python 绑定,但 API 应该相同。这是一个例子。

try:
    while True:
        ep.libHandleEvents(60_000)
except KeyboardInterrupt:
    logger.info("Exiting. Received interrupt signal.")
finally:
    ep.libDestroy()
于 2020-06-17T13:36:29.440 回答
0

只是阻止程序退出解决了我的问题。

while (true) {
  std::getchar();
}
于 2020-04-01T08:56:03.793 回答