messaging.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 2014, Digium, Inc.
  5. *
  6. * Matt Jordan <mjordan@digium.com>
  7. *
  8. * See http://www.asterisk.org for more information about
  9. * the Asterisk project. Please do not directly contact
  10. * any of the maintainers of this project for assistance;
  11. * the project provides a web site, mailing lists and IRC
  12. * channels for your use.
  13. *
  14. * This program is free software, distributed under the terms of
  15. * the GNU General Public License Version 2. See the LICENSE file
  16. * at the top of the source tree.
  17. */
  18. #ifndef _ASTERISK_RES_STASIS_MESSAGING_H
  19. #define _ASTERISK_RES_STASIS_MESSAGING_H
  20. /*!
  21. * \file
  22. *
  23. * \brief Stasis out-of-call text message support
  24. *
  25. * \author Matt Jordan <mjordan@digium.com>
  26. * \since 12.4.0
  27. */
  28. /*!
  29. * \brief Callback handler for when a message is received from the core
  30. *
  31. * \param endpoint_id The ID of the endpoint that we received the message from
  32. * \param json_msg JSON representation of the text message
  33. * \param pvt ao2 ref counted pvt passed during registration
  34. *
  35. * \retval 0 the message was handled
  36. * \retval non-zero the message was not handled
  37. */
  38. typedef int (* message_received_cb)(const char *endpoint_id, struct ast_json *json_msg, void *pvt);
  39. /*!
  40. * \brief Subscribe for messages from a particular endpoint
  41. *
  42. * \param app_name Name of the stasis application to unsubscribe from messaging
  43. * \param endpoint_id The ID of the endpoint we no longer care about
  44. *
  45. * \retval 0 success
  46. * \retval -1 error
  47. */
  48. void messaging_app_unsubscribe_endpoint(const char *app_name, const char *endpoint_id);
  49. /*!
  50. * \brief Subscribe an application to an endpoint for messages
  51. *
  52. * \param app_name The name of the \ref stasis application to subscribe to \c endpoint
  53. * \param endpoint The endpoint object to subscribe to
  54. * \param message_received_cb The callback to call when a message is received
  55. * \param pvt An ao2 ref counted object that will be passed to the callback.
  56. *
  57. * \retval 0 subscription was successful
  58. * \retval -1 subscription failed
  59. */
  60. int messaging_app_subscribe_endpoint(const char *app_name, struct ast_endpoint *endpoint, message_received_cb callback, void *pvt);
  61. /*!
  62. * \brief Tidy up the messaging layer
  63. *
  64. * \retval 0 success
  65. * \retval -1 failure
  66. */
  67. int messaging_cleanup(void);
  68. /*!
  69. * \brief Initialize the messaging layer
  70. *
  71. * \retval 0 success
  72. * \retval -1 failure
  73. */
  74. int messaging_init(void);
  75. #endif /* #define _ASTERISK_RES_STASIS_MESSAGING_H */