.TH "How-To initialize libeXosip2." 3 "Sun Jun 24 2012" "Version 3.1.0" "libeXosip2" \" -*- nroff -*- .ad l .nh .SH NAME How-To initialize libeXosip2. \- When using eXosip, your first task is to initialize both eXosip context and libosip library (parser and state machines)\&. This must be done prior to any use of libeXosip2\&. .PP .PP .nf #include <\fBeXosip2/eXosip\&.h\fP> .fi .PP .PP .PP .nf int i; .fi .PP .PP .PP .nf TRACE_INITIALIZE (6, stdout); .fi .PP .PP .PP .nf i=\fBeXosip_init()\fP; if (i!=0) return -1; .fi .PP .PP .PP .nf i = eXosip_listen_addr (IPPROTO_UDP, NULL, port, AF_INET, 0); if (i!=0) { \fBeXosip_quit()\fP; fprintf (stderr, 'could not initialize transport layer\\n'); return -1; } .fi .PP .PP .PP .nf \&.\&.\&. then you have to send messages and wait for eXosip events\&.\&.\&. .fi .PP .PP In the previous code, you've learned how to: .PD 0 .IP "\(bu" 2 Initialize the osip trace (compile this code with -DENABLE_TRACE) .IP "\(bu" 2 Initialize eXosip (and osip) stack .IP "\(bu" 2 Open a socket for signalling (only UDP with initial eXosip2 version) .PP .PP Now you have to handle eXosip events\&. Here is some code to get \fBeXosip_event\fP from the eXosip2 stack\&. .PP .PP .nf eXosip_event_t *je; for (;;) { je = eXosip_event_wait (0, 50); \fBeXosip_lock()\fP; eXosip_automatic_action (); \fBeXosip_unlock()\fP; if (je == NULL) break; if (je->type == EXOSIP_CALL_NEW) { \&.\&.\&.\&. \&.\&.\&.\&. } else if (je->type == EXOSIP_CALL_ACK) { \&.\&.\&.\&. \&.\&.\&.\&. } else if (je->type == EXOSIP_CALL_ANSWERED) { \&.\&.\&.\&. \&.\&.\&.\&. } else \&.\&.\&.\&.\&. \&.\&.\&.\&. \&.\&.\&.\&. .fi .PP .PP .PP .nf eXosip_event_free(je); } .fi .PP .PP You will receive one event for each SIP message sent\&. Each event contains the original request of the affected transaction and the last response that triggers the event when available\&. .PP You can access all headers from those messages and store them in your own context for other actions or graphic displays\&. .PP For example, when you receive a REFER request for a call transfer, you'll typically retreive the 'refer-To' header: .PP .PP .nf osip_header_t *referto_head = NULL; i = osip_message_header_get_byname (evt->sip, 'refer-to', 0, &referto_head); if (referto_head == NULL || referto_head->hvalue == NULL) .fi .PP .PP .PP .nf .fi .PP .PP The \fBeXosip_event\fP also contains identifiers for calls, registrations, incoming subscriptions or outgoing subscriptions when applicable\&. Those identifiers are used in API to control calls, registrations, incoming or outgoing subscriptions\&. These API will build default messages with usual SIP headers (From, To, Call-ID, CSeq, Route, Record-Route, Max-Forward\&.\&.\&.) and send thoses messages for you\&. .SH "Author" .PP Generated automatically by Doxygen for libeXosip2 from the source code\&.