47 static int message_type_id;
49 static void message_type_dtor(
void *obj)
74 vtable = &null_vtable;
83 type->vtable = vtable;
117 return type->available_formatters;
134 static void stasis_message_dtor(
void *obj)
137 ao2_cleanup(message->
data);
144 if (type == NULL || data == NULL) {
150 if (message == NULL) {
211 #define INVOKE_VIRTUAL(fn, ...) \
216 ast_assert(msg->type != NULL); \
217 ast_assert(msg->type->vtable != NULL); \
218 if (!msg->type->vtable->fn) { \
221 msg->type->vtable->fn(__VA_ARGS__); \
226 return INVOKE_VIRTUAL(to_ami, msg);
233 return INVOKE_VIRTUAL(to_json, msg, sanitize);
238 return INVOKE_VIRTUAL(to_event, msg);
241 #define HAS_VIRTUAL(fn, msg) \
246 ast_assert(msg->type != NULL); \
247 ast_assert(msg->type->vtable != NULL); \
248 !!msg->type->vtable->fn; \
253 return HAS_VIRTUAL(to_ami, msg);
Struct containing info for an AMI event to send out.
int stasis_message_type_declined(const char *name)
Check whether a message type is declined.
Asterisk main include file. File version handling, generic pbx functions.
Virtual table providing methods for messages.
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
Generic (perhaps overly so) hashtable implementation Hash Table support in Asterisk.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define ao2_t_alloc_options(data_size, destructor_fn, options, debug_msg)
Allocate and initialize an object.
#define ast_strdup(str)
A wrapper for strdup()
struct ast_event *(* to_event)(struct stasis_message *message)
Build the ast_event representation of the message.
const struct ast_eid * stasis_message_eid(const struct stasis_message *msg)
Get the entity id for a stasis_message.
struct ast_manager_event_blob * stasis_message_to_ami(struct stasis_message *msg)
Build the AMI representation of the message.
An Entity ID is essentially a MAC address, brief and unique.
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
Structure containing callbacks for Stasis message sanitization.
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct stasis_message_type * type
struct ast_json *(* to_json)(struct stasis_message *message, const struct stasis_message_sanitizer *sanitize)
Build the JSON representation of the message.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
const char * stasis_message_type_name(const struct stasis_message_type *type)
Gets the name of a given message type.
int stasis_message_can_be_ami(struct stasis_message *msg)
Determine if the given message can be converted to AMI.
struct stasis_message * stasis_message_create_full(struct stasis_message_type *type, void *data, const struct ast_eid *eid)
Create a new message for an entity.
enum stasis_subscription_message_formatters stasis_message_type_available_formatters(const struct stasis_message_type *type)
Get a bitmap of available formatters for a message type.
struct ast_json * stasis_message_to_json(struct stasis_message *msg, struct stasis_message_sanitizer *sanitize)
Build the JSON representation of the message.
enum stasis_message_type_result stasis_message_type_create(const char *name, struct stasis_message_vtable *vtable, struct stasis_message_type **result)
Create a new message type.
struct ast_manager_event_blob *(* to_ami)(struct stasis_message *message)
Build the AMI representation of the message.
unsigned int ast_hashtab_hash_string(const void *obj)
Hashes a string to a number.
struct stasis_message_type * stasis_message_type(const struct stasis_message *msg)
Get the message type for a stasis_message.
struct ast_eid ast_eid_default
Global EID.
const struct timeval * stasis_message_timestamp(const struct stasis_message *msg)
Get the time when a message was created.
unsigned int stasis_message_type_hash(const struct stasis_message_type *type)
Gets the hash of a given message type.
Abstract JSON element (object, array, string, int, ...).
const struct ast_eid * eid_ptr
int stasis_message_type_id(const struct stasis_message_type *type)
Gets the id of a given message type.
stasis_message_type_result
Return code for Stasis message type creation attempts.
stasis_subscription_message_formatters
Stasis subscription formatter filters.
struct ast_event * stasis_message_to_event(struct stasis_message *msg)
Build the Generic event system representation of the message.