[Freeswitch-svn] [commit] r8742 - freeswitch/trunk/src/mod/languages/mod_spidermonkey
Freeswitch SVN
anthm at freeswitch.org
Mon Jun 2 19:32:16 EDT 2008
Author: anthm
Date: Mon Jun 2 19:32:15 2008
New Revision: 8742
Modified:
freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
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 Jun 2 19:32:15 2008
@@ -2000,6 +2000,16 @@
return JS_TRUE;
}
+
+static JSBool session_answered(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
+{
+ struct js_session *jss = JS_GetPrivate(cx, obj);
+
+ *rval = BOOLEAN_TO_JSVAL((jss && jss->session && switch_channel_test_flag(switch_core_session_get_channel(jss->session), CF_ANSWERED)) ? JS_TRUE : JS_FALSE);
+
+ return JS_TRUE;
+}
+
static JSBool session_wait_for_media(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
{
struct js_session *jss = JS_GetPrivate(cx, obj);
@@ -2461,6 +2471,7 @@
{"preAnswer", session_pre_answer, 0},
{"generateXmlCdr", session_cdr, 0},
{"ready", session_ready, 0},
+ {"answered", session_answered, 0},
{"waitForAnswer", session_wait_for_answer, 0},
{"waitForMedia", session_wait_for_media, 0},
{"getEvent", session_get_event, 0},
@@ -3152,6 +3163,24 @@
return JS_FALSE;
}
+static JSBool js_api_sleep(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
+{
+ int32 msec = 0;
+
+ if (argc > 0) {
+ JS_ValueToInt32(cx, argv[0], &msec);
+ }
+
+ if (msec) {
+ switch_yield(msec * 1000);
+ } else {
+ eval_some_js("~throw new Error(\"No Time specified\");", cx, obj, rval);
+ }
+
+ return JS_TRUE;
+
+}
+
static JSBool js_api_use(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
{
char *mod_name = NULL;
@@ -3322,6 +3351,7 @@
{"bridge", js_bridge, 2},
{"apiExecute", js_api_execute, 2},
{"use", js_api_use, 1},
+ {"msleep", js_api_sleep, 1},
{"fileDelete", js_file_unlink, 1},
{"system", js_system, 1},
#ifdef HAVE_CURL
More information about the Freeswitch-svn
mailing list