提交 9089dddc authored 作者: Anthony Minessale's avatar Anthony Minessale

add work-around for php

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12121 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 4d6e89bd
......@@ -3,46 +3,5 @@
#include "esl_oop.h"
%}
class ESLevent {
public:
esl_event_t *event;
char *serialized_string;
int mine;
ESLevent(const char *type, const char *subclass_name = NULL);
virtual ~ESLevent();
const char *serialize(const char *format = NULL);
bool setPriority(esl_priority_t priority = ESL_PRIORITY_NORMAL);
const char *getHeader(char *header_name);
char *getBody(void);
const char *getType(void);
bool addBody(const char *value);
bool addHeader(const char *header_name, const char *value);
bool delHeader(const char *header_name);
};
class ESLconnection {
private:
esl_handle_t handle;
ESLevent *last_event_obj;
public:
ESLconnection(const char *host, const char *port, const char *password);
ESLconnection(int socket);
virtual ~ESLconnection();
int connected();
ESLevent *getInfo();
esl_status_t send(const char *cmd);
ESLevent *sendRecv(const char *cmd);
esl_status_t sendEvent(ESLevent *send_me);
ESLevent *recvEvent();
ESLevent *recvEventTimed(int ms);
esl_status_t filter(const char *header, const char *value);
esl_status_t events(const char *etype, const char *value);
esl_status_t execute(const char *app, const char *arg = NULL, const char *uuid = NULL);
int setBlockingExecute(const char *val);
int setEventLock(const char *val);
};
void eslSetLogLevel(int level);
%include "esl_oop.h"
差异被折叠。
差异被折叠。
......@@ -52,10 +52,10 @@ class ESLevent {
return null;
}
function __construct($type,$subclass_name=null) {
function __construct($type_or_wrap_me_or_me,$subclass_name_or_free_me=null) {
switch (func_num_args()) {
case 1: $r=new_ESLevent($type); break;
default: $r=new_ESLevent($type,$subclass_name);
case 1: $r=new_ESLevent($type_or_wrap_me_or_me); break;
default: $r=new_ESLevent($type_or_wrap_me_or_me,$subclass_name_or_free_me);
}
$this->_cPtr=$r;
}
......
差异被折叠。
......@@ -2,4 +2,6 @@
require_once('ESL.php');
$esl = new eslConnection('127.0.0.1', '8021', 'ClueCon');
echo $esl->sendRecv("api status");
$e = $esl->sendRecv("api status");
print $e->getBody();
差异被折叠。
#include <esl.h>
#include <esl_oop.h>
#define construct_common() memset(&handle, 0, sizeof(handle)); last_event_obj = NULL
#define connection_construct_common() memset(&handle, 0, sizeof(handle)); last_event_obj = NULL
#define event_construct_common() event = NULL; serialized_string = NULL; mine = 0
void eslSetLogLevel(int level)
{
......@@ -10,7 +11,7 @@ void eslSetLogLevel(int level)
ESLconnection::ESLconnection(const char *host, const char *port, const char *password)
{
construct_common();
connection_construct_common();
int x_port = atoi(port);
esl_connect(&handle, host, x_port, password);
......@@ -19,7 +20,7 @@ ESLconnection::ESLconnection(const char *host, const char *port, const char *pas
ESLconnection::ESLconnection(int socket)
{
construct_common();
connection_construct_common();
memset(&handle, 0, sizeof(handle));
esl_attach_handle(&handle, (esl_socket_t)socket, NULL);
}
......@@ -150,6 +151,8 @@ ESLevent::ESLevent(const char *type, const char *subclass_name)
{
esl_event_types_t event_id;
event_construct_common();
if (esl_name_event(type, &event_id) != ESL_SUCCESS) {
event_id = ESL_EVENT_MESSAGE;
}
......@@ -170,14 +173,28 @@ ESLevent::ESLevent(const char *type, const char *subclass_name)
ESLevent::ESLevent(esl_event_t *wrap_me, int free_me)
{
event_construct_common();
event = wrap_me;
mine = free_me;
serialized_string = NULL;
}
ESLevent::~ESLevent()
ESLevent::ESLevent(ESLevent *me)
{
/* workaround for silly php thing */
event = me->event;
mine = me->mine;
serialized_string = NULL;
me->event = NULL;
me->mine = 0;
esl_safe_free(me->serialized_string);
delete me;
}
ESLevent::~ESLevent()
{
if (serialized_string) {
free(serialized_string);
}
......
......@@ -51,6 +51,7 @@ class ESLevent {
ESLevent(const char *type, const char *subclass_name = NULL);
ESLevent(esl_event_t *wrap_me, int free_me = 0);
ESLevent(ESLevent *me);
virtual ~ESLevent();
const char *serialize(const char *format = NULL);
bool setPriority(esl_priority_t priority = ESL_PRIORITY_NORMAL);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论