diff options
author | David M. Lee <dlee@digium.com> | 2013-05-08 18:34:50 +0000 |
---|---|---|
committer | David M. Lee <dlee@digium.com> | 2013-05-08 18:34:50 +0000 |
commit | 0eb4cf8c194d05214677459feb389f63f60c68af (patch) | |
tree | 86f355afb7bda15fe320192ce9daecffa71bfba2 /include/asterisk/stasis.h | |
parent | 297feffd4ed67a5b72eb28de0f6c7edcd0edb40d (diff) |
Remove required type field from channel blobs
When we first introduced the channel blob types, the JSON blobs were
self identifying by a required "type" field in the JSON object
itself. This, as it turns out, was a bad idea.
When we introduced the message router, it was useless for routing based
on the JSON type. And messages had two type fields to check: the
stasis_message_type() of the message itself, plus the type field in the
JSON blob (but only if it was a blob message).
This patch corrects that mistake by removing the required type field
from JSON blobs, and introducing first class stasis_message_type objects
for the actual message type.
Since we now will have a proliferation of message types, I introduced a
few macros to help reduce the amount of boilerplate necessary to set
them up.
Review: https://reviewboard.asterisk.org/r/2509
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@388005 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk/stasis.h')
-rw-r--r-- | include/asterisk/stasis.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/include/asterisk/stasis.h b/include/asterisk/stasis.h index 48d51e369..da8168746 100644 --- a/include/asterisk/stasis.h +++ b/include/asterisk/stasis.h @@ -543,6 +543,43 @@ struct ao2_container *stasis_cache_dump(struct stasis_caching_topic *caching_top /*! @{ */ /*! + * \brief Boiler-plate removing macro for defining message types. + * + * \param name Name of message type. + * \since 12 + */ +#define STASIS_MESSAGE_TYPE_DEFN(name) \ + static struct stasis_message_type *__ ## name; \ + struct stasis_message_type *name(void) { \ + ast_assert(__ ## name != NULL); \ + return __ ## name; \ + } + +/*! + * \brief Boiler-plate removing macro for initializing message types. + * + * \param name Name of message type. + * \return 0 if initialization is successful. + * \return Non-zero on failure. + * \since 12 + */ +#define STASIS_MESSAGE_TYPE_INIT(name) \ + ({ \ + __ ## name = stasis_message_type_create(#name); \ + __ ## name ? 0 : -1; \ + }) + +#define STASIS_MESSAGE_TYPE_CLEANUP(name) \ + ({ \ + ao2_cleanup(__ ## name); \ + __ ## name = NULL; \ + }) + +/*! @} */ + +/*! @{ */ + +/*! * \brief Initialize the Stasis subsystem * \return 0 on success. * \return Non-zero on error. |