]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add funcs to js
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 18 Aug 2006 21:18:41 +0000 (21:18 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 18 Aug 2006 21:18:41 +0000 (21:18 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2332 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/languages/mod_spidermonkey/mod_spidermonkey.c

index 6836691a6a883360fea6b6141db1410027840635..be62712df26e8069a82dc9dcd299b6dbb00fb573 100644 (file)
@@ -674,6 +674,38 @@ static switch_status_t js_speak_dtmf_callback(switch_core_session_t *session, vo
        
 }
 
+static JSBool session_flush_digits(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+       struct js_session *jss = JS_GetPrivate(cx, obj);
+       switch_channel_t *channel;
+       char buf[256];
+       switch_size_t has;
+
+       channel = switch_core_session_get_channel(jss->session);
+    assert(channel != NULL);
+
+       if ((has = switch_channel_has_dtmf(channel))) {
+               switch_channel_dequeue_dtmf(channel, buf, has);
+       }
+
+       *rval = BOOLEAN_TO_JSVAL( JS_TRUE );
+    return JS_TRUE;
+}
+
+static JSBool session_flush_events(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+       struct js_session *jss = JS_GetPrivate(cx, obj);
+       switch_event_t *event;
+
+       while (switch_core_session_dequeue_event(jss->session, &event) == SWITCH_STATUS_SUCCESS) {
+               switch_event_destroy(&event);
+       }
+       
+       *rval = BOOLEAN_TO_JSVAL( JS_TRUE );
+    return JS_TRUE;
+       
+}
+
 static JSBool session_recordfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 {
        struct js_session *jss = JS_GetPrivate(cx, obj);
@@ -1158,6 +1190,8 @@ enum session_tinyid {
 static JSFunctionSpec session_methods[] = {
        {"streamFile", session_streamfile, 1}, 
        {"recordFile", session_recordfile, 1}, 
+       {"flushEvents", session_flush_events, 1}, 
+       {"flushDigits", session_flush_digits, 1}, 
        {"speak", session_speak, 1}, 
        {"getDigits", session_get_digits, 1},
        {"answer", session_answer, 0},