[asterisk-commits] dlee: branch dlee/ari-event-remodel2 r392433 - /team/dlee/ari-event-remodel2/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jun 21 11:18:15 CDT 2013


Author: dlee
Date: Fri Jun 21 11:18:13 2013
New Revision: 392433

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392433
Log:
Put varset, DTMF and hangup events back on ARI

Modified:
    team/dlee/ari-event-remodel2/res/res_stasis.c

Modified: team/dlee/ari-event-remodel2/res/res_stasis.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/res/res_stasis.c?view=diff&rev=392433&r1=392432&r2=392433
==============================================================================
--- team/dlee/ari-event-remodel2/res/res_stasis.c (original)
+++ team/dlee/ari-event-remodel2/res/res_stasis.c Fri Jun 21 11:18:13 2013
@@ -391,6 +391,32 @@
 static void distribute_message(struct ao2_container *apps, struct ast_json *msg)
 {
 	ao2_callback(apps, OBJ_NODATA, app_send_cb, msg);
+}
+
+static void sub_channel_blob_handler(void *data,
+		struct stasis_subscription *sub,
+		struct stasis_topic *topic,
+		struct stasis_message *message)
+{
+	RAII_VAR(struct ast_json *, msg, NULL, ast_json_unref);
+	RAII_VAR(struct ao2_container *, watching_apps, NULL, ao2_cleanup);
+	struct ast_channel_blob *obj = stasis_message_data(message);
+
+	if (!obj->snapshot) {
+		return;
+	}
+
+	msg = stasis_message_to_json(message);
+	if (!msg) {
+		return;
+	}
+
+	watching_apps = get_apps_watching_channel(obj->snapshot->uniqueid);
+	if (!watching_apps) {
+		return;
+	}
+
+	distribute_message(watching_apps, msg);
 }
 
 /*!
@@ -920,6 +946,16 @@
 	}
 
 	r |= stasis_message_router_add(channel_router, stasis_cache_update_type(), sub_channel_snapshot_handler, NULL);
+	/* TODO: This could be handled a lot better. Instead of subscribing to
+	 * the one caching topic and filtering out messages by channel id, we
+	 * should have individual caching topics per-channel, with a shared
+	 * back-end cache. That would simplify a lot of what's going on right
+	 * here.
+	 */
+	r |= stasis_message_router_add(channel_router, ast_channel_user_event_type(), sub_channel_blob_handler, NULL);
+	r |= stasis_message_router_add(channel_router, ast_channel_varset_type(), sub_channel_blob_handler, NULL);
+	r |= stasis_message_router_add(channel_router, ast_channel_dtmf_end_type(), sub_channel_blob_handler, NULL);
+	r |= stasis_message_router_add(channel_router, ast_channel_hangup_request_type(), sub_channel_blob_handler, NULL);
 	if (r) {
 		return AST_MODULE_LOAD_FAILURE;
 	}




More information about the asterisk-commits mailing list