Author: asanders
Date: Tue Mar 31 17:49:45 2015
New Revision: 433845

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=433845
Log:
stasis: set a channel variable on websocket disconnect error

When an error occurs while writing to a web socket, the web socket is
disconnected and the event is logged. A side-effect of this, however, is that
any application on the other side waiting for a response from Stasis is left
hanging indefinitely (as there is no mechanism presently available for
notifying interested parties about web socket error states in Stasis).

To remedy this scenario, this patch introduces a new channel variable:
STASISSTATUS.

The possible values for STASISSTATUS are:
SUCCESS         - The channel has exited Stasis without any failures
FAILED          - Something caused Stasis to croak. 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

ASTERISK-24802
Reported By: Kevin Harwell
Review: https://reviewboard.asterisk.org/r/4519/
........

Merged revisions 433839 from http://svn.asterisk.org/svn/asterisk/branches/13

Modified:
    trunk/   (props changed)
    trunk/apps/app_stasis.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-13-merged' - no diff available.

Modified: trunk/apps/app_stasis.c
URL: 
http://svnview.digium.com/svn/asterisk/trunk/apps/app_stasis.c?view=diff&rev=433845&r1=433844&r2=433845
==============================================================================
--- trunk/apps/app_stasis.c (original)
+++ trunk/apps/app_stasis.c Tue Mar 31 17:49:45 2015
@@ -54,6 +54,25 @@
                                Invoke a Stasis application.
                        </para>
                </description>
+               <para>This application will set the following channel variable 
upon
+               completion:</para>
+                       <variablelist>
+                               <variable name="STASISSTATUS">
+                                       <para>This indicates the status of the 
execution of the
+                                       Stasis application.</para>
+                                       <value name="SUCCESS">
+                                       The channel has exited Stasis without 
any failures in Stasis
+                                       </value>
+                                       <value name="FAILED">
+                                       A failure occurred when executing the 
Stasis application.
+                                       Some (not all) possible reasons for 
this:
+                                           <para>The app registry is not 
instantiated</para>
+                                           <para>The app requested is not 
registered</para>
+                                           <para>The app requested is not 
active</para>
+                                           <para>Stasis couldn't send a start 
message</para>
+                                       </value>
+                               </variable>
+                       </variablelist>
        </application>
  ***/
 
@@ -67,6 +86,7 @@
 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 @@
        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)


-- 
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

svn-commits mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/svn-commits

Reply via email to