android - 注册失败后如何更改默认时间延迟300秒(Pjsua 2 Android)重试注册?
问题描述
注册失败后如何更改默认的 pjsua2 重新注册。目前它已设置为 300 秒。我希望设置在注册失败后重试注册到 60 秒左右。
我浏览了文档...但是有些我无法在示例 android pjsua2 应用程序上实现它们。
unsigned timeoutSec 可选的注册间隔,以秒为单位。
如果该值为零,将使用默认间隔(PJSUA_REG_INTERVAL,300 秒)。
unsigned retryIntervalSec 指定注册失败(包括传输问题)时自动注册重试的时间间隔,以秒为单位。
设置为 0 以禁用自动重新注册。请注意,如果由于传输失败而发生注册重试,则第一次重试将在 firstRetryIntervalSec 秒后完成。另请注意,间隔将稍微随机几秒(在 reg_retry_random_interval 中指定)以避免所有客户端同时重新注册。
另请参阅 firstRetryIntervalSec 和 randomRetryIntervalSec 设置。
默认值:PJSUA_REG_RETRY_INTERVAL
链接:https ://www.pjsip.org/docs/book-latest/html/reference.html
解决方案
您可以使用下面的代码,并根据您的需要阅读注释和设置值。
accCfg = new AccountConfig();
/*
* Specify interval of auto registration retry upon registration failure
(including
* caused by transport problem), in second. Set to 0 to disable auto re-
registration.
* Note that if the registration retry occurs because of transport
failure, the first
* retry will be done after reg_first_retry_interval seconds instead. Also
note that
* the interval will be randomized slightly by some seconds (specified in
reg_retry_
* random_interval) to avoid all clients re-registering at the same time.
* */
accCfg.getRegConfig().setFirstRetryIntervalSec(3);
accCfg.getRegConfig().setRetryIntervalSec(10);
/*
* This specifies maximum randomized value to be added/subtracted to/from
the
* registration retry interval specified in reg_retry_interval and
* reg_first_retry_interval, in second. This is useful to avoid all
clients
* re-registering at the same time. For example, if the registration retry
interval
* is set to 100 seconds and this is set to 10 seconds, the actual
registration retry
* interval will be in the range of 90 to 110 seconds.
*/
accCfg.getRegConfig().setRandomRetryIntervalSec(7);
/*
* Optional interval for registration, in seconds. If the value is zero,
default
* interval will be used (PJSUA_REG_INTERVAL, 300 seconds).
*/
accCfg.getRegConfig().setTimeoutSec(65);
/*
* Specify the number of seconds to refresh the client registration before
the
* registration expires.
* Default: PJSIP_REGISTER_CLIENT_DELAY_BEFORE_REFRESH, 5 seconds
*/
accCfg.getRegConfig().setDelayBeforeRefreshSec(10);
推荐阅读
- jhipster - 如何为基于令牌的身份验证禁用 csrf 并为浏览器启用它?
- php - Wget Linux 命令正在为仅 sudo 用户下载具有读取权限的文件 - 如何为所有用户授予读取权限?
- python - 在 Python 中从给定的长十六进制数中获取 8 位数字
- ios - 在计时器的帮助下,Swift 4 在页面视图控制器中自动滑动
- c++ - 手动执行 C++ 向量
- javascript - Eloquent JS:电子生活项目问题
- embedded - USB CDC:STM32F103RBT6 无法显示 USB 设备
- sql - 在 SQL Server 2016 中按子句排序的单个案例中的多列
- php - 如何从以@开头的字符串中获取数组并以字符串中的空格结尾
- java - SonarQube + 报告中未显示的依赖模块中的聚合覆盖率或覆盖率由 Jacoco 生成