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

Freeswitch SVN anthm at freeswitch.org
Mon Jan 8 19:39:12 EST 2007


Author: anthm
Date: Mon Jan  8 19:39:11 2007
New Revision: 3931

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

Log:
add getvar

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	Mon Jan  8 19:39:11 2007
@@ -613,6 +613,9 @@
 
 
     if (listener->session) {
+        switch_channel_t *channel = switch_core_session_get_channel(listener->session);
+        assert(channel != NULL);
+
         if (!strncasecmp(cmd, "connect", 7)) {
             snprintf(reply, reply_len, "+OK");
             goto done;
@@ -628,6 +631,21 @@
                 snprintf(reply, reply_len, "+OK");
             }
             goto done;
+        } else if (!strncasecmp(cmd, "getvar", 6)) {
+            char *arg;
+            char *val = "";
+            
+            strip_cr(cmd);
+
+            if ((arg = strchr(cmd, ' '))) {
+                *arg++ = '\0';
+                if (!(val = switch_channel_get_variable(channel, arg))) {
+                    val = "";
+                }
+
+            }
+            snprintf(reply, reply_len, val);
+            goto done;
         } else if (!strncasecmp(cmd, "myevents", 8)) {
             listener->event_list[SWITCH_EVENT_CHANNEL_CREATE] = 1;
             listener->event_list[SWITCH_EVENT_CHANNEL_DESTROY] = 1;



More information about the Freeswitch-svn mailing list