change api to return event on filter command

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12488 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2009-03-06 19:24:10 +00:00
parent 734b2d3b82
commit f3acb35505
9 changed files with 40 additions and 20 deletions

View File

@ -2537,7 +2537,7 @@ static int _wrap_ESLconnection_filter(lua_State* L) {
ESLconnection *arg1 = (ESLconnection *) 0 ;
char *arg2 = (char *) 0 ;
char *arg3 = (char *) 0 ;
int result;
ESLevent *result = 0 ;
SWIG_check_num_args("filter",3,3)
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("filter",1,"ESLconnection *");
@ -2550,9 +2550,9 @@ static int _wrap_ESLconnection_filter(lua_State* L) {
arg2 = (char *)lua_tostring(L, 2);
arg3 = (char *)lua_tostring(L, 3);
result = (int)(arg1)->filter((char const *)arg2,(char const *)arg3);
result = (ESLevent *)(arg1)->filter((char const *)arg2,(char const *)arg3);
SWIG_arg=0;
lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
SWIG_NewPointerObj(L,result,SWIGTYPE_p_ESLevent,0); SWIG_arg++;
return SWIG_arg;
if(0) SWIG_fail;

View File

@ -3092,7 +3092,7 @@ XS(_wrap_ESLconnection_filter) {
ESLconnection *arg1 = (ESLconnection *) 0 ;
char *arg2 = (char *) 0 ;
char *arg3 = (char *) 0 ;
int result;
ESLevent *result = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
int res2 ;
@ -3122,8 +3122,8 @@ XS(_wrap_ESLconnection_filter) {
SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_filter" "', argument " "3"" of type '" "char const *""'");
}
arg3 = reinterpret_cast< char * >(buf3);
result = (int)(arg1)->filter((char const *)arg2,(char const *)arg3);
ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ;
result = (ESLevent *)(arg1)->filter((char const *)arg2,(char const *)arg3);
ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, 0 | SWIG_SHADOW); argvi++ ;
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
if (alloc3 == SWIG_NEWOBJ) delete[] buf3;

View File

@ -26,7 +26,17 @@ for(;;) {
printf "Connected call %s, from %s\n", $uuid, $info->getHeader("caller-caller-id-number");
$con->sendRecv("myevents");
$e = $con->filter("unique-id", $uuid);
if ($e) {
print $e->serialize();
} else {
printf("WTF?\n");
}
$con->events("plain", "all");
#$con->sendRecv("myevents");
$con->execute("answer");
$con->execute("playback", "/ram/swimp.raw");

View File

@ -170,7 +170,8 @@ class ESLconnection {
}
function filter($header,$value) {
return ESLconnection_filter($this->_cPtr,$header,$value);
$r=ESLconnection_filter($this->_cPtr,$header,$value);
return is_resource($r) ? new ESLevent($r) : $r;
}
function events($etype,$value) {

View File

@ -2120,7 +2120,7 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_filter) {
ESLconnection *arg1 = (ESLconnection *) 0 ;
char *arg2 = (char *) 0 ;
char *arg3 = (char *) 0 ;
int result;
ESLevent *result = 0 ;
zval **args[3];
SWIG_ResetError();
@ -2146,9 +2146,9 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_filter) {
arg3 = (char *) Z_STRVAL_PP(args[2]);
/*@SWIG@*/;
result = (int)(arg1)->filter((char const *)arg2,(char const *)arg3);
result = (ESLevent *)(arg1)->filter((char const *)arg2,(char const *)arg3);
{
ZVAL_LONG(return_value,result);
SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 0);
}
return;
fail:

View File

@ -3956,7 +3956,7 @@ SWIGINTERN PyObject *_wrap_ESLconnection_filter(PyObject *SWIGUNUSEDPARM(self),
ESLconnection *arg1 = (ESLconnection *) 0 ;
char *arg2 = (char *) 0 ;
char *arg3 = (char *) 0 ;
int result;
ESLevent *result = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
int res2 ;
@ -3985,8 +3985,8 @@ SWIGINTERN PyObject *_wrap_ESLconnection_filter(PyObject *SWIGUNUSEDPARM(self),
SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_filter" "', argument " "3"" of type '" "char const *""'");
}
arg3 = reinterpret_cast< char * >(buf3);
result = (int)(arg1)->filter((char const *)arg2,(char const *)arg3);
resultobj = SWIG_From_int(static_cast< int >(result));
result = (ESLevent *)(arg1)->filter((char const *)arg2,(char const *)arg3);
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, 0 | 0 );
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
return resultobj;

View File

@ -3087,7 +3087,7 @@ _wrap_ESLconnection_filter(int argc, VALUE *argv, VALUE self) {
ESLconnection *arg1 = (ESLconnection *) 0 ;
char *arg2 = (char *) 0 ;
char *arg3 = (char *) 0 ;
int result;
ESLevent *result = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
int res2 ;
@ -3116,8 +3116,8 @@ _wrap_ESLconnection_filter(int argc, VALUE *argv, VALUE self) {
SWIG_exception_fail(SWIG_ArgError(res3), Ruby_Format_TypeError( "", "char const *","filter", 3, argv[1] ));
}
arg3 = reinterpret_cast< char * >(buf3);
result = (int)(arg1)->filter((char const *)arg2,(char const *)arg3);
vresult = SWIG_From_int(static_cast< int >(result));
result = (ESLevent *)(arg1)->filter((char const *)arg2,(char const *)arg3);
vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, 0 | 0 );
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
return vresult;

View File

@ -189,9 +189,18 @@ ESLevent *ESLconnection::recvEventTimed(int ms)
return NULL;
}
int ESLconnection::filter(const char *header, const char *value)
ESLevent *ESLconnection::filter(const char *header, const char *value)
{
return esl_filter(&handle, header, value);
esl_status_t status = esl_filter(&handle, header, value);
if (status == ESL_SUCCESS && handle.last_sr_event) {
esl_event_t *event;
esl_event_dup(&event, handle.last_sr_event);
return new ESLevent(event, 1);
}
return NULL;
}
int ESLconnection::events(const char *etype, const char *value)

View File

@ -86,7 +86,7 @@ class ESLconnection {
int sendEvent(ESLevent *send_me);
ESLevent *recvEvent();
ESLevent *recvEventTimed(int ms);
int filter(const char *header, const char *value);
ESLevent *filter(const char *header, const char *value);
int events(const char *etype, const char *value);
int execute(const char *app, const char *arg = NULL, const char *uuid = NULL);
int setBlockingExecute(const char *val);