[Freeswitch-svn] [commit] r12724 - in freeswitch/trunk/libs/esl: . lua perl php python ruby src src/include

FreeSWITCH SVN anthm at freeswitch.org
Mon Mar 23 12:55:03 PDT 2009


Author: anthm
Date: Mon Mar 23 14:55:02 2009
New Revision: 12724

Log:
add disconnect method and check in ivrd

Added:
   freeswitch/trunk/libs/esl/ivrd.c
   freeswitch/trunk/libs/esl/test.pl   (contents, props changed)
Modified:
   freeswitch/trunk/libs/esl/Makefile
   freeswitch/trunk/libs/esl/lua/esl_wrap.cpp
   freeswitch/trunk/libs/esl/perl/ESL.pm
   freeswitch/trunk/libs/esl/perl/esl_wrap.cpp
   freeswitch/trunk/libs/esl/php/ESL.php
   freeswitch/trunk/libs/esl/php/esl_wrap.cpp
   freeswitch/trunk/libs/esl/php/php_ESL.h
   freeswitch/trunk/libs/esl/python/ESL.py
   freeswitch/trunk/libs/esl/python/esl_wrap.cpp
   freeswitch/trunk/libs/esl/ruby/esl_wrap.cpp
   freeswitch/trunk/libs/esl/src/esl_oop.cpp
   freeswitch/trunk/libs/esl/src/include/esl_oop.h

Modified: freeswitch/trunk/libs/esl/Makefile
==============================================================================
--- freeswitch/trunk/libs/esl/Makefile	(original)
+++ freeswitch/trunk/libs/esl/Makefile	Mon Mar 23 14:55:02 2009
@@ -16,7 +16,7 @@
 # comment the next line to disable c++ (no swig mods for you then)
 OBJS += src/esl_oop.o
 
-all: $(MYLIB) fs_cli testclient testserver
+all: $(MYLIB) fs_cli testclient testserver ivrd
 
 $(MYLIB): $(OBJS) $(HEADERS) $(SRC)
 	ar rcs $(MYLIB) $(OBJS)
@@ -25,6 +25,9 @@
 testserver: $(MYLIB) testserver.c
 	$(CC) $(CC_CFLAGS) $(CFLAGS) testserver.c -o testserver $(LDFLAGS) $(LIBS)
 
+ivrd: $(MYLIB) ivrd.c
+	$(CC) $(CC_CFLAGS) $(CFLAGS) ivrd.c -o ivrd $(LDFLAGS) $(LIBS)
+
 testclient: $(MYLIB) testclient.c
 	$(CC) $(CC_CFLAGS) $(CFLAGS) testclient.c -o testclient $(LDFLAGS) $(LIBS)
 
@@ -38,7 +41,7 @@
 	$(CXX) $(CXX_CFLAGS) $(CXXFLAGS) -c $< -o $@
 
 clean:
-	rm -f *.o src/*.o testclient testserver fs_cli libesl.a *~ src/*~ src/include/*~
+	rm -f *.o src/*.o testclient testserver ivrd fs_cli libesl.a *~ src/*~ src/include/*~
 	$(MAKE) -C perl clean
 	$(MAKE) -C php clean
 	$(MAKE) -C lua clean

Added: freeswitch/trunk/libs/esl/ivrd.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/esl/ivrd.c	Mon Mar 23 14:55:02 2009
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2009, Anthony Minessale II
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 
+ * * Neither the name of the original author; nor the names of any contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ * 
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <esl.h>
+
+static void mycallback(esl_socket_t server_sock, esl_socket_t client_sock, struct sockaddr_in *addr)
+{
+	esl_handle_t handle = {{0}};
+	char path_buffer[1024] = { 0 };
+	const char *path;
+
+	if (fork()) {
+		close(client_sock);
+		return;
+	}
+
+	esl_attach_handle(&handle, client_sock, addr);
+
+	if (!(path = esl_event_get_header(handle.info_event, "variable_ivr_path"))) {
+		esl_log(ESL_LOG_ERROR, "Missing ivr_path param!\n");
+		return;
+	}
+
+	strncpy(path_buffer, path, sizeof(path_buffer) - 1);
+	
+	/* hotwire the socket to STDIN/STDOUT */
+	dup2(client_sock, STDIN_FILENO);
+	dup2(client_sock, STDOUT_FILENO);
+
+	/* close the handle but leak the socket on purpose cos the child will need it open */
+	handle.sock = -1;
+	esl_disconnect(&handle);
+	
+	/* DOH! we're still here! Close the socket. */
+	
+	execl(path_buffer, path_buffer, NULL);
+	esl_log(ESL_LOG_ERROR, "Error %d\n", client_sock);
+	close(client_sock);
+
+}
+
+int main(int argc, char *argv[])
+{
+	int i;
+	char *ip = NULL;
+	int port = 0;
+	
+	for (i = 1; i + 1 < argc; ) {
+		if (!strcasecmp(argv[i], "-h")) {
+			ip = argv[++i];
+		} else if (!strcasecmp(argv[i], "-p")) {
+			port = atoi(argv[++i]);
+		} else {
+			i++;
+		}
+	}
+
+	if (!(ip && port)) {
+		fprintf(stderr, "Usage %s -h <host> -p <port>\n", argv[0]);
+		return -1;
+	}
+
+	esl_listen(ip, port, mycallback);
+	
+	return 0;
+}

