mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 03:50:31 +00:00
A simplistic router for stasis_message's.
Often times, when subscribing to a topic, one wants to handle different message types differently. While one could cascade if/else statements through the subscription handler, it is much cleaner to specify a different callback for each message type. The stasis_message_router is here to help! A stasis_message_router is constructed for a particular stasis_topic, which is subscribes to. Call stasis_message_router_unsubscribe() to cancel that subscription. Once constructed, routes can be added using stasis_message_router_add() (or stasis_message_router_set_default() for any messages not handled by other routes). There may be only one route per stasis_message_type. The route's callback is invoked just as if it were a callback for a subscription; but it only gets called for messages of the specified type. (issue ASTERISK-20887) Review: https://reviewboard.asterisk.org/r/2390/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@383242 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -46,7 +46,7 @@ static struct ast_threadpool *pool;
|
||||
|
||||
static struct stasis_message_type *__subscription_change_message_type;
|
||||
|
||||
/*! \private */
|
||||
/*! \internal */
|
||||
struct stasis_topic {
|
||||
char *name;
|
||||
/*! Variable length array of the subscribers (raw pointer to avoid cyclic references) */
|
||||
@@ -86,7 +86,7 @@ struct stasis_topic *stasis_topic_create(const char *name)
|
||||
}
|
||||
|
||||
topic->num_subscribers_max = INITIAL_SUBSCRIBERS_MAX;
|
||||
topic->subscribers = ast_calloc(topic->num_subscribers_max, sizeof(topic->subscribers));
|
||||
topic->subscribers = ast_calloc(topic->num_subscribers_max, sizeof(*topic->subscribers));
|
||||
if (!topic->subscribers) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -100,7 +100,7 @@ const char *stasis_topic_name(const struct stasis_topic *topic)
|
||||
return topic->name;
|
||||
}
|
||||
|
||||
/*! \private */
|
||||
/*! \internal */
|
||||
struct stasis_subscription {
|
||||
/*! Unique ID for this subscription */
|
||||
char *uniqueid;
|
||||
@@ -264,7 +264,7 @@ static int topic_add_subscription(struct stasis_topic *topic, struct stasis_subs
|
||||
}
|
||||
|
||||
/*!
|
||||
* \private
|
||||
* \internal
|
||||
* \brief Information needed to dispatch a message to a subscription
|
||||
*/
|
||||
struct dispatch {
|
||||
|
Reference in New Issue
Block a user