<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>libeXosip2: How-To send or update registrations.</title> <link href="tabs.css" rel="stylesheet" type="text/css"> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.5.9 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> </ul> </div> </div> <div class="contents"> <h1>How-To send or update registrations.<br> <small> [<a class="el" href="group__libeXosip2.html">The eXtented eXosip stack</a>]</small> </h1><table border="0" cellpadding="0" cellspacing="0"> <tr><td></td></tr> </table> eXosip2 offers a flexible API to help you to register one or several identities.<p> <h2>Initiate a registration</h2> <p> To start a registration, you need to build a default REGISTER request bby providing several mandatory headers<p> <pre> osip_message_t *reg = NULL; int id; int i;</pre><p> <pre> eXosip_lock (); id = eXosip_register_build_initial_register (identity, registrar, NULL, 1800, &reg); if (id < 0) { eXosip_unlock (); return -1; }</pre><p> <pre> osip_message_set_supported (reg, "100rel"); osip_message_set_supported(reg, "path");</pre><p> <pre> i = eXosip_register_send_register (id, reg); eXosip_unlock (); return i;</pre><p> <pre></pre><p> 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.<p> <h2>Update a registration</h2> <p> You just need to reuse the registration identifier:<p> <pre> int i;</pre><p> <pre> eXosip_lock (); i = eXosip_register_build_register (id, 1800, &reg); if (i < 0) { eXosip_unlock (); return -1; }</pre><p> <pre> eXosip_register_send_register (id, reg); eXosip_unlock (); </pre><p> <b>Note</b>: The above code also shows that the stack is sometimes able to build and send a default SIP messages with only one API call<p> <h2>Closing the registration</h2> <p> 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".<p> The same code as for updating a registration is used with 0 instead of 1800 for the expiration delay. </div> <hr size="1"><address style="text-align: right;"><small>Generated on Sun Jul 26 15:51:58 2009 for libeXosip2 by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address> </body> </html>