[Freeswitch-svn] [commit] r5006 - freeswitch/trunk/src/mod/languages/mod_spidermonkey

Freeswitch SVN anthm at freeswitch.org
Mon Apr 23 16:11:29 EDT 2007


Author: anthm
Date: Mon Apr 23 16:11:28 2007
New Revision: 5006

Modified:
   freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
   freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h

Log:
update

Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	Mon Apr 23 16:11:28 2007
@@ -1090,11 +1090,17 @@
 
 static void check_hangup_hook(struct js_session *jss)
 {
-	jsval argv[2] = { 0 };
+	jsval argv[3] = { 0 };
 	int argc = 0;
 	jsval ret;
-	if (jss->on_hangup) {
+
+	if (jss->on_hangup && (jss->hook_state == CS_HANGUP || jss->hook_state == CS_RING)) {
 		argv[argc++] = OBJECT_TO_JSVAL(jss->obj);
+		if (jss->hook_state == CS_HANGUP) {
+			argv[argc++] = STRING_TO_JSVAL(JS_NewStringCopyZ(jss->cx, "hangup"));
+		} else {
+			argv[argc++] = STRING_TO_JSVAL(JS_NewStringCopyZ(jss->cx, "transfer"));
+		}
 		JS_CallFunction(jss->cx, jss->obj, jss->on_hangup, argc, argv, &ret);
 	}
 }
@@ -1103,16 +1109,21 @@
 {
 	switch_channel_t *channel;
 	struct js_session *jss = NULL;
+	switch_channel_state_t state;
 
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
 
-	if (switch_channel_get_state(channel) != CS_EXECUTE) {
-		if ((jss = switch_channel_get_private(channel, "jss"))) {
+	state = switch_channel_get_state(channel);
+
+	if ((jss = switch_channel_get_private(channel, "jss"))) {
+		if (jss->hook_state != state) {
+			jss->hook_state = state;
 			check_hangup_hook(jss);
 		}
 	}
 
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -1128,6 +1139,7 @@
 				switch_channel_t *channel = switch_core_session_get_channel(jss->session);
 				assert(channel != NULL);
 				jss->on_hangup = function;
+				jss->hook_state = switch_channel_get_state(channel);
 				switch_channel_set_private(channel, "jss", jss);
 				switch_core_event_hook_add_state_change(jss->session, hanguphook);
 				*rval = BOOLEAN_TO_JSVAL(JS_FALSE);

Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h	Mon Apr 23 16:11:28 2007
@@ -129,6 +129,7 @@
 	unsigned int flags;
 	switch_call_cause_t cause;
 	JSFunction *on_hangup;
+	switch_channel_state_t hook_state;
 };
 
 



More information about the Freeswitch-svn mailing list