[Freeswitch-svn] [commit] r10402 - freeswitch/trunk/src/mod/event_handlers/mod_event_socket
FreeSWITCH SVN
anthm at freeswitch.org
Fri Nov 14 09:29:14 PST 2008
Author: anthm
Date: Fri Nov 14 12:29:14 2008
New Revision: 10402
Log:
add filters to event_sink
Modified:
freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
==============================================================================
--- freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c (original)
+++ freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c Fri Nov 14 12:29:14 2008
@@ -532,7 +532,7 @@
stream->write_function(stream, " </listener>\n");
}
-SWITCH_STANDARD_API(event_manager_function)
+SWITCH_STANDARD_API(event_sink_function)
{
char *http = NULL;
char *wcmd = NULL;
@@ -563,9 +563,51 @@
format = "xml";
}
-
-
- if (!strcasecmp(wcmd, "create-listener")) {
+
+ if (!strcasecmp(wcmd, "filter")) {
+ char *action = switch_event_get_header(stream->param_event, "action");;
+ char *header_name = switch_event_get_header(stream->param_event, "header_name");;
+ char *header_val = switch_event_get_header(stream->param_event, "header_val");;
+
+ if (switch_strlen_zero(action)) {
+ stream->write_function(stream, "<data><reply type=\"error\">Invalid Syntax</reply></data>\n");
+ goto end;
+ }
+
+ switch_mutex_lock(listener->filter_mutex);
+ if (!listener->filters) {
+ switch_event_create(&listener->filters, SWITCH_EVENT_CHANNEL_DATA);
+ }
+
+ if (!strcasecmp(action, "delete")) {
+ if (switch_strlen_zero(header_val)) {
+ stream->write_function(stream, "<data><reply type=\"error\">Invalid Syntax</reply></data>\n");
+ goto filter_end;
+ }
+
+ if (!strcasecmp(header_val, "all")) {
+ switch_event_destroy(&listener->filters);
+ switch_event_create(&listener->filters, SWITCH_EVENT_CHANNEL_DATA);
+ } else {
+ switch_event_del_header(listener->filters, header_val);
+ }
+ stream->write_function(stream, "<data>\n <reply type=\"success\">filter deleted.</reply>\n<api-command>\n");
+ } else if (!strcasecmp(action, "add")) {
+ if (switch_strlen_zero(header_name) || switch_strlen_zero(header_val)) {
+ stream->write_function(stream, "<data><reply type=\"error\">Invalid Syntax</reply></data>\n");
+ goto filter_end;
+ }
+ switch_event_add_header_string(listener->filters, SWITCH_STACK_BOTTOM, header_name, header_val);
+ stream->write_function(stream, "<data>\n <reply type=\"success\">filter added.</reply>\n<api-command>\n");
+ } else {
+ stream->write_function(stream, "<data><reply type=\"error\">Invalid Syntax</reply></data>\n");
+ }
+
+ filter_end:
+
+ switch_mutex_unlock(listener->filter_mutex);
+
+ } else if (!strcasecmp(wcmd, "create-listener")) {
char *events = switch_event_get_header(stream->param_event, "events");
switch_memory_pool_t *pool;
char *next, *cur;
@@ -769,7 +811,7 @@
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
SWITCH_ADD_APP(app_interface, "socket", "Connect to a socket", "Connect to a socket", socket_function, "<ip>[:<port>]", SAF_SUPPORT_NOMEDIA);
- SWITCH_ADD_API(api_interface, "event_manager", "event_manager", event_manager_function, "<web data>");
+ SWITCH_ADD_API(api_interface, "event_sink", "event_sink", event_sink_function, "<web data>");
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
More information about the Freeswitch-svn
mailing list