diff --git a/apps/app_stasis.c b/apps/app_stasis.c index f0389947ab..1e7b7f9c9c 100644 --- a/apps/app_stasis.c +++ b/apps/app_stasis.c @@ -54,6 +54,25 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") Invoke a Stasis application. + This application will set the following channel variable upon + completion: + + + This indicates the status of the execution of the + Stasis application. + + The channel has exited Stasis without any failures in Stasis + + + A failure occurred when executing the Stasis application. + Some (not all) possible reasons for this: + The app registry is not instantiated + The app requested is not registered + The app requested is not active + Stasis couldn't send a start message + + + ***/ @@ -67,6 +86,7 @@ static const char *stasis = "Stasis"; static int app_exec(struct ast_channel *chan, const char *data) { char *parse = NULL; + int ret = -1; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(app_name); @@ -76,17 +96,28 @@ static int app_exec(struct ast_channel *chan, const char *data) ast_assert(chan != NULL); ast_assert(data != NULL); + pbx_builtin_setvar_helper(chan, "STASISSTATUS", ""); + /* parse the arguments */ parse = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, parse); if (args.argc < 1) { ast_log(LOG_WARNING, "Stasis app_name argument missing\n"); - return -1; + } else { + ret = stasis_app_exec(chan, + args.app_name, + args.argc - 1, + args.app_argv); } - return stasis_app_exec( - chan, args.app_name, args.argc - 1, args.app_argv); + if (ret == -1) { + pbx_builtin_setvar_helper(chan, "STASISSTATUS", "FAILED"); + } else { + pbx_builtin_setvar_helper(chan, "STASISSTATUS", "SUCCESS"); + } + + return ret; } static int load_module(void)