mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-10 06:49:40 +00:00
stasis: Add internal filtering of messages.
This change adds the ability for subscriptions to indicate which message types they are interested in accepting. By doing so the filtering is done before being dispatched to the subscriber, reducing the amount of work that has to be done. This is optional and if a subscriber does not add message types they wish to accept and set the subscription to selective filtering the previous behavior is preserved and they receive all messages. There is also the ability to explicitly force the reception of all messages for cases such as AMI or ARI where a large number of messages are expected that are then generically converted into a different format. ASTERISK-28103 Change-Id: I99bee23895baa0a117985d51683f7963b77aa190
This commit is contained in:
@@ -39,9 +39,11 @@ struct stasis_message_type {
|
||||
struct stasis_message_vtable *vtable;
|
||||
char *name;
|
||||
unsigned int hash;
|
||||
int id;
|
||||
};
|
||||
|
||||
static struct stasis_message_vtable null_vtable = {};
|
||||
static int message_type_id;
|
||||
|
||||
static void message_type_dtor(void *obj)
|
||||
{
|
||||
@@ -78,6 +80,7 @@ int stasis_message_type_create(const char *name,
|
||||
}
|
||||
type->hash = ast_hashtab_hash_string(name);
|
||||
type->vtable = vtable;
|
||||
type->id = ast_atomic_fetchadd_int(&message_type_id, +1);
|
||||
*result = type;
|
||||
|
||||
return STASIS_MESSAGE_TYPE_SUCCESS;
|
||||
@@ -93,6 +96,11 @@ unsigned int stasis_message_type_hash(const struct stasis_message_type *type)
|
||||
return type->hash;
|
||||
}
|
||||
|
||||
int stasis_message_type_id(const struct stasis_message_type *type)
|
||||
{
|
||||
return type->id;
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
struct stasis_message {
|
||||
/*! Time the message was created */
|
||||
|
Reference in New Issue
Block a user