From 1eafc86063172731686ba28ca6f91d22132cfb8c Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 2 Apr 2007 21:31:03 +0000 Subject: [PATCH] update git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4834 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- .../mod_spidermonkey/mod_spidermonkey.c | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c index 7536f42954..bcf4a16892 100644 --- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c @@ -2651,7 +2651,7 @@ static void js_parse_and_execute(switch_core_session_t *session, char *input_cod if ((arg = strchr(script, ' '))) { *arg++ = '\0'; - argc = switch_separate_string(arg, ':', argv, (sizeof(argv) / sizeof(argv[0]))); + argc = switch_separate_string(arg, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } if (argc) { /* create a js doppleganger of this argc/argv */ @@ -2757,6 +2757,22 @@ static switch_loadable_module_interface_t spidermonkey_module_interface = { /*.directory_interface */ NULL }; +static void message_query_handler(switch_event_t *event) +{ + char *account = switch_event_get_header(event, "message-account"); + + if (account) { + char *text; + + text = switch_mprintf("mwi.js %s", account); + assert(text != NULL); + + js_thread_launch(text); + free(text); + } + +} + SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename) { switch_status_t status; @@ -2765,6 +2781,12 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod return status; } + if (switch_event_bind((char *) modname, SWITCH_EVENT_MESSAGE_QUERY, SWITCH_EVENT_SUBCLASS_ANY, message_query_handler, NULL) + != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n"); + return SWITCH_STATUS_GENERR; + } + /* connect my internal structure to the blank pointer passed to me */ *module_interface = &spidermonkey_module_interface;