Remove required type field from channel blobs
[asterisk/asterisk.git] / res / res_stasis.c
index 0453625..3d003e4 100644 (file)
@@ -240,10 +240,10 @@ static struct stasis_app_control *control_create(const char *uniqueid)
 static void *exec_command(struct stasis_app_control *control,
                          struct stasis_app_command *command)
 {
-        ao2_lock(control);
+       ao2_lock(control);
        ao2_ref(command, +1);
        ao2_link(control->command_queue, command);
-        ao2_unlock(control);
+       ao2_unlock(control);
 
        return wait_for_command(command);
 }
@@ -302,12 +302,12 @@ struct stasis_app_control *stasis_app_control_find_by_channel_id(
  */
 static int control_continue_test_and_reset(struct stasis_app_control *control)
 {
-        int r;
-        SCOPED_AO2LOCK(lock, control);
+       int r;
+       SCOPED_AO2LOCK(lock, control);
 
-        r = control->continue_to_dialplan;
-        control->continue_to_dialplan = 0;
-        return r;
+       r = control->continue_to_dialplan;
+       control->continue_to_dialplan = 0;
+       return r;
 }
 
 void stasis_app_control_continue(struct stasis_app_control *control)
@@ -470,19 +470,17 @@ static void dtmf_handler(struct app *app, struct ast_channel_blob *obj)
        app_send(app, msg);
 }
 
-static void blob_handler(struct app *app, struct ast_channel_blob *blob)
-{
-       /* To simplify events, we'll only generate on DTMF end */
-       if (strcmp(ast_channel_blob_json_type(blob), "dtmf_end") == 0) {
-               dtmf_handler(app, blob);
-       }
-}
-
 static void sub_handler(void *data, struct stasis_subscription *sub,
                        struct stasis_topic *topic,
                        struct stasis_message *message)
 {
        struct app *app = data;
+
+       if (stasis_subscription_final_message(sub, message)) {
+               ao2_cleanup(data);
+               return;
+       }
+
        if (ast_channel_snapshot_type() == stasis_message_type(message)) {
                RAII_VAR(struct ast_json *, msg, NULL, ast_json_unref);
                struct ast_channel_snapshot *snapshot =
@@ -493,13 +491,12 @@ static void sub_handler(void *data, struct stasis_subscription *sub,
                        return;
                }
                app_send(app, msg);
-       } else if (ast_channel_blob_type() == stasis_message_type(message)) {
+       } else if (ast_channel_dtmf_end_type() == stasis_message_type(message)) {
+               /* To simplify events, we'll only generate on DTMF end */
                struct ast_channel_blob *blob = stasis_message_data(message);
-               blob_handler(app, blob);
-       }
-       if (stasis_subscription_final_message(sub, message)) {
-               ao2_cleanup(data);
+               dtmf_handler(app, blob);
        }
+
 }
 
 /*!
@@ -526,7 +523,7 @@ static void dispatch_commands(struct stasis_app_control *control,
        struct ao2_iterator i;
        void *obj;
 
-        SCOPED_AO2LOCK(lock, control);
+       SCOPED_AO2LOCK(lock, control);
 
        i = ao2_iterator_init(control->command_queue, AO2_ITERATOR_UNLINK);