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

Freeswitch SVN anthm at freeswitch.org
Sun Oct 26 17:08:23 EDT 2008


Author: anthm
Date: Sun Oct 26 17:08:22 2008
New Revision: 10158

Modified:
   freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c

Log:
update

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	Sun Oct 26 17:08:22 2008
@@ -1048,15 +1048,43 @@
 			switch_snprintf(reply, reply_len, "+OK");
 			goto done;
 		} else if (listener->session && !strncasecmp(cmd, "sendmsg", 7)) {
-			if (switch_test_flag(listener, LFLAG_ASYNC)) {
-				if ((status = switch_core_session_queue_private_event(listener->session, event)) == SWITCH_STATUS_SUCCESS) {
+			char *uuid = cmd + 8;
+			switch_core_session_t *session = NULL;
+
+			if (uuid) {
+				while (*uuid == ' ') {
+					uuid++;
+				}
+				
+				if (*uuid == '\r' || *uuid == '\n') {
+					uuid = NULL;
+				} else {
+					strip_cr(uuid);
+				}
+			}
+
+			if (!uuid) {
+				uuid = switch_event_get_header(*event, "session-id");
+			}
+			
+			if (uuid && (session = switch_core_session_locate(uuid))) {
+				if ((status = switch_core_session_queue_private_event(session, event)) == SWITCH_STATUS_SUCCESS) {
 					switch_snprintf(reply, reply_len, "+OK");
 				} else {
 					switch_snprintf(reply, reply_len, "-ERR memory error");
 				}
+				switch_core_session_rwunlock(session);
 			} else {
-				switch_ivr_parse_event(listener->session, *event);
-				switch_snprintf(reply, reply_len, "+OK");
+				if (switch_test_flag(listener, LFLAG_ASYNC)) {
+					if ((status = switch_core_session_queue_private_event(listener->session, event)) == SWITCH_STATUS_SUCCESS) {
+						switch_snprintf(reply, reply_len, "+OK");
+					} else {
+						switch_snprintf(reply, reply_len, "-ERR memory error");
+					}
+				} else {
+					switch_ivr_parse_event(listener->session, *event);
+					switch_snprintf(reply, reply_len, "+OK");
+				}
 			}
 			goto done;
 		} else if (!strncasecmp(cmd, "getvar", 6)) {
@@ -1173,8 +1201,8 @@
 		if (!uuid) {
 			uuid = switch_event_get_header(*event, "session-id");
 		}
-
-		if ((session = switch_core_session_locate(uuid))) {
+		
+		if (uuid && (session = switch_core_session_locate(uuid))) {
 			if ((status = switch_core_session_queue_private_event(session, event)) == SWITCH_STATUS_SUCCESS) {
 				switch_snprintf(reply, reply_len, "+OK");
 			} else {
@@ -1182,7 +1210,7 @@
 			}
 			switch_core_session_rwunlock(session);
 		} else {
-			switch_snprintf(reply, reply_len, "-ERR invalid session id [%s]", uuid);
+			switch_snprintf(reply, reply_len, "-ERR invalid session id [%s]", switch_str_nil(uuid));
 		}
 
 		goto done;



More information about the Freeswitch-svn mailing list