Sophie

Sophie

distrib > Fedora > 16 > i386 > by-pkgid > 750aa820f1f75caac19955f06bc89df7 > files > 110

libeXosip2-devel-3.5.0-1.fc16.i686.rpm

\section{How-\/To send or update registrations.}
\label{group__howto2__registration}\index{How-\/To send or update registrations.@{How-\/To send or update registrations.}}
eXosip2 offers a flexible API to help you to register one or several identities.

\subsubsection*{Initiate a registration}

To start a registration, you need to build a default REGISTER request bby providing several mandatory headers


\begin{DoxyPre}
  osip\_message\_t *reg = NULL;
  int id;
  int i;\end{DoxyPre}



\begin{DoxyPre}  eXosip\_lock ();
  id = eXosip\_register\_build\_initial\_register (identity, registrar, NULL,
                                               1800, \&reg);
  if (id < 0)
    \{
      eXosip\_unlock ();
      return -1;
    \}\end{DoxyPre}



\begin{DoxyPre}  osip\_message\_set\_supported (reg, "100rel");
  osip\_message\_set\_supported(reg, "path");\end{DoxyPre}



\begin{DoxyPre}  i = eXosip\_register\_send\_register (id, reg);
  eXosip\_unlock ();
  return i;\end{DoxyPre}



\begin{DoxyPre}\end{DoxyPre}


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.

\subsubsection*{Update a registration}

You just need to reuse the registration identifier:


\begin{DoxyPre}
  int i;\end{DoxyPre}



\begin{DoxyPre}  eXosip\_lock ();
  i = eXosip\_register\_build\_register (id, 1800, \&reg);
  if (i < 0)
    \{
      eXosip\_unlock ();
      return -1;
    \}\end{DoxyPre}



\begin{DoxyPre}  eXosip\_register\_send\_register (id, reg);
  eXosip\_unlock ();
\end{DoxyPre}


{\bfseries 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

\subsubsection*{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 \char`\"{}0\char`\"{}.

The same code as for updating a registration is used with 0 instead of 1800 for the expiration delay.