nea.docs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /* -*- c -*- */
  2. /**@MODULEPAGE "nea" - SIP Events Module
  3. *
  4. * @section nea_meta Module Meta Information
  5. *
  6. * Sofia Event API provides an interface to different events used in SIP
  7. * presence and conferencing. Interface used both in client and server sides
  8. * is presented in <sofia-sip/nea.h>.
  9. *
  10. * @CONTACT Pekka Pessi <Pekka.Pessi@nokia.com>
  11. *
  12. * @STATUS @SofiaSIP Core library
  13. *
  14. * @LICENSE LGPL
  15. *
  16. * @section Creating NEA server and events
  17. *
  18. * @section nea_server_create Creating NEA server
  19. *
  20. * NEA server generates, receives and sends events to subscribed
  21. * parties. The server is presentity specific, ie. a different server
  22. * is created for every presentity.
  23. *
  24. * First, a server object is created. The object uses the NTA @e agent
  25. * (#nta_agent_t) that handles incoming and outgoing SIP messages.
  26. *
  27. * The example below provides a way to create the NEA server. The
  28. * function nea_server_create() creates the server. Parameters @e
  29. * agent, @e root define the transaction engine. Third parameter is
  30. * the address of the presentity. event_callback is a callback
  31. * function pointer and is called every time a new user subscribes to
  32. * an event that does not exist or requests for payload type that
  33. * doesn't match.
  34. *
  35. * @code
  36. * presence_t *presence_create(su_root_t *root,
  37. * nta_agent_t *agent,
  38. * sip_contact_t const *m)
  39. * {
  40. * presentity_t *pr = su_home_clone(p->p_home, sizeof (*pr));
  41. * ...
  42. * pr->pr_nes =
  43. * nea_server_create(agent, root,
  44. * m->m_url,
  45. * MAX_SUBSCRIBERS,
  46. * event_callback, pr,
  47. * SIPTAG_CONTACT(m),
  48. * SIPTAG_SERVER_STR("Sofia-SIP NEA"),
  49. * TAG_NULL());
  50. * ...
  51. * }
  52. * @endcode
  53. *
  54. * @section nea_event_create Creating Events
  55. *
  56. * Next, events are created. The function nea_event_create () defines
  57. * an event, its package and content types (a comma separated
  58. * list). The parameter presence_callback defines the callback
  59. * function that is called when a someone subscribes to a defined
  60. * event.
  61. *
  62. * @code
  63. * #define PRESENCE_PACKAGE "presence"
  64. * #define XPIDF_MIME_TYPE "application/xpidf+xml"
  65. * #define PIDF_MIME_TYPE "application/cpim-pidf+xml"
  66. * ne = nea_event_create(pr->pr_nes, presence_callback, ep,
  67. * PRESENCE_PACKAGE, NULL,
  68. * PIDF_MIME_TYPE,
  69. * PIDF_MIME_TYPE "," XPIDF_MIME_TYPE);
  70. * @endcode
  71. *
  72. * @section nea_server_update Operating with event payloads
  73. *
  74. * A new payload can be inserted to a event with the function
  75. * nea_server_update(). The 4th parameter describes if the updated
  76. * content is a fake (for unauthorized subscribers). A real payload is
  77. * inserted (updated) with the 4th parameter being 0. If the event is
  78. * not updated with the content type @a ct before, a new content type
  79. * format for the event is created. Otherwise the old payload is
  80. * replaced with the new one.
  81. *
  82. * After the update, subscribers of the event are notified (with SIP
  83. * NOTIFY) of the changed payload with nea_server_update ().
  84. *
  85. * @code
  86. * nea_server_update(pr->pr_nes, home, event, 1,
  87. * SIPTAG_CONTENT_TYPE(ct),
  88. * SIPTAG_PAYLOAD(pl),
  89. * TAG_END());
  90. * nea_server_notify(pr->pr_nes, event);
  91. * @endcode
  92. *
  93. * Obtaining the event's payload and removing it is presented in the
  94. * example below. The event is defined as a part of the @a package_t
  95. * structure. Function nea_payloads_get() is used to return a payload
  96. * (in this case content type being predefined
  97. * "application/cpim-pidf+xml"). The real and fake payloads are stored
  98. * in the structure #nea_payloads_t. Finally, the payload is removed
  99. * with nea_payload_remove().
  100. *
  101. * @code
  102. * int remove_old_payload(package_t *ep)
  103. * {
  104. * nea_payloads_t *np;
  105. * sip_content_type_t *ct;
  106. * sip_payload_t *real;
  107. * sip_payload_t *fake;
  108. * event = ep->ep_event;
  109. * np = nea_payloads_get(event, PIDF_MIME_TYPE);
  110. * ct = nea_content_type_get(np);
  111. * real = nea_payload_get(np);
  112. * fake = nea_fake_get(np);
  113. * nea_payload_remove(ep->ep_home, np);
  114. * return 0;
  115. * }
  116. * @endcode
  117. */