summaryrefslogtreecommitdiff
path: root/include/asterisk
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2014-01-12 22:07:01 +0000
committerMatthew Jordan <mjordan@digium.com>2014-01-12 22:07:01 +0000
commitf8aaf585a39d496479eb8a4e55f2e327d02b37ca (patch)
treecd9926c9fd134466c6ec6adee3ec7392e4aac754 /include/asterisk
parent60ed8159a10b6eed56095dd52cf17c039cd2275c (diff)
stasis: Add methods to allow for synchronous publishing to subscriber
This patch adds an API call to Stasis that allows a publisher to publish a stasis message that will not return until a specific subscriber handles the message. Since a subscriber can have their own forwarding topic which orders messages from many topics, this allows a publisher who knows of that subscriber to synchronize to that subscriber regardless of the forwarding relationships between topics. This is of particular use for dialplan applications that need to synchronize on a particular subscriber's handling of a message. (issue ASTERISK-22884) Reported by: Matt Jordan Review: https://reviewboard.asterisk.org/r/3099/ ........ Merged revisions 405311 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@405313 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk')
-rw-r--r--include/asterisk/stasis.h33
-rw-r--r--include/asterisk/stasis_message_router.h18
2 files changed, 45 insertions, 6 deletions
diff --git a/include/asterisk/stasis.h b/include/asterisk/stasis.h
index 6bc5171e0..1a420da2f 100644
--- a/include/asterisk/stasis.h
+++ b/include/asterisk/stasis.h
@@ -187,6 +187,12 @@ struct stasis_message_type;
struct stasis_message;
/*!
+ * \brief Opaque type for a Stasis subscription.
+ * \since 12
+ */
+struct stasis_subscription;
+
+/*!
* \brief Structure containing callbacks for Stasis message sanitization
*
* \note If either callback is implemented, both should be implemented since
@@ -377,21 +383,36 @@ const char *stasis_topic_name(const struct stasis_topic *topic);
* \brief Publish a message to a topic's subscribers.
* \param topic Topic.
* \param message Message to publish.
+ *
+ * This call is asynchronous and will return immediately upon queueing
+ * the message for delivery to the topic's subscribers.
+ *
* \since 12
*/
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message);
+/*!
+ * \brief Publish a message to a topic's subscribers, synchronizing
+ * on the specified subscriber
+ * \param sub Subscription to synchronize on.
+ * \param message Message to publish.
+ *
+ * The caller of stasis_publish_sync will block until the specified
+ * subscriber completes handling of the message.
+ *
+ * All other subscribers to the topic the \ref stasis_subpscription
+ * is subscribed to are also delivered the message; this delivery however
+ * happens asynchronously.
+ *
+ * \since 12.1.0
+ */
+void stasis_publish_sync(struct stasis_subscription *sub, struct stasis_message *message);
+
/*! @} */
/*! @{ */
/*!
- * \brief Opaque type for a Stasis subscription.
- * \since 12
- */
-struct stasis_subscription;
-
-/*!
* \brief Callback function type for Stasis subscriptions.
* \param data Data field provided with subscription.
* \param message Published message.
diff --git a/include/asterisk/stasis_message_router.h b/include/asterisk/stasis_message_router.h
index 3209adb16..613a2bd7f 100644
--- a/include/asterisk/stasis_message_router.h
+++ b/include/asterisk/stasis_message_router.h
@@ -93,6 +93,24 @@ void stasis_message_router_unsubscribe_and_join(
int stasis_message_router_is_done(struct stasis_message_router *router);
/*!
+ * \brief Publish a message to a message router's subscription synchronously
+ *
+ * \param router Router
+ * \param message The \ref stasis message
+ *
+ * This should be used when a message needs to be published synchronously to
+ * the underlying subscription created by a message router. This is analagous
+ * to \ref stasis_publish_sync.
+ *
+ * Note that the caller will be blocked until the thread servicing the message
+ * on the message router's subscription completes handling of the message.
+ *
+ * \since 12.1.0
+ */
+void stasis_message_router_publish_sync(struct stasis_message_router *router,
+ struct stasis_message *message);
+
+/*!
* \brief Add a route to a message router.
*
* A particular \a message_type may have at most one route per \a router. If