mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-16 14:58:25 +00:00
stasis: Allow filtering by formatter
A subscriber can now indicate that it only wants messages that have formatters of a specific type. For instance, manager can indicate that it only wants messages that have a "to_ami" formatter. You can combine this with the existing filter for message type to get only messages with specific formatters or messages of specific types. ASTERISK-28186 Change-Id: Ifdb7a222a73b6b56c6bb9e4ee93dc8a394a5494c
This commit is contained in:
@@ -302,6 +302,21 @@ enum stasis_subscription_message_filter {
|
||||
STASIS_SUBSCRIPTION_FILTER_SELECTIVE, /*!< Only messages of allowed message types are raised */
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Stasis subscription formatter filters
|
||||
*
|
||||
* There should be an entry here for each member of \ref stasis_message_vtable
|
||||
*
|
||||
* \since 13.25.0
|
||||
* \since 16.2.0
|
||||
*/
|
||||
enum stasis_subscription_message_formatters {
|
||||
STASIS_SUBSCRIPTION_FORMATTER_NONE = 0,
|
||||
STASIS_SUBSCRIPTION_FORMATTER_JSON = 1 << 0, /*!< Allow messages with a to_json formatter */
|
||||
STASIS_SUBSCRIPTION_FORMATTER_AMI = 1 << 1, /*!< Allow messages with a to_ami formatter */
|
||||
STASIS_SUBSCRIPTION_FORMATTER_EVENT = 1 << 2, /*!< Allow messages with a to_event formatter */
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Create a new message type.
|
||||
*
|
||||
@@ -685,6 +700,30 @@ int stasis_subscription_decline_message_type(struct stasis_subscription *subscri
|
||||
int stasis_subscription_set_filter(struct stasis_subscription *subscription,
|
||||
enum stasis_subscription_message_filter filter);
|
||||
|
||||
/*!
|
||||
* \brief Indicate to a subscription that we are interested in messages with one or more formatters.
|
||||
*
|
||||
* \param subscription Subscription to alter.
|
||||
* \param formatters A bitmap of \ref stasis_subscription_message_formatters we wish to receive.
|
||||
*
|
||||
* \since 13.25.0
|
||||
* \since 16.2.0
|
||||
*/
|
||||
void stasis_subscription_accept_formatters(struct stasis_subscription *subscription,
|
||||
enum stasis_subscription_message_formatters formatters);
|
||||
|
||||
/*!
|
||||
* \brief Get a bitmap of available formatters for a message type
|
||||
*
|
||||
* \param message_type Message type
|
||||
* \return A bitmap of \ref stasis_subscription_message_formatters
|
||||
*
|
||||
* \since 13.25.0
|
||||
* \since 16.2.0
|
||||
*/
|
||||
enum stasis_subscription_message_formatters stasis_message_type_available_formatters(
|
||||
const struct stasis_message_type *message_type);
|
||||
|
||||
/*!
|
||||
* \brief Cancel a subscription.
|
||||
*
|
||||
|
||||
@@ -242,4 +242,23 @@ int stasis_message_router_set_default(struct stasis_message_router *router,
|
||||
stasis_subscription_cb callback,
|
||||
void *data);
|
||||
|
||||
/*!
|
||||
* \brief Indicate to a message router that we are interested in messages with one or more formatters.
|
||||
*
|
||||
* The formatters are passed on to the underlying subscription.
|
||||
*
|
||||
* \warning With direct subscriptions, adding a formatter filter is an OR operation
|
||||
* with any message type filters. In the current implementation of message router however,
|
||||
* it's an AND operation. Even when setting a default route, the callback will only get
|
||||
* messages that have the formatters provides in this call.
|
||||
*
|
||||
* \param router Router to set the formatters of.
|
||||
* \param formatters A bitmap of \ref stasis_subscription_message_formatters we wish to receive.
|
||||
*
|
||||
* \since 13.25.0
|
||||
* \since 16.2.0
|
||||
*/
|
||||
void stasis_message_router_accept_formatters(struct stasis_message_router *router,
|
||||
enum stasis_subscription_message_formatters formatters);
|
||||
|
||||
#endif /* _ASTERISK_STASIS_MESSAGE_ROUTER_H */
|
||||
|
||||
Reference in New Issue
Block a user