]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add optional format string after myevent
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 9 Sep 2011 19:31:02 +0000 (14:31 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Fri, 9 Sep 2011 19:31:16 +0000 (14:31 -0500)
src/mod/event_handlers/mod_event_socket/mod_event_socket.c

index 37c238852c732ed295fa6d1d8b44d7f7f3f69b5e..aaf270cb26a8ae62c34aa00fd8f579ae7bc6b616 100644 (file)
@@ -1883,11 +1883,30 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even
                                char *uuid;
 
                                if ((uuid = cmd + 9)) {
+                                       char *fmt;
                                        strip_cr(uuid);
-
+                                       
+                                       if ((fmt = strchr(uuid, ' '))) {
+                                               *fmt++ = '\0';
+                                       }
+                                               
                                        if (!(listener->session = switch_core_session_locate(uuid))) {
-                                               switch_snprintf(reply, reply_len, "-ERR invalid uuid");
-                                               goto done;
+                                               if (fmt) {
+                                                       switch_snprintf(reply, reply_len, "-ERR invalid uuid");
+                                                       goto done;
+                                               } else {
+                                                       fmt = uuid;
+                                               }
+                                       }
+
+                                       if ((fmt = strchr(uuid, ' '))) {
+                                               if (!strcasecmp(fmt, "xml")) {
+                                                       listener->format = EVENT_FORMAT_XML;
+                                               } else if (!strcasecmp(fmt, "plain")) {
+                                                       listener->format = EVENT_FORMAT_PLAIN;
+                                               } else if (!strcasecmp(fmt, "json")) {
+                                                       listener->format = EVENT_FORMAT_JSON;
+                                               }                                               
                                        }
 
                                        switch_set_flag_locked(listener, LFLAG_SESSION);