Modified: freeswitch/trunk/libs/esl/lua/esl_wrap.cpp
==============================================================================
--- freeswitch/trunk/libs/esl/lua/esl_wrap.cpp	(original)
+++ freeswitch/trunk/libs/esl/lua/esl_wrap.cpp	Mon Mar 23 14:55:02 2009
@@ -1927,14 +1927,14 @@
   
   SWIG_check_num_args("getHeader",2,2)
   if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("getHeader",1,"ESLevent *");
-  if(!lua_isstring(L,2)) SWIG_fail_arg("getHeader",2,"char *");
+  if(!lua_isstring(L,2)) SWIG_fail_arg("getHeader",2,"char const *");
   
   if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_ESLevent,0))){
     SWIG_fail_ptr("ESLevent_getHeader",1,SWIGTYPE_p_ESLevent);
   }
   
   arg2 = (char *)lua_tostring(L, 2);
-  result = (char *)(arg1)->getHeader(arg2);
+  result = (char *)(arg1)->getHeader((char const *)arg2);
   SWIG_arg=0;
   lua_pushstring(L,(const char*)result); SWIG_arg++;
   return SWIG_arg;
@@ -2688,6 +2688,31 @@
 }
 
 
+static int _wrap_ESLconnection_disconnect(lua_State* L) {
+  int SWIG_arg = -1;
+  ESLconnection *arg1 = (ESLconnection *) 0 ;
+  int result;
+  
+  SWIG_check_num_args("disconnect",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("disconnect",1,"ESLconnection *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_ESLconnection,0))){
+    SWIG_fail_ptr("ESLconnection_disconnect",1,SWIGTYPE_p_ESLconnection);
+  }
+  
+  result = (int)(arg1)->disconnect();
+  SWIG_arg=0;
+  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
 static void swig_delete_ESLconnection(void *obj) {
 ESLconnection *arg1 = (ESLconnection *) obj;
 delete arg1;
@@ -2707,6 +2732,7 @@
     {"execute", _wrap_ESLconnection_execute}, 
     {"setBlockingExecute", _wrap_ESLconnection_setBlockingExecute}, 
     {"setEventLock", _wrap_ESLconnection_setEventLock}, 
+    {"disconnect", _wrap_ESLconnection_disconnect}, 
     {0,0}
 };
 static swig_lua_attribute swig_ESLconnection_attributes[] = {

Modified: freeswitch/trunk/libs/esl/perl/ESL.pm
==============================================================================
--- freeswitch/trunk/libs/esl/perl/ESL.pm	(original)
+++ freeswitch/trunk/libs/esl/perl/ESL.pm	Mon Mar 23 14:55:02 2009
@@ -142,6 +142,7 @@
 *execute = *ESLc::ESLconnection_execute;
 *setBlockingExecute = *ESLc::ESLconnection_setBlockingExecute;
 *setEventLock = *ESLc::ESLconnection_setEventLock;
+*disconnect = *ESLc::ESLconnection_disconnect;
 sub DISOWN {
     my $self = shift;
     my $ptr = tied(%$self);

Modified: freeswitch/trunk/libs/esl/perl/esl_wrap.cpp
==============================================================================
--- freeswitch/trunk/libs/esl/perl/esl_wrap.cpp	(original)
+++ freeswitch/trunk/libs/esl/perl/esl_wrap.cpp	Mon Mar 23 14:55:02 2009
@@ -2304,10 +2304,10 @@
     arg1 = reinterpret_cast< ESLevent * >(argp1);
     res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
     if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_getHeader" "', argument " "2"" of type '" "char *""'");
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_getHeader" "', argument " "2"" of type '" "char const *""'");
     }
     arg2 = reinterpret_cast< char * >(buf2);
-    result = (char *)(arg1)->getHeader(arg2);
+    result = (char *)(arg1)->getHeader((char const *)arg2);
     ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ;
     
     if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
@@ -3330,6 +3330,34 @@
 }
 
 
+XS(_wrap_ESLconnection_disconnect) {
+  {
+    ESLconnection *arg1 = (ESLconnection *) 0 ;
+    int result;
+    void *argp1 = 0 ;
+    int res1 = 0 ;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 1) || (items > 1)) {
+      SWIG_croak("Usage: ESLconnection_disconnect(self);");
+    }
+    res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLconnection, 0 |  0 );
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_disconnect" "', argument " "1"" of type '" "ESLconnection *""'"); 
+    }
+    arg1 = reinterpret_cast< ESLconnection * >(argp1);
+    result = (int)(arg1)->disconnect();
+    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ;
+    
+    XSRETURN(argvi);
+  fail:
+    
+    SWIG_croak_null();
+  }
+}
+
+
 XS(_wrap_eslSetLogLevel) {
   {
     int arg1 ;
@@ -3435,6 +3463,7 @@
 {"ESLc::ESLconnection_execute", _wrap_ESLconnection_execute},
 {"ESLc::ESLconnection_setBlockingExecute", _wrap_ESLconnection_setBlockingExecute},
 {"ESLc::ESLconnection_setEventLock", _wrap_ESLconnection_setEventLock},
+{"ESLc::ESLconnection_disconnect", _wrap_ESLconnection_disconnect},
 {"ESLc::eslSetLogLevel", _wrap_eslSetLogLevel},
 {0,0}
 };

Modified: freeswitch/trunk/libs/esl/php/ESL.php
==============================================================================
--- freeswitch/trunk/libs/esl/php/ESL.php	(original)
+++ freeswitch/trunk/libs/esl/php/ESL.php	Mon Mar 23 14:55:02 2009
@@ -194,6 +194,10 @@
 	function setEventLock($val) {
 		return ESLconnection_setEventLock($this->_cPtr,$val);
 	}
+
+	function disconnect() {
+		return ESLconnection_disconnect($this->_cPtr);
+	}
 }
 
 

