libeXosip2(1-3) -- How-To send or update registrations.
How-To send or update registrations.
Initiate a registration
To start a registration, you need to build a default REGISTER request by providing several mandatory headers.
You can start as many registration you want even in one eXosip_t context.
osip_message_t *reg = NULL;
int rid;
int i;
eXosip_lock (ctx);
rid = eXosip_register_build_initial_register (ctx, "sip:me@sip.antisip.com", "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;
The returned element of eXosip_register_build_initial_register is the registration identifier that you can use to update your registration. In future events about this registration, you'll see that registration identifier when applicable.
Contact headers in REGISTER
You should let eXosip2 manage contact headers alone. The setup you have provided will generate various behavior, all being controlled by eXosip2. See the "NAT and Contact header" section in setup documentation.
Set password(s)!
Usually, you will need a login/password to access a service!
eXosip can be used to access several service at the same time and thus the realm (identify the service) needs to be provided if you are using several services in the same instance.
The simple way when you use one service with username being the same as the login:
eXosip_lock (ctx);
eXosip_add_authentication_info (ctx, login, login, passwd, NULL, NULL);
eXosip_unlock (ctx);
OR the complete way:
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);
Delete all registration
This feature is not advised by sip specification, but it exists for some purpose & reasons! You can send "*" in Contact header of a REGISTER to ask for immediate removal of all active registrations for a particular SIP agent:
rid = eXosip_register_build_initial_register (ctx, "sip:me@sip.antisip.com", "sip.antisip.com", "*", 1800, ®);
Update a registration
You just need to reuse the registration identifier:
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);
Note: The above code also shows that the stack is sometimes able to build and send a default SIP messages with only one API call
Closing the registration
A softphone should delete its registration on the SIP server when terminating. To do so, you have to send a REGISTER request with the expires header set to value "0".
The same code as for updating a registration is used with 0 instead of 1800 for the expiration delay.
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);
Discard registration context
If you need to delete a context without sending a REGISTER with expires 0, you can use eXosip_register_remove to release memory.
int i;
eXosip_lock (ctx);
i = eXosip_register_remove (ctx, rid);
if (i == 0) {
}
eXosip_unlock (ctx);
libeXosip2(1-3) -- How-To send or update registrations.的更多相关文章
- libeXosip2(1) -- Modules
Modules Here is a list of all modules: [detail level 12] The eXtented eXosip stack LibeXosip2 Versio ...
- Simple GB28181 System
I. Deployment / Architecture Block Diagram II. Resources Used 1. freeswitch —— sip server and media ...
- MapReduce剖析笔记之七:Child子进程处理Map和Reduce任务的主要流程
在上一节我们分析了TaskTracker如何对JobTracker分配过来的任务进行初始化,并创建各类JVM启动所需的信息,最终创建JVM的整个过程,本节我们继续来看,JVM启动后,执行的是Child ...
- [翻译]:怎样从C/C++代码中对C#进行回调
声明:网络上类似的中文博客大有存在,本人知识水平有限,业余爱好,也是为了备份收藏How to make a callback to C# from C/C++ code 本着共享知识的初衷,翻译一份给 ...
- Propagation of Visual Entity Properties Under Bandwidth Constraints
1. Introduction The Saga of Ryzom is a persistent massively-multiplayer online game (MMORPG) release ...
- iOS 10.0 更新点(开发者视角)
html, body {overflow-x: initial !important;}html { font-size: 14px; } body { margin: 0px; padding: 0 ...
- 从svn服务器自动同步到另一台服务器
需求场景 A commit B post-commit C (workstation) --------------> (svn server) ---------------------> ...
- Android Non-UI to UI Thread Communications(Part 1 of 5)
original:http://www.intertech.com/Blog/android-non-ui-to-ui-thread-communications-part-1-of-5/ ANDRO ...
- Doubango ims 框架 分析之 多媒体部分
序言 RTP提供带有实时特性的端对端数据传输服务,传输的数据如:交互式的音频和视频.那些服务包括有效载荷类型定义,序列号,时间戳和传输监测控制.应用程序在UDP上运行RTP来使用它的多路技术和chec ...
随机推荐
- POJ2367 Genealogical tree (拓扑排序)
裸拓扑排序. 拓扑排序 用一个队列实现,先把入度为0的点放入队列.然后考虑不断在图中删除队列中的点,每次删除一个点会产生一些新的入度为0的点.把这些点插入队列. 注意:有向无环图 g[] : g[i] ...
- 【每天一个Linux命令】19. 创建文件夹目录命令mkdir
命令用途 mkdir 命令用来创建指定的名称的目录 使用说明 1. 创建目录的用户在当前目录中具有写权限 2. 指定的目录名不能是当前目录中已有的目录. 命令实例 0. 帮助文件 bixiaopen ...
- 好多邮箱的SMTP设置
http://731771490.diandian.com/post/2011-04-20/19576550
- 第32讲 UI组件之 时间日期控件DatePicker和TimePicker
第32讲 UI组件之 时间日期控件DatePicker和TimePicker 在Android中,时间日期控件相对来说还是比较丰富的.其中, DatePicker用来实现日期输入设置, Time ...
- PHP设计模式笔记七:观察者模式 -- Rango韩老师 http://www.imooc.com/learn/236
观察者模式 概述: 1.观察者模式(Observer),当一个对象状态发生改变时,依赖他的对象全部会收到通知,并自动更新 2.场景:一个事件发生后,要执行一连串更新操作,传统的编程方式,就是在事件的代 ...
- [Angular 2] Using the @Inject decorator
TypeScript is used heavily as we build up our application, but TypeScript isn’t required. If you wan ...
- 阿里云 RDS 怎么保证高可用性
RDS在系统构建之初,从网络到硬件再到系统都是基于高可用设计,他可以做到故障30秒无缝转移,对应用完全透明. 当一个数据库实例发生故障时, 另一个会立即顶上,而且对应用是完全透明的.你无需变更应用的连 ...
- 只包含schema的dll生成和引用方法
工作中,所有的tools里有一个project是只包含若干个schema的工程,研究了一下,发现创建这种只包含schema的dll其实非常简单. 首先,在visual studio-new proje ...
- css3标签
-moz代表firefox浏览器私有属性 -ms代表ie浏览器私有属性 -webkit代表chrome.safari私有属性 -o代表opera私有属性 border-radius:2em; 向div ...
- C#窗体实现文件拖拽功能
1.首先要把你的窗体或者空间的AllowDrag属性设置为允许 2.注册DragEnter事件 3.获得文件路径,先通过e.Data.GetFormats()方法获得所有数据格式 4.调用e.GetD ...