Asterisk - The Open Source Telephony Project
18.5.0
|
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... | |
int | 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.
#define HAS_VIRTUAL | ( | fn, | |
msg | |||
) |
Definition at line 241 of file stasis_message.c.
Referenced by stasis_message_can_be_ami().
#define INVOKE_VIRTUAL | ( | fn, | |
... | |||
) |
Definition at line 211 of file stasis_message.c.
Referenced by stasis_message_to_ami(), stasis_message_to_event(), and stasis_message_to_json().
|
static |
Definition at line 49 of file stasis_message.c.
References ast_free, stasis_message_type::name, NULL, and type.
Referenced by stasis_message_type_create().
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.
References HAS_VIRTUAL, and to_ami().
Referenced by manager_default_msg_cb().
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 errorDefinition at line 174 of file stasis_message.c.
References ast_eid_default, and stasis_message_create_full().
Referenced by __ast_test_suite_event_notify(), aoc_publish_blob(), 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_dial_internal(), 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(), AST_TEST_DEFINE(), bridge_publish_state_from_blob(), bridge_topics_destroy(), cc_publish(), cdr_prop_write(), cdr_read(), cdr_write(), create_channel_blob_message(), create_endpoint_snapshot_message(), endpoint_publish_snapshot(), forkcdr_exec(), handle_security_event(), local_optimization_finished_cb(), local_optimization_started_cb(), presence_state_event(), publish_acl_change(), publish_app_cdr_message(), publish_chanspy_message(), publish_cluster_discovery_to_stasis_full(), publish_corosync_ping_to_stasis(), publish_format_update(), publish_hint_change(), publish_hint_remove(), publish_load_message_type(), publish_local_bridge_message(), publish_parked_call(), publish_parked_call_failure(), queue_publish_member_blob(), queue_publish_multi_channel_snapshot_blob(), send_call_pickup_stasis_message(), send_msg(), send_start_msg_snapshots(), send_subscription_subscribe(), send_subscription_unsubscribe(), stasis_app_user_event(), stasis_cache_clear_create(), stasis_test_message_create(), stun_monitor_request(), and update_create().
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 |
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_type::name, NULL, stasis_message_dtor(), stasis_message::timestamp, type, and stasis_message::type.
Referenced by ast_publish_device_state_full(), AST_TEST_DEFINE(), cache_test_message_create_full(), create_foo_type_message(), device_state_aggregate_calc(), mwi_state_create_message(), 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, and NULL.
Referenced by agent_login_to_ami(), agent_logoff_to_ami(), agi_channel_to_ami(), aoc_to_ami(), appcdr_callback(), ast_ari_endpoints_list(), ast_ari_endpoints_list_by_tech(), ast_bridge_merge_message_to_json(), ast_bridge_publish_enter(), ast_bridge_publish_leave(), ast_channel_entered_bridge_to_json(), ast_channel_left_bridge_to_json(), ast_delete_mwi_state_full(), ast_endpoint_latest_snapshot(), ast_mwi_publish_by_mailbox(), AST_TEST_DEFINE(), asterisk_publisher_devstate_cb(), asterisk_publisher_mwistate_cb(), attended_transfer_to_ami(), attended_transfer_to_json(), blind_transfer_to_ami(), blind_transfer_to_json(), bridge_attended_transfer_handler(), bridge_blind_transfer_handler(), bridge_merge_cb(), bridge_merge_handler(), bridge_snapshot_update(), cache_test_aggregate_calc_fn(), cache_test_data_id(), cache_update(), cache_update_cb(), caching_topic_exec(), call_forwarded_handler(), call_pickup_to_ami(), cc_available_to_ami(), cc_callerrecalling_to_ami(), cc_callerstartmonitoring_to_ami(), cc_callerstopmonitoring_to_ami(), cc_failure_to_ami(), cc_monitorfailed_to_ami(), cc_offertimerstart_to_ami(), cc_recallcomplete_to_ami(), cc_requestacknowledged_to_ami(), cc_requested_to_ami(), cdr_prop_write_callback(), cdr_read_callback(), cdr_write_callback(), cel_attended_transfer_cb(), cel_blind_transfer_cb(), cel_bridge_enter_cb(), cel_bridge_leave_cb(), cel_dial_cb(), cel_generic_cb(), cel_local_cb(), cel_parking_cb(), cel_pickup_cb(), cel_snapshot_update_cb(), channel_blob_to_json(), channel_chanspy_start_cb(), channel_chanspy_stop_cb(), channel_dial_cb(), channel_dtmf_begin_cb(), channel_dtmf_end_cb(), channel_enter_cb(), channel_fax_cb(), channel_flash_cb(), channel_hangup_handler_cb(), channel_hangup_request_cb(), channel_hold_cb(), channel_leave_cb(), channel_mixmonitor_mute_cb(), channel_mixmonitor_start_cb(), channel_mixmonitor_stop_cb(), channel_moh_start_cb(), channel_moh_stop_cb(), channel_monitor_start_cb(), channel_monitor_stop_cb(), channel_snapshot_update(), channel_unhold_cb(), check_cache_aggregate(), conf_send_event_to_participants(), confbridge_atxfer_cb(), confbridge_publish_manager_event(), confbridge_talking_cb(), consumer_exec(), contactstatus_to_ami(), contactstatus_to_json(), corosync_ping_to_event(), dahdichannel_to_ami(), device_state_aggregate_calc(), device_state_cb(), device_state_get_id(), devstate_cached(), devstate_change_cb(), devstate_to_ami(), devstate_to_event(), dial_to_json(), dtmf_end_to_json(), dump_cache_load(), dump_cache_unload(), dump_consumer(), endpoint_cache_clear(), endpoint_snapshot_get_id(), endpoints_scrape_cb(), explicit_publish_cb(), fake_ami(), fake_json(), find_route(), forkcdr_callback(), generic_agent_devstate_cb(), generic_monitor_devstate_cb(), get_bool_header(), get_cached_mwi(), handle_attended_transfer(), handle_blind_transfer(), handle_bridge_enter(), handle_bridge_enter_message(), handle_bridge_leave_message(), handle_channel_snapshot_update_message(), handle_dial_message(), handle_hangup(), handle_hint_change_message_type(), handle_local_optimization_begin(), handle_local_optimization_end(), handle_masquerade(), handle_mwi_state(), handle_parked_call_message(), has_voicemail(), hold_to_json(), implicit_publish_cb(), is_msg(), local_message_to_ami(), manager_generic_msg_cb(), meetme_stasis_cb(), moh_post_start(), moh_post_stop(), multi_user_event_to_ami(), multi_user_event_to_json(), mwi_app_event_cb(), mwi_event_cb(), mwi_startup_event_cb(), mwi_state_get_id(), mwi_to_event(), mwi_update_cb(), park_announce_update_cb(), parker_update_cb(), parking_event_cb(), peerstatus_to_ami(), peerstatus_to_json(), playback_to_json(), presence_state_cached(), presence_state_cb(), presence_state_get_id(), presence_state_to_ami(), queue_agent_cb(), queue_channel_to_ami(), queue_member_to_ami(), queue_multi_channel_to_ami(), recording_to_json(), refer_progress_bridge(), registry_message_cb(), remove_device_states_cb(), rtcp_report_to_ami(), rtcp_report_to_json(), security_event_to_ami(), security_stasis_cb(), session_timeout_to_ami(), startup_event_cb(), stasis_end_to_json(), stasis_start_to_json(), stasis_state_subscriber_data(), stasis_subscription_final_message(), sub_bridge_update_handler(), sub_channel_update_handler(), sub_endpoint_update_handler(), subscription_persistence_event_cb(), system_registry_to_ami(), talking_start_to_ami(), talking_stop_to_ami(), test_cb(), test_suite_event_to_ami(), unhold_to_json(), unistim_send_mwi_to_peer(), update_registry(), updates(), varset_to_ami(), xmpp_pubsub_devstate_cb(), and xmpp_pubsub_mwi_cb().
|
static |
Definition at line 134 of file stasis_message.c.
References ao2_cleanup, and stasis_message::data.
Referenced by stasis_message_create_full().
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 |
Definition at line 179 of file stasis_message.c.
References stasis_message::eid_ptr, and NULL.
Referenced by AST_TEST_DEFINE(), cache_entry_by_eid(), cache_entry_create(), cache_remove(), cache_udpate(), caching_topic_exec(), and clear_node_cache().
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 NULL, and stasis_message::timestamp.
Referenced by ast_bridge_merge_message_to_json(), ast_channel_entered_bridge_to_json(), ast_channel_left_bridge_to_json(), AST_TEST_DEFINE(), attended_transfer_to_json(), blind_transfer_to_json(), cel_attended_transfer_cb(), cel_blind_transfer_cb(), cel_bridge_enter_cb(), cel_bridge_leave_cb(), cel_dial_cb(), cel_generic_cb(), cel_local_cb(), cel_parking_cb(), cel_pickup_cb(), cel_snapshot_update_cb(), channel_blob_to_json(), contactstatus_to_json(), dial_to_json(), dtmf_end_to_json(), handle_bridge_enter_message(), handle_bridge_leave_message(), handle_channel_snapshot_update_message(), handle_dial_message(), handle_parked_call_message(), hold_to_json(), multi_user_event_to_json(), pack_bridge_and_channels(), peerstatus_to_json(), playback_to_json(), recording_to_json(), sub_bridge_update_handler(), sub_channel_update_handler(), sub_endpoint_update_handler(), unhold_to_json(), and updates().
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
on error. NULL
if AMI format is not supported. Definition at line 224 of file stasis_message.c.
References INVOKE_VIRTUAL, and to_ami().
Referenced by action_devicestatelist(), action_presencestatelist(), AST_TEST_DEFINE(), and manager_default_msg_cb().
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
on error. NULL
if AMI format is not supported. Definition at line 236 of file stasis_message.c.
References INVOKE_VIRTUAL.
Referenced by publish_to_corosync().
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
on error. NULL
if JSON format is not supported. Definition at line 229 of file stasis_message.c.
References INVOKE_VIRTUAL.
Referenced by AST_TEST_DEFINE(), rtcp_message_handler(), and sub_default_handler().
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 NULL, and stasis_message::type.
Referenced by acl_change_stasis_cb(), appcdr_callback(), AST_TEST_DEFINE(), asterisk_publisher_devstate_cb(), asterisk_publisher_mwistate_cb(), cache_entry_create(), cache_put(), cache_simple(), cache_test_aggregate_calc_fn(), cache_test_data_id(), cache_update(), caching_topic_exec(), cdr_prop_write_callback(), cdr_read_callback(), cdr_write_callback(), conf_send_event_to_participants(), confbridge_publish_manager_event(), device_state_cb(), device_state_get_id(), devstate_change_cb(), dispatch_message(), dump_consumer(), endpoint_snapshot_get_id(), find_route(), forkcdr_callback(), generic_agent_devstate_cb(), generic_monitor_devstate_cb(), handle_hint_change_message_type(), is_msg(), local_message_to_ami(), meetme_stasis_cb(), message_sink_cb(), mwi_event_cb(), mwi_startup_event_cb(), mwi_stasis_cb(), mwi_state_get_id(), mwi_update_cb(), network_change_stasis_cb(), pack_bridge_and_channels(), park_announce_update_cb(), parker_update_cb(), parking_event_cb(), presence_state_cb(), presence_state_get_id(), publish_msg(), queue_agent_cb(), refer_progress_bridge(), rtcp_report_to_ami(), rtp_topic_handler(), security_event_to_ami(), security_stasis_cb(), startup_event_cb(), stasis_subscription_final_message(), statsmaker(), sub_default_handler(), sub_endpoint_update_handler(), subscription_invoke(), subscription_persistence_event_cb(), test_cb(), update_create(), 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.
References stasis_message_type::available_formatters.
Referenced by dispatch_message().
int 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_cleanup, ao2_t_alloc_options, ast_atomic_fetchadd_int(), ast_hashtab_hash_string(), ast_strdup, stasis_message_type::available_formatters, stasis_message_type::hash, stasis_message_type::id, message_type_dtor(), message_type_id, stasis_message_type::name, null_vtable, 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, stasis_message_vtable::to_json, type, and stasis_message_type::vtable.
Referenced by AST_TEST_DEFINE(), and create_message_types().
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.
References stasis_message_type::hash.
Referenced by cache_entry_compute_hash().
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.
References stasis_message_type::id.
Referenced by dispatch_message(), publish_msg(), 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.
References stasis_message_type::name.
Referenced by AST_TEST_DEFINE(), cache_find(), cache_simple(), cache_test_data_id(), caching_topic_exec(), dump_consumer(), print_cache_entry(), send_msg(), stasis_subscription_accept_message_type(), stasis_subscription_decline_message_type(), statistics_show_messages(), statistics_show_subscription(), and statsmaker().
|
static |
Definition at line 47 of file stasis_message.c.
Referenced by publish_msg(), stasis_message_type_create(), and subscription_invoke().
|
static |
Definition at line 46 of file stasis_message.c.
Referenced by stasis_message_type_create().