Modified: freeswitch/trunk/libs/esl/php/esl_wrap.cpp
==============================================================================
--- freeswitch/trunk/libs/esl/php/esl_wrap.cpp	(original)
+++ freeswitch/trunk/libs/esl/php/esl_wrap.cpp	Mon Mar 23 14:55:02 2009
@@ -1465,7 +1465,7 @@
   arg2 = (char *) Z_STRVAL_PP(args[1]);
   /*@SWIG@*/;
   
-  result = (char *)(arg1)->getHeader(arg2);
+  result = (char *)(arg1)->getHeader((char const *)arg2);
   {
     if(!result) {
       ZVAL_NULL(return_value);
@@ -2313,6 +2313,32 @@
 }
 
 
+ZEND_NAMED_FUNCTION(_wrap_ESLconnection_disconnect) {
+  ESLconnection *arg1 = (ESLconnection *) 0 ;
+  int result;
+  zval **args[1];
+  
+  SWIG_ResetError();
+  if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) {
+    WRONG_PARAM_COUNT;
+  }
+  
+  {
+    if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_ESLconnection, 0) < 0) {
+      SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of ESLconnection_disconnect. Expected SWIGTYPE_p_ESLconnection");
+    }
+  }
+  if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL");
+  result = (int)(arg1)->disconnect();
+  {
+    ZVAL_LONG(return_value,result);
+  }
+  return;
+fail:
+  zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg());
+}
+
+
 ZEND_NAMED_FUNCTION(_wrap_eslSetLogLevel) {
   int arg1 ;
   zval **args[1];
@@ -2391,6 +2417,7 @@
  SWIG_ZEND_NAMED_FE(eslconnection_execute,_wrap_ESLconnection_execute,NULL)
  SWIG_ZEND_NAMED_FE(eslconnection_setblockingexecute,_wrap_ESLconnection_setBlockingExecute,NULL)
  SWIG_ZEND_NAMED_FE(eslconnection_seteventlock,_wrap_ESLconnection_setEventLock,NULL)
+ SWIG_ZEND_NAMED_FE(eslconnection_disconnect,_wrap_ESLconnection_disconnect,NULL)
  SWIG_ZEND_NAMED_FE(eslsetloglevel,_wrap_eslSetLogLevel,NULL)
 {NULL, NULL, NULL}
 };

