Revision
14874
Author
anthm
Date
2009-09-15 14:18:20 -0500 (Tue, 15 Sep 2009)

Log Message

add unique-id check to sendevent to send and event to a session instead of the system

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c (14873 => 14874)


--- freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c	2009-09-15 18:48:12 UTC (rev 14873)
+++ freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c	2009-09-15 19:18:20 UTC (rev 14874)
@@ -1667,6 +1667,8 @@
 
 	if (!strncasecmp(cmd, "sendevent", 9)) {
 		char *ename;
+		const char *uuid = NULL;
+
 		strip_cr(cmd);
 
 		ename = cmd + 9;
@@ -1691,7 +1693,17 @@
 			}
 		}
 
-		switch_event_fire(event);
+		if ((uuid = switch_event_get_header(*event, "unique-id"))) {
+			switch_core_session_t *dsession;
+			if ((dsession = switch_core_session_locate(uuid))) {
+				switch_core_session_queue_event(dsession, event);
+				switch_core_session_rwunlock(dsession);
+			}
+		}
+		
+		if (*event) {
+			switch_event_fire(event);
+		}
 		switch_snprintf(reply, reply_len, "+OK");
 		goto done;
 	} else if (!strncasecmp(cmd, "api ", 4)) {