diff options
author | Kinsey Moore <kmoore@digium.com> | 2013-04-16 15:33:59 +0000 |
---|---|---|
committer | Kinsey Moore <kmoore@digium.com> | 2013-04-16 15:33:59 +0000 |
commit | 191cf99ae1f821dec98199931fc775fc0716d27c (patch) | |
tree | 210b5ebfaf3f30fa06c666e8d99e93e9918253a5 /include | |
parent | c1ae5dc49be01a567b403306ee4b560391293f67 (diff) |
Move device state distribution to Stasis-core
In the move from Asterisk's event system to Stasis, this makes
distributed device state aggregation always-on, removes unnecessary
task processors where possible, and collapses aggregate and
non-aggregate states into a single cache for ease of retrieval. This
also removes an intermediary step in device state aggregation.
Review: https://reviewboard.asterisk.org/r/2389/
(closes issue ASTERISK-21101)
Patch-by: Kinsey Moore <kmoore@digium.com>
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@385860 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk/devicestate.h | 93 | ||||
-rw-r--r-- | include/asterisk/xmpp.h | 3 |
2 files changed, 83 insertions, 13 deletions
diff --git a/include/asterisk/devicestate.h b/include/asterisk/devicestate.h index 86740bc2f..2b3353ffd 100644 --- a/include/asterisk/devicestate.h +++ b/include/asterisk/devicestate.h @@ -38,6 +38,7 @@ #define _ASTERISK_DEVICESTATE_H #include "asterisk/channelstate.h" +#include "asterisk/utils.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { @@ -270,19 +271,87 @@ struct ast_devstate_aggregate { }; /*! - * \brief Enable distributed device state processing. - * - * \details - * By default, Asterisk assumes that device state change events will only be - * originating from one instance. If a module gets loaded and configured such - * that multiple instances of Asterisk will be sharing device state, this - * function should be called to enable distributed device state processing. - * It is off by default to save on unnecessary processing. - * - * \retval 0 success - * \retval -1 failure + * \brief The structure that contains device state + * \since 12 + */ +struct ast_device_state_message { + AST_DECLARE_STRING_FIELDS( + AST_STRING_FIELD(cache_id); /*!< A unique ID used for hashing */ + AST_STRING_FIELD(device); /*!< The name of the device */ + ); + enum ast_device_state state; /*!< The state of the device */ + struct ast_eid *eid; /*!< The EID of the server where this message originated, NULL EID means aggregate state */ + enum ast_devstate_cache cachable; /*!< Flag designating the cachability of this device state */ +}; + +/*! + * \brief Get the Stasis topic for device state messages + * \retval The topic for device state messages + * \retval NULL if it has not been allocated + * \since 12 + */ +struct stasis_topic *ast_device_state_topic_all(void); + +/*! + * \brief Get the Stasis topic for device state messages for a specific device + * \param uniqueid The device for which to get the topic + * \retval The topic structure for MWI messages for a given device + * \retval NULL if it failed to be found or allocated + * \since 12 + */ +struct stasis_topic *ast_device_state_topic(const char *device); + +/*! + * \brief Get the Stasis caching topic for device state messages + * \retval The caching topic for device state messages + * \retval NULL if it has not been allocated + * \since 12 + */ +struct stasis_caching_topic *ast_device_state_topic_cached(void); + +/*! + * \brief Get the Stasis message type for device state messages + * \retval The message type for device state messages + * \retval NULL if it has not been allocated + * \since 12 + */ +struct stasis_message_type *ast_device_state_message_type(void); + +/*! + * \brief Initialize the device state core + * \retval 0 Success + * \retval -1 Failure + * \since 12 + */ +int devstate_init(void); + +/*! + * \brief Publish a device state update + * \param[in] device The device name + * \param[in] state The state of the device + * \param[in] cachable Whether the device state can be cached + * \retval 0 Success + * \retval -1 Failure + * \since 12 + */ +#define ast_publish_device_state(device, state, cachable) \ + ast_publish_device_state_full(device, state, cachable, &ast_eid_default) + +/*! + * \brief Publish a device state update with EID + * \param[in] device The device name + * \param[in] state The state of the device + * \param[in] cachable Whether the device state can be cached + * \param[in] eid The EID of the server that originally published the message + * \retval 0 Success + * \retval -1 Failure + * \since 12 */ -int ast_enable_distributed_devstate(void); +int ast_publish_device_state_full( + const char *device, + enum ast_device_state state, + enum ast_devstate_cache cachable, + struct ast_eid *eid); #if defined(__cplusplus) || defined(c_plusplus) } diff --git a/include/asterisk/xmpp.h b/include/asterisk/xmpp.h index 6833b6cce..6d14b1115 100644 --- a/include/asterisk/xmpp.h +++ b/include/asterisk/xmpp.h @@ -47,6 +47,7 @@ #include "asterisk/linkedlists.h" #include "asterisk/stringfields.h" #include "asterisk/pbx.h" +#include "asterisk/stasis.h" /* * As per RFC 3920 - section 3.1, the maximum length for a full Jabber ID @@ -135,7 +136,7 @@ struct ast_xmpp_client { int timeout; unsigned int reconnect:1; /*!< Reconnect this client */ struct stasis_subscription *mwi_sub; /*!< If distributing event information the MWI subscription */ - struct ast_event_sub *device_state_sub; /*!< If distributing event information the device state subscription */ + struct stasis_subscription *device_state_sub; /*!< If distributing event information the device state subscription */ }; /*! |