Modified: freeswitch/trunk/libs/esl/php/php_ESL.h
==============================================================================
--- freeswitch/trunk/libs/esl/php/php_ESL.h	(original)
+++ freeswitch/trunk/libs/esl/php/php_ESL.h	Mon Mar 23 14:55:02 2009
@@ -64,5 +64,6 @@
 ZEND_NAMED_FUNCTION(_wrap_ESLconnection_execute);
 ZEND_NAMED_FUNCTION(_wrap_ESLconnection_setBlockingExecute);
 ZEND_NAMED_FUNCTION(_wrap_ESLconnection_setEventLock);
+ZEND_NAMED_FUNCTION(_wrap_ESLconnection_disconnect);
 ZEND_NAMED_FUNCTION(_wrap_eslSetLogLevel);
 #endif /* PHP_ESL_H */

Modified: freeswitch/trunk/libs/esl/python/ESL.py
==============================================================================
--- freeswitch/trunk/libs/esl/python/ESL.py	(original)
+++ freeswitch/trunk/libs/esl/python/ESL.py	Mon Mar 23 14:55:02 2009
@@ -91,6 +91,7 @@
     def execute(*args): return apply(_ESL.ESLconnection_execute, args)
     def setBlockingExecute(*args): return apply(_ESL.ESLconnection_setBlockingExecute, args)
     def setEventLock(*args): return apply(_ESL.ESLconnection_setEventLock, args)
+    def disconnect(*args): return apply(_ESL.ESLconnection_disconnect, args)
 ESLconnection_swigregister = _ESL.ESLconnection_swigregister
 ESLconnection_swigregister(ESLconnection)
 

Modified: freeswitch/trunk/libs/esl/python/esl_wrap.cpp
==============================================================================
--- freeswitch/trunk/libs/esl/python/esl_wrap.cpp	(original)
+++ freeswitch/trunk/libs/esl/python/esl_wrap.cpp	Mon Mar 23 14:55:02 2009
@@ -3298,10 +3298,10 @@
   arg1 = reinterpret_cast< ESLevent * >(argp1);
   res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_getHeader" "', argument " "2"" of type '" "char *""'");
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_getHeader" "', argument " "2"" of type '" "char const *""'");
   }
   arg2 = reinterpret_cast< char * >(buf2);
-  result = (char *)(arg1)->getHeader(arg2);
+  result = (char *)(arg1)->getHeader((char const *)arg2);
   resultobj = SWIG_FromCharPtr((const char *)result);
   if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
   return resultobj;
@@ -4173,6 +4173,28 @@
 }
 
 
+SWIGINTERN PyObject *_wrap_ESLconnection_disconnect(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  ESLconnection *arg1 = (ESLconnection *) 0 ;
+  int result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:ESLconnection_disconnect",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLconnection, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_disconnect" "', argument " "1"" of type '" "ESLconnection *""'"); 
+  }
+  arg1 = reinterpret_cast< ESLconnection * >(argp1);
+  result = (int)(arg1)->disconnect();
+  resultobj = SWIG_From_int(static_cast< int >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
 SWIGINTERN PyObject *ESLconnection_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *obj;
   if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
@@ -4237,6 +4259,7 @@
 	 { (char *)"ESLconnection_execute", _wrap_ESLconnection_execute, METH_VARARGS, NULL},
 	 { (char *)"ESLconnection_setBlockingExecute", _wrap_ESLconnection_setBlockingExecute, METH_VARARGS, NULL},
 	 { (char *)"ESLconnection_setEventLock", _wrap_ESLconnection_setEventLock, METH_VARARGS, NULL},
+	 { (char *)"ESLconnection_disconnect", _wrap_ESLconnection_disconnect, METH_VARARGS, NULL},
 	 { (char *)"ESLconnection_swigregister", ESLconnection_swigregister, METH_VARARGS, NULL},
 	 { (char *)"eslSetLogLevel", _wrap_eslSetLogLevel, METH_VARARGS, NULL},
 	 { NULL, NULL, 0, NULL }

Modified: freeswitch/trunk/libs/esl/ruby/esl_wrap.cpp
==============================================================================
--- freeswitch/trunk/libs/esl/ruby/esl_wrap.cpp	(original)
+++ freeswitch/trunk/libs/esl/ruby/esl_wrap.cpp	Mon Mar 23 14:55:02 2009
@@ -2414,10 +2414,10 @@
   arg1 = reinterpret_cast< ESLevent * >(argp1);
   res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2);
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char *","getHeader", 2, argv[0] ));
+    SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char const *","getHeader", 2, argv[0] ));
   }
   arg2 = reinterpret_cast< char * >(buf2);
