Asterisk - The Open Source Telephony Project
21.4.1
|
Stasis Message API. More...
#include "asterisk.h"
#include "asterisk/astobj2.h"
#include "asterisk/stasis.h"
#include "asterisk/utils.h"
#include "asterisk/hashtab.h"
Go to the source code of this file.
Data Structures | |
struct | stasis_message |
struct | stasis_message_type |
Macros | |
#define | HAS_VIRTUAL(fn, msg) |
#define | INVOKE_VIRTUAL(fn, ...) |
Functions | |
static void | message_type_dtor (void *obj) |
int | stasis_message_can_be_ami (struct stasis_message *msg) |
Determine if the given message can be converted to AMI. More... | |
struct stasis_message * | stasis_message_create (struct stasis_message_type *type, void *data) |
Create a new message. More... | |
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. More... | |
void * | stasis_message_data (const struct stasis_message *msg) |
Get the data contained in a message. More... | |
static void | stasis_message_dtor (void *obj) |
const struct ast_eid * | stasis_message_eid (const struct stasis_message *msg) |
Get the entity id for a stasis_message. More... | |
const struct timeval * | stasis_message_timestamp (const struct stasis_message *msg) |
Get the time when a message was created. More... | |
struct ast_manager_event_blob * | stasis_message_to_ami (struct stasis_message *msg) |
Build the AMI representation of the message. More... | |
struct ast_event * | stasis_message_to_event (struct stasis_message *msg) |
Build the Generic event system representation of the message. More... | |
struct ast_json * | stasis_message_to_json (struct stasis_message *msg, struct stasis_message_sanitizer *sanitize) |
Build the JSON representation of the message. More... | |
struct stasis_message_type * | stasis_message_type (const struct stasis_message *msg) |
Get the message type for a stasis_message. More... | |
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. More... | |
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. More... | |
unsigned int | stasis_message_type_hash (const struct stasis_message_type *type) |
Gets the hash of a given message type. More... | |
int | stasis_message_type_id (const struct stasis_message_type *type) |
Gets the id of a given message type. More... | |
const char * | stasis_message_type_name (const struct stasis_message_type *type) |
Gets the name of a given message type. More... | |
Variables | |
static int | message_type_id |
static struct stasis_message_vtable | null_vtable = {} |
Stasis Message API.
Definition in file stasis_message.c.
int stasis_message_can_be_ami | ( | struct stasis_message * | msg | ) |
Determine if the given message can be converted to AMI.
msg | Message to see if can be converted to AMI. |
0 | Cannot be converted |
non-zero | Can be converted |
Definition at line 251 of file stasis_message.c.
struct stasis_message* stasis_message_create | ( | struct stasis_message_type * | type, |
void * | data | ||
) |
Create a new message.
This message is an ao2
object, and must be ao2_cleanup()'ed when you are done with it. Messages are also immutable, and must not be modified after they are initialized. Especially the data in the message.
type | Type of the message |
data | Immutable data that is the actual contents of the message |
NULL | on error |
Definition at line 174 of file stasis_message.c.
References ast_eid_default, and stasis_message_create_full().
Referenced by ast_bridge_blob_create(), ast_bridge_blob_create_from_snapshots(), ast_bridge_publish_attended_transfer(), ast_bridge_publish_blind_transfer(), ast_bridge_publish_merge(), ast_bridge_publish_state(), ast_cdr_engine_term(), ast_channel_publish_final_snapshot(), ast_channel_publish_snapshot(), ast_endpoint_blob_create(), ast_manager_publish_event(), ast_multi_object_blob_single_channel_publish(), ast_mwi_blob_create(), ast_rtp_publish_rtcp_message(), ast_system_publish_registry(), local_optimization_finished_cb(), local_optimization_started_cb(), publish_cluster_discovery_to_stasis_full(), publish_corosync_ping_to_stasis(), publish_hint_change(), publish_hint_remove(), publish_load_message_type(), publish_parked_call(), publish_parked_call_failure(), stasis_app_user_event(), stasis_cache_clear_create(), stasis_test_message_create(), and stun_monitor_request().
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.
This message is an ao2
object, and must be ao2_cleanup()'ed when you are done with it. Messages are also immutable, and must not be modified after they are initialized. Especially the data in the message.
type | Type of the message |
data | Immutable data that is the actual contents of the message |
eid | What entity originated this message. (NULL for aggregate) |
New | message |
NULL | on error |
Definition at line 140 of file stasis_message.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_ref, ao2_t_alloc_options, ast_tvnow(), stasis_message::data, stasis_message::eid, stasis_message::eid_ptr, stasis_message::timestamp, and stasis_message::type.
Referenced by ast_publish_device_state_full(), and stasis_message_create().
void* stasis_message_data | ( | const struct stasis_message * | msg | ) |
Get the data contained in a message.
msg | Message. |
NULL | if msg is NULL . |
Definition at line 195 of file stasis_message.c.
References stasis_message::data.
Referenced by ast_ari_endpoints_list(), ast_ari_endpoints_list_by_tech(), ast_bridge_publish_enter(), ast_bridge_publish_leave(), ast_delete_mwi_state_full(), ast_endpoint_latest_snapshot(), ast_mwi_publish_by_mailbox(), cache_update(), channel_dial_cb(), conf_send_event_to_participants(), corosync_ping_to_event(), device_state_cb(), devstate_to_event(), endpoint_cache_clear(), endpoint_snapshot_get_id(), handle_attended_transfer(), handle_blind_transfer(), handle_bridge_leave_message(), handle_channel_snapshot_update_message(), handle_dial_message(), handle_parked_call_message(), mwi_app_event_cb(), stasis_state_subscriber_data(), stasis_subscription_final_message(), update_registry(), xmpp_pubsub_devstate_cb(), and xmpp_pubsub_mwi_cb().
const struct ast_eid* stasis_message_eid | ( | const struct stasis_message * | msg | ) |
Get the entity id for a stasis_message.
msg | Message to get eid. |
Entity | id of msg |
NULL | if msg is an aggregate or msg is NULL . |
Definition at line 179 of file stasis_message.c.
References stasis_message::eid_ptr.
const struct timeval* stasis_message_timestamp | ( | const struct stasis_message * | msg | ) |
Get the time when a message was created.
msg | Message. |
NULL | if msg is NULL . |
Definition at line 203 of file stasis_message.c.
References stasis_message::timestamp.
Referenced by handle_bridge_leave_message(), handle_channel_snapshot_update_message(), handle_dial_message(), and handle_parked_call_message().
struct ast_manager_event_blob* stasis_message_to_ami | ( | struct stasis_message * | msg | ) |
Build the AMI representation of the message.
May return NULL
, to indicate no representation. The returned object should be ao2_cleanup()'ed.
msg | Message to convert to AMI. |
NULL | if AMI format is not supported. |
Definition at line 224 of file stasis_message.c.
struct ast_event* stasis_message_to_event | ( | struct stasis_message * | msg | ) |
Build the Generic event system representation of the message.
May return NULL
, to indicate no representation. The returned object should be disposed of via ast_event_destroy.
msg | Message to convert to AMI. |
NULL | if AMI format is not supported. |
Definition at line 236 of file stasis_message.c.
struct ast_json* stasis_message_to_json | ( | struct stasis_message * | msg, |
struct stasis_message_sanitizer * | sanitize | ||
) |
Build the JSON representation of the message.
May return NULL
, to indicate no representation. The returned object should be ast_json_unref()'ed.
msg | Message to convert to JSON string. |
sanitize | Snapshot sanitization callback. |
NULL | if JSON format is not supported. |
Definition at line 229 of file stasis_message.c.
struct stasis_message_type* stasis_message_type | ( | const struct stasis_message * | msg | ) |
Get the message type for a stasis_message.
msg | Message to type |
NULL | if msg is NULL . |
Definition at line 187 of file stasis_message.c.
References stasis_message::type.
Referenced by cache_update(), conf_send_event_to_participants(), device_state_cb(), endpoint_snapshot_get_id(), message_sink_cb(), rtp_reload(), stasis_subscription_final_message(), subscription_invoke(), xmpp_pubsub_devstate_cb(), and xmpp_pubsub_mwi_cb().
enum stasis_subscription_message_formatters stasis_message_type_available_formatters | ( | const struct stasis_message_type * | message_type | ) |
Get a bitmap of available formatters for a message type.
message_type | Message type |
Definition at line 114 of file stasis_message.c.
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.
stasis_message_type is an AO2 object, so ao2_cleanup() when you're done with it.
name | Name of the new type. | |
vtable | Virtual table of message methods. May be NULL . | |
[out] | result | The location where the new message type will be placed |
Definition at line 56 of file stasis_message.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_t_alloc_options, ast_atomic_fetchadd_int(), ast_hashtab_hash_string(), ast_strdup, STASIS_MESSAGE_TYPE_DECLINED, stasis_message_type_declined(), STASIS_MESSAGE_TYPE_ERROR, STASIS_MESSAGE_TYPE_SUCCESS, STASIS_SUBSCRIPTION_FORMATTER_AMI, STASIS_SUBSCRIPTION_FORMATTER_EVENT, STASIS_SUBSCRIPTION_FORMATTER_JSON, stasis_message_vtable::to_ami, stasis_message_vtable::to_event, and stasis_message_vtable::to_json.
unsigned int stasis_message_type_hash | ( | const struct stasis_message_type * | type | ) |
Gets the hash of a given message type.
type | The type to get the hash of. |
Definition at line 104 of file stasis_message.c.
int stasis_message_type_id | ( | const struct stasis_message_type * | type | ) |
Gets the id of a given message type.
type | The type to get the id of. |
Definition at line 109 of file stasis_message.c.
Referenced by stasis_subscription_accept_message_type(), stasis_subscription_decline_message_type(), and subscription_invoke().
const char* stasis_message_type_name | ( | const struct stasis_message_type * | type | ) |
Gets the name of a given message type.
type | The type to get. |
NULL | if type is NULL . |
Definition at line 99 of file stasis_message.c.
Referenced by stasis_subscription_accept_message_type(), and stasis_subscription_decline_message_type().