[asterisk-commits] kmoore: branch kmoore/stasis-http_sounds r387632 - in /team/kmoore/stasis-htt...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat May 4 10:58:52 CDT 2013


Author: kmoore
Date: Sat May  4 10:58:50 2013
New Revision: 387632

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=387632
Log:
Migrate SHARED's use of the VarSet AMI event to Stasis-Core

This patch removes the direct call to AMI from the SHARED function
and instead call Stasis-Core. Stasis-Core delivers the notification
that a shared variable has changed on a channel to all interested
consumers.

(issue ASTERISK-21462)
........

Merged revisions 387630 from http://svn.asterisk.org/svn/asterisk/trunk

Modified:
    team/kmoore/stasis-http_sounds/   (props changed)
    team/kmoore/stasis-http_sounds/funcs/func_global.c

Propchange: team/kmoore/stasis-http_sounds/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sat May  4 10:58:50 2013
@@ -1,1 +1,1 @@
-/trunk:1-387601
+/trunk:1-387631

Modified: team/kmoore/stasis-http_sounds/funcs/func_global.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-http_sounds/funcs/func_global.c?view=diff&rev=387632&r1=387631&r2=387632
==============================================================================
--- team/kmoore/stasis-http_sounds/funcs/func_global.c (original)
+++ team/kmoore/stasis-http_sounds/funcs/func_global.c Sat May  4 10:58:50 2013
@@ -39,7 +39,7 @@
 #include "asterisk/pbx.h"
 #include "asterisk/channel.h"
 #include "asterisk/app.h"
-#include "asterisk/manager.h"
+#include "asterisk/stasis_channels.h"
 
 /*** DOCUMENTATION
 	<function name="GLOBAL" language="en_US">
@@ -83,7 +83,25 @@
 			using it in a set of calculations (or you might be surprised by the result).</para>
 		</description>
 	</function>
-
+	<managerEvent language="en_US" name="VarSet">
+		<managerEventInstance class="EVENT_FLAG_DIALPLAN">
+			<synopsis>Raised when a variable is shared between channels.</synopsis>
+			<syntax>
+				<xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+				<parameter name="Variable">
+					<para>The SHARED variable being set.</para>
+					<note><para>The variable name will always be enclosed with
+					<literal>SHARED()</literal></para></note>
+				</parameter>
+				<parameter name="Value">
+					<para>The new value of the variable.</para>
+				</parameter>
+			</syntax>
+			<see-also>
+				<ref type="function">SHARED</ref>
+			</see-also>
+		</managerEventInstance>
+	</managerEvent>
  ***/
 
 static void shared_variable_free(void *data);
@@ -197,6 +215,8 @@
 		AST_APP_ARG(chan);
 	);
 	struct ast_channel *c_ref = NULL;
+	int len;
+	RAII_VAR(char *, shared_buffer, NULL, ast_free);
 
 	if (ast_strlen_zero(data)) {
 		ast_log(LOG_WARNING, "SHARED() requires an argument: SHARED(<var>[,<chan>])\n");
@@ -213,6 +233,15 @@
 			return -1;
 		}
 		chan = c_ref;
+	}
+
+	len = 9 + strlen(args.var); /* SHARED() + var */
+	shared_buffer = ast_malloc(len);
+	if (!shared_buffer) {
+		if (c_ref) {
+			ast_channel_unref(c_ref);
+		}
+		return -1;
 	}
 
 	ast_channel_lock(chan);
@@ -255,13 +284,9 @@
 
 	var = ast_var_assign(args.var, S_OR(value, ""));
 	AST_LIST_INSERT_HEAD(varshead, var, entries);
-	manager_event(EVENT_FLAG_DIALPLAN, "VarSet", 
-		"Channel: %s\r\n"
-		"Variable: SHARED(%s)\r\n"
-		"Value: %s\r\n"
-		"Uniqueid: %s\r\n", 
-		chan ? ast_channel_name(chan) : "none", args.var, value, 
-		chan ? ast_channel_uniqueid(chan) : "none");
+
+	sprintf(shared_buffer, "SHARED(%s)", args.var);
+	ast_channel_publish_varset(chan, shared_buffer, value);
 
 	ast_channel_unlock(chan);
 




More information about the asterisk-commits mailing list