mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 01:26:58 +00:00
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:
@@ -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:
|
||||
|
||||
|
@@ -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()
|
||||
|
@@ -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>
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user