mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +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:
@@ -40,6 +40,7 @@ struct stasis_message_type {
|
||||
char *name;
|
||||
unsigned int hash;
|
||||
int id;
|
||||
enum stasis_subscription_message_formatters available_formatters;
|
||||
};
|
||||
|
||||
static struct stasis_message_vtable null_vtable = {};
|
||||
@@ -80,6 +81,15 @@ int stasis_message_type_create(const char *name,
|
||||
}
|
||||
type->hash = ast_hashtab_hash_string(name);
|
||||
type->vtable = vtable;
|
||||
if (vtable->to_json) {
|
||||
type->available_formatters |= STASIS_SUBSCRIPTION_FORMATTER_JSON;
|
||||
}
|
||||
if (vtable->to_ami) {
|
||||
type->available_formatters |= STASIS_SUBSCRIPTION_FORMATTER_AMI;
|
||||
}
|
||||
if (vtable->to_event) {
|
||||
type->available_formatters |= STASIS_SUBSCRIPTION_FORMATTER_EVENT;
|
||||
}
|
||||
type->id = ast_atomic_fetchadd_int(&message_type_id, +1);
|
||||
*result = type;
|
||||
|
||||
@@ -101,6 +111,12 @@ int stasis_message_type_id(const struct stasis_message_type *type)
|
||||
return type->id;
|
||||
}
|
||||
|
||||
enum stasis_subscription_message_formatters stasis_message_type_available_formatters(
|
||||
const struct stasis_message_type *type)
|
||||
{
|
||||
return type->available_formatters;
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
struct stasis_message {
|
||||
/*! Time the message was created */
|
||||
|
Reference in New Issue
Block a user