-  result = (char *)(arg1)->getHeader(arg2);
+  result = (char *)(arg1)->getHeader((char const *)arg2);
   vresult = SWIG_FromCharPtr((const char *)result);
   if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
   return vresult;
@@ -3306,6 +3306,30 @@
 
 
 SWIGINTERN VALUE
+_wrap_ESLconnection_disconnect(int argc, VALUE *argv, VALUE self) {
+  ESLconnection *arg1 = (ESLconnection *) 0 ;
+  int result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  VALUE vresult = Qnil;
+  
+  if ((argc < 0) || (argc > 0)) {
+    rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
+  }
+  res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ESLconnection, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "ESLconnection *","disconnect", 1, self )); 
+  }
+  arg1 = reinterpret_cast< ESLconnection * >(argp1);
+  result = (int)(arg1)->disconnect();
+  vresult = SWIG_From_int(static_cast< int >(result));
+  return vresult;
+fail:
+  return Qnil;
+}
+
+
+SWIGINTERN VALUE
 _wrap_eslSetLogLevel(int argc, VALUE *argv, VALUE self) {
   int arg1 ;
   int val1 ;
@@ -3658,6 +3682,7 @@
   rb_define_method(cESLconnection.klass, "execute", VALUEFUNC(_wrap_ESLconnection_execute), -1);
   rb_define_method(cESLconnection.klass, "setBlockingExecute", VALUEFUNC(_wrap_ESLconnection_setBlockingExecute), -1);
   rb_define_method(cESLconnection.klass, "setEventLock", VALUEFUNC(_wrap_ESLconnection_setEventLock), -1);
+  rb_define_method(cESLconnection.klass, "disconnect", VALUEFUNC(_wrap_ESLconnection_disconnect), -1);
   cESLconnection.mark = 0;
   cESLconnection.destroy = (void (*)(void *)) free_ESLconnection;
   cESLconnection.trackObjects = 0;

Modified: freeswitch/trunk/libs/esl/src/esl_oop.cpp
==============================================================================
--- freeswitch/trunk/libs/esl/src/esl_oop.cpp	(original)
+++ freeswitch/trunk/libs/esl/src/esl_oop.cpp	Mon Mar 23 14:55:02 2009
@@ -33,6 +33,15 @@
 
 }
 
+int ESLconnection::disconnect()
+{
+	if (handle.connected) {
+        return esl_disconnect(&handle);
+    }
+
+	return 0;
+}
+
 int ESLconnection::connected()
 {
 	return handle.connected;

Modified: freeswitch/trunk/libs/esl/src/include/esl_oop.h
==============================================================================
--- freeswitch/trunk/libs/esl/src/include/esl_oop.h	(original)
+++ freeswitch/trunk/libs/esl/src/include/esl_oop.h	Mon Mar 23 14:55:02 2009
@@ -90,6 +90,7 @@
 	int execute(const char *app, const char *arg = NULL, const char *uuid = NULL);
 	int setBlockingExecute(const char *val);
 	int setEventLock(const char *val);
+	int disconnect(void);
 };
 
 void eslSetLogLevel(int level);

Added: freeswitch/trunk/libs/esl/test.pl
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/esl/test.pl	Mon Mar 23 14:55:02 2009
@@ -0,0 +1,21 @@
+#!/usr/bin/perl
+require ESL;
+use Data::Dumper;
+
+my $fd = fileno(STDIN);
+my $con = new ESL::ESLconnection($fd);
+my $info = $con->getInfo();
+
+select STDERR;
+
+print $info->serialize();
+
+my $uuid = $info->getHeader("unique-id");
+
+$con->execute("answer", "", $uuid);
+$con->execute("playback", "/ram/swimp.raw", $uuid);
+
+
+$con->disconnect();
+
+



More information about the Freeswitch-svn mailing list