diff options
author | Matthew Jordan <mjordan@digium.com> | 2013-03-30 05:06:54 +0000 |
---|---|---|
committer | Matthew Jordan <mjordan@digium.com> | 2013-03-30 05:06:54 +0000 |
commit | e8015cc4603773288525508fc4635993efc654ce (patch) | |
tree | b0723a48cab61cecd2b8ba081d89e1205ef0e3db /main/manager.c | |
parent | d16efd5be89892f00465241ad8a83d7ea542f585 (diff) |
Convert TestEvent AMI events over to Stasis Core
This patch migrates the TestEvent AMI events to first be dispatched over the
Stasis-Core message bus. This helps to preserve the ordering of the events
with other events in the AMI system, such as the various channel related
events.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@384389 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/manager.c')
-rw-r--r-- | main/manager.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/main/manager.c b/main/manager.c index fdc85424b..eb4fd0649 100644 --- a/main/manager.c +++ b/main/manager.c @@ -92,6 +92,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/stringfields.h" #include "asterisk/presencestate.h" #include "asterisk/stasis.h" +#include "asterisk/test.h" +#include "asterisk/json.h" /*** DOCUMENTATION <manager name="Ping" language="en_US"> @@ -7343,6 +7345,50 @@ static void load_channelvars(struct ast_variable *var) ast_channel_set_manager_vars(args.argc, args.vars); } +#ifdef TEST_FRAMEWORK + +static void test_suite_event_cb(void *data, struct stasis_subscription *sub, + struct stasis_topic *topic, + struct stasis_message *message) +{ + struct ast_test_suite_message_payload *payload; + struct ast_json *blob; + const char *type; + + if (stasis_message_type(message) != ast_test_suite_message_type()) { + return; + } + + payload = stasis_message_data(message); + if (!payload) { + return; + } + blob = ast_test_suite_get_blob(payload); + if (!blob) { + return; + } + + type = ast_json_string_get(ast_json_object_get(blob, "type")); + if (ast_strlen_zero(type) || strcmp("testevent", type)) { + return; + } + + manager_event(EVENT_FLAG_TEST, "TestEvent", + "Type: StateChange\r\n" + "State: %s\r\n" + "AppFile: %s\r\n" + "AppFunction: %s\r\n" + "AppLine: %ld\r\n" + "%s\r\n", + ast_json_string_get(ast_json_object_get(blob, "state")), + ast_json_string_get(ast_json_object_get(blob, "appfile")), + ast_json_string_get(ast_json_object_get(blob, "appfunction")), + ast_json_integer_get(ast_json_object_get(blob, "line")), + ast_json_string_get(ast_json_object_get(blob, "data"))); +} + +#endif + /*! \internal \brief Free a user record. Should already be removed from the list */ static void manager_free_user(struct ast_manager_user *user) { @@ -7499,6 +7545,10 @@ static int __init_manager(int reload, int by_external_config) ast_manager_register_xml_core("AOCMessage", EVENT_FLAG_AOC, action_aocmessage); ast_manager_register_xml_core("Filter", EVENT_FLAG_SYSTEM, action_filter); +#ifdef TEST_FRAMEWORK + stasis_subscribe(ast_test_suite_topic(), test_suite_event_cb, NULL); +#endif + ast_cli_register_multiple(cli_manager, ARRAY_LEN(cli_manager)); __ast_custom_function_register(&managerclient_function, NULL); ast_extension_state_add(NULL, NULL, manager_state_cb, NULL); |