构建初始化注册请求
/**
* Build initial REGISTER request.
*
* @param excontext eXosip_t instance.
* @param from SIP url for caller.
* @param proxy Proxy used for registration.
* @param contact Contact address. (optional)
* @param expires The expires value for registration.
* @param reg The SIP request to build.
*/
int eXosip_register_build_initial_register (struct eXosip_t *excontext, const char *from, const char *proxy, const char *contact, int expires, osip_message_t ** reg);
使用qvalue值构建初始化注册请求
/**
* Build initial REGISTER request with qvalue for contact.
*
* @param excontext eXosip_t instance.
* @param from SIP url for caller.
* @param proxy Proxy used for registration.
* @param contact Contact address. (optional)
* @param expires The expires value for registration.
* @param qvalue The qvalue value for contact header.
* @param reg The SIP request to build.
*/
int eXosip_register_build_initial_register_withqvalue (struct eXosip_t *excontext, const char *from, const char *proxy, const char *contact, int expires, const char *qvalue, osip_message_t ** reg);
为一个已经存在的注册构建一个新的注册请求,可用于关闭注册于刷新注册。
/**
* Build a new REGISTER request for an existing registration.
*
* @param excontext eXosip_t instance.
* @param rid A unique identifier for the registration context
* @param expires The expires value for registration.
* @param reg The SIP request to build.
*/
int eXosip_register_build_register (struct eXosip_t *excontext, int rid, int expires, osip_message_t ** reg);
为一个已经存在的注册发送注册请求
/**
* Send a REGISTER request for an existing registration.
*
* @param excontext eXosip_t instance.
* @param rid A unique identifier for the registration context
* @param reg The SIP request to build. (NULL for default REGISTER)
*/
int eXosip_register_send_register (struct eXosip_t *excontext, int rid, osip_message_t * reg);
在不发送注册请求的情况下,删除已经存在的注册,
在没有发送关闭注册请求的情况下,移除注册,释放内存资源。
/**
* Remove existing registration without sending REGISTER.
*
* @param excontext eXosip_t instance.
* @param rid A unique identifier for the registration context
*/
int eXosip_register_remove (struct eXosip_t *excontext, int rid);
需要提供多个头域,同一个ctx中可以开启多个注册
osip_message_t *reg = NULL;
int rid;
int i;
eXosip_lock (ctx);
rid = eXosip_register_build_initial_register (ctx, "sip:[email protected]", "sip.antisip.com", NULL, 1800, ®);
if (rid < 0)
{
eXosip_unlock (ctx);
return -1;
}
osip_message_set_supported (reg, "100rel");
osip_message_set_supported (reg, "path");
i = eXosip_register_send_register (ctx, rid, reg);
eXosip_unlock (ctx);
return i;
eXosip_register_build_initial_register 返回值为注册ID,可用于刷新注册
应该有eXosip单独管理Contact头域,
通常,您需要登录/密码才能访问服务。
eXosip可用于同时访问多个服务,因此,如果在同一实例中使用多个服务,则需要提供领域(标识服务)。
当您使用一个用户名与登录名相同的服务时,最简单的方法是:
eXosip_lock (ctx);
eXosip_add_authentication_info (ctx, login, login, passwd, NULL, NULL);
eXosip_unlock (ctx);
或者完整的方式
eXosip_lock (ctx);
eXosip_add_authentication_info (ctx, login, login, passwd, NULL, "sip.antisip.com");
eXosip_add_authentication_info (ctx, from_username, login, passwd, NULL, "otherservice.com");
eXosip_unlock (ctx);
sip规范中不建议使用这个功能,要求立即删除特定SIP代理的所有活动注册
rid = eXosip_register_build_initial_register (ctx, "sip:[email protected]", "sip.antisip.com", "*", 1800, ®);
只需要初始化注册时反馈的注册ID
int i;
eXosip_lock (ctx);
i = eXosip_register_build_register (ctx, rid, 1800, ®);
if (i < 0)
{
eXosip_unlock (ctx);
return -1;
}
eXosip_register_send_register (ctx, rid, reg);
eXosip_unlock (ctx);
软电话在终止时应删除其在SIP服务器上的注册。为此,您必须发送一个注册请求,将expires头设置为值“0”。
与更新注册代码相同,仅是expires的值设置为0即可。
int i;
eXosip_lock (ctx);
i = eXosip_register_build_register (ctx, rid, 0, ®);
if (i < 0)
{
eXosip_unlock (ctx);
return -1;
}
eXosip_register_send_register (ctx, rid, reg);
eXosip_unlock (ctx);
如果你不想发送expires为0的注册,直接释放内存,可以使用eXosip_register_remove实现。
int i;
eXosip_lock (ctx);
i = eXosip_register_remove (ctx, rid);
if (i == 0) {
}
eXosip_unlock (ctx);