[Freeswitch-svn] [commit] r13016 - freeswitch/trunk/src/mod/languages/mod_spidermonkey
FreeSWITCH SVN
anthm at freeswitch.org
Tue Apr 14 09:45:35 PDT 2009
Author: anthm
Date: Tue Apr 14 11:45:35 2009
New Revision: 13016
Log:
add destroy method to js
Modified:
freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
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 Tue Apr 14 11:45:35 2009
@@ -2216,6 +2216,40 @@
return ret;
}
+static JSBool session_detach(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
+{
+ struct js_session *jss = JS_GetPrivate(cx, obj);
+ jsval ret = JS_TRUE;
+ switch_call_cause_t cause = 0;
+ switch_channel_t *channel;
+ switch_core_session_t *session;
+ METHOD_SANITY_CHECK();
+
+ if ((session = jss->session)) {
+ jss->session = NULL;
+
+ if (argc > 1) {
+ if (JSVAL_IS_INT(argv[0])) {
+ int32 i = 0;
+ JS_ValueToInt32(cx, argv[0], &i);
+ cause = i;
+ }
+ }
+
+ if (cause) {
+ channel = switch_core_session_get_channel(session);
+ switch_channel_hangup(channel, cause);
+ }
+
+ switch_core_session_rwunlock(session);
+ *rval = JS_TRUE;
+ } else {
+ *rval = JS_FALSE;
+ }
+
+ return ret;
+}
+
static JSBool session_execute(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
{
JSBool retval = JS_FALSE;
@@ -2617,6 +2651,7 @@
{"sendEvent", session_send_event, 0},
{"hangup", session_hangup, 0},
{"execute", session_execute, 0},
+ {"destroy", session_detach, 0},
{"sleep", session_sleep, 1},
{0}
};
More information about the Freeswitch-svn
mailing list