fix esl sendevent issue and change the sendEvent method to return the reply text like sendRecv etc

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16921 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale
2010-03-05 23:10:41 +00:00
parent 8111b4beb4
commit 1baa8d5eee
17 changed files with 93 additions and 80 deletions

View File

@@ -453,14 +453,12 @@ ESL_DECLARE(esl_status_t) esl_sendevent(esl_handle_t *handle, esl_event_t *event
snprintf(event_buf, sizeof(event_buf), "sendevent %s\n", esl_event_name(event->event_id));
if (send(handle->sock, event_buf, strlen(event_buf), 0)) goto fail;
if (send(handle->sock, txt, strlen(txt), 0)) goto fail;
if (send(handle->sock, "\n\n", 2, 0)) goto fail;
if (send(handle->sock, event_buf, strlen(event_buf), 0) <= 0) goto fail;
if (send(handle->sock, txt, strlen(txt), 0) <= 0) goto fail;
free(txt);
return ESL_SUCCESS;
return esl_recv(handle);
fail:

View File

@@ -186,9 +186,18 @@ ESLevent *ESLconnection::executeAsync(const char *app, const char *arg, const ch
return NULL;
}
int ESLconnection::sendEvent(ESLevent *send_me)
ESLevent *ESLconnection::sendEvent(ESLevent *send_me)
{
return esl_sendevent(&handle, send_me->event);
if (esl_sendevent(&handle, send_me->event) == ESL_SUCCESS) {
esl_event_t *e = handle.last_ievent ? handle.last_ievent : handle.last_event;
if (e) {
esl_event_t *event;
esl_event_dup(&event, e);
return new ESLevent(event, 1);
}
}
return new ESLevent("server_disconnected");
}
ESLevent *ESLconnection::recvEvent()

View File

@@ -198,6 +198,7 @@ typedef enum {
#define esl_safe_free(_x) if (_x) free(_x); _x = NULL
#define esl_strlen_zero(s) (!s || *(s) == '\0')
#define esl_strlen_zero_buf(s) (*(s) == '\0')
#define end_of(_s) *(*_s == '\0' ? _s : _s + strlen(_s) - 1)
#ifdef WIN32
#include <winsock2.h>

View File

@@ -83,7 +83,7 @@ class ESLconnection {
ESLevent *sendRecv(const char *cmd);
ESLevent *api(const char *cmd, const char *arg = NULL);
ESLevent *bgapi(const char *cmd, const char *arg = NULL);
int sendEvent(ESLevent *send_me);
ESLevent *sendEvent(ESLevent *send_me);
ESLevent *recvEvent();
ESLevent *recvEventTimed(int ms);
ESLevent *filter(const char *header, const char *value);