⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ht0-initialize.dox

📁 libeXosip2-3.0.3.tar.gz
💻 DOX
字号:
/** * @ingroup libeXosip2 The eXtented eXosip stack * @defgroup howto0_initialize How-To initialize libeXosip2.When using eXosip, your first task is to initializeboth eXosip context and libosip library (parser andstate machines). This must be done prior to any useof libeXosip2.<PRE>	#include <eXosip2/eXosip.h>	int i;	TRACE_INITIALIZE (6, stdout);	i=eXosip_init();	if (i!=0)	  return -1;	i = eXosip_listen_addr (IPPROTO_UDP, NULL, port, AF_INET, 0);	if (i!=0)	  {	    eXosip_quit();	    fprintf (stderr, "could not initialize transport layer\n");	    return -1;	  }	... then you have to send messages and wait for eXosip events...</PRE>In the previous code, you've learned how to:<UL><LI>Initialize the osip trace (compile this codewith -DENABLE_TRACE)</LI><LI>Initialize eXosip (and osip) stack</LI><LI>Open a socket for signalling (only UDP with initial eXosip2 version)</LI></UL>Now you have to handle eXosip events. Here is some code to get eXosip_eventfrom the eXosip2 stack.<PRE>  eXosip_event_t *je;  for (;;)    {      je = eXosip_event_wait (0, 50);      eXosip_lock();      eXosip_automatic_action ();      eXosip_unlock();      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 .....      ....      ....      eXosip_event_free(je);    }</PRE>You will receive one event for each SIP message sent. Each eventcontains the original request of the affected transaction and thelast response that triggers the event when available.You can access all headers from those messages and store them inyour own context for other actions or graphic displays.For example, when you receive a REFER request for a call transfer,you'll typically retreive the "refer-To" header:<PRE>  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)</PRE>The eXosip_event 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 messageswith usual SIP headers (From, To, Call-ID, CSeq, Route, Record-Route,Max-Forward...)  and send thoses messages for you.*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -