mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-17 15:29:05 +00:00
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
This commit is contained in:
@@ -186,6 +186,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
|
||||
*
|
||||
@@ -377,20 +383,35 @@ 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.
|
||||
|
||||
@@ -92,6 +92,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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user