[Freeswitch-svn] [commit] r10731 - freeswitch/trunk/src/mod/event_handlers/mod_event_socket

FreeSWITCH SVN anthm at freeswitch.org
Fri Dec 12 07:44:38 PST 2008


Author: anthm
Date: Fri Dec 12 10:44:37 2008
New Revision: 10731

Log:
fix MODEVENT-34

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 Dec 12 10:44:37 2008
@@ -48,7 +48,8 @@
 	LFLAG_MYEVENTS = (1 << 5),
 	LFLAG_SESSION = (1 << 6),
 	LFLAG_ASYNC = (1 << 7),
-	LFLAG_STATEFUL = (1 << 8)
+	LFLAG_STATEFUL = (1 << 8),
+	LFLAG_OUTBOUND = (1 << 9)
 } event_flag_t;
 
 typedef enum {
@@ -403,6 +404,7 @@
 
 	switch_core_hash_init(&listener->event_hash, listener->pool);
 	switch_set_flag(listener, LFLAG_AUTHED);
+	switch_set_flag(listener, LFLAG_OUTBOUND);
 	for (x = 1; x < argc; x++) {
 		if (argv[x] && !strcasecmp(argv[x], "full")) {
 			switch_set_flag(listener, LFLAG_FULL);
@@ -1294,39 +1296,12 @@
 			switch_snprintf(reply, reply_len, "+OK Events Enabled");
 			goto done;
 		}
-
-		if (!switch_test_flag(listener, LFLAG_FULL)) {
-			goto done;
-		}
 	}
 
-	if (!strncasecmp(cmd, "sendevent", 9)) {
-		char *ename;
-		strip_cr(cmd);
-
-		ename = cmd + 9;
 
-		while (ename && (*ename == '\t' || *ename == ' ')) {
-			++ename;
-		}
-
-		if (ename && (*ename == '\r' || *ename == '\n')) {
-			ename = NULL;
-		}
-
-		if (ename) {
-			switch_event_types_t etype;
-			if (switch_name_event(ename, &etype) == SWITCH_STATUS_SUCCESS) {
-				(*event)->event_id = etype;
-			}
-		}
-
-		switch_event_fire(event);
-		switch_snprintf(reply, reply_len, "+OK");
-		goto done;
-	} else if (!strncasecmp(cmd, "sendmsg", 7)) {
+	if (!strncasecmp(cmd, "sendmsg", 7)) {
 		switch_core_session_t *session;
-		char *uuid = cmd + 8;
+		char *uuid = cmd + 7;
 
 		if (uuid) {
 			while (*uuid == ' ') {
@@ -1343,7 +1318,7 @@
 		if (switch_strlen_zero(uuid)) {
 			uuid = switch_event_get_header(*event, "session-id");
 		}
-		
+
 		if (switch_strlen_zero(uuid) && listener->session) {
 			if (switch_test_flag(listener, LFLAG_ASYNC)) {
 				if ((status = switch_core_session_queue_private_event(listener->session, event)) == SWITCH_STATUS_SUCCESS) {
@@ -1370,6 +1345,37 @@
 		
 		goto done;
 
+	}
+	
+	if (switch_test_flag(listener, LFLAG_OUTBOUND) && !switch_test_flag(listener, LFLAG_FULL)) {
+		goto done;
+	}
+
+
+	if (!strncasecmp(cmd, "sendevent", 9)) {
+		char *ename;
+		strip_cr(cmd);
+
+		ename = cmd + 9;
+
+		while (ename && (*ename == '\t' || *ename == ' ')) {
+			++ename;
+		}
+
+		if (ename && (*ename == '\r' || *ename == '\n')) {
+			ename = NULL;
+		}
+
+		if (ename) {
+			switch_event_types_t etype;
+			if (switch_name_event(ename, &etype) == SWITCH_STATUS_SUCCESS) {
+				(*event)->event_id = etype;
+			}
+		}
+
+		switch_event_fire(event);
+		switch_snprintf(reply, reply_len, "+OK");
+		goto done;
 	} else if (!strncasecmp(cmd, "api ", 4)) {
 		struct api_command_struct acs = { 0 };
 		char *api_cmd = cmd + 4;
@@ -1965,6 +1971,7 @@
 		listener->pool = listener_pool;
 		listener_pool = NULL;
 		listener->format = EVENT_FORMAT_PLAIN;
+		switch_set_flag(listener, LFLAG_FULL);
 		switch_mutex_init(&listener->flag_mutex, SWITCH_MUTEX_NESTED, listener->pool);
 		switch_mutex_init(&listener->filter_mutex, SWITCH_MUTEX_NESTED, listener->pool);
 



More information about the Freeswitch-svn mailing list