mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-13 12:40:17 +00:00
Make XML fetch reply ACKs distinguishable, update freeswitch.erl
This commit is contained in:
parent
1277ac473e
commit
9d44ed0409
@ -19,7 +19,7 @@
|
|||||||
get_event_header/2, get_event_body/1,
|
get_event_header/2, get_event_body/1,
|
||||||
get_event_name/1, getpid/1, sendmsg/3,
|
get_event_name/1, getpid/1, sendmsg/3,
|
||||||
sendevent/3, sendevent_custom/3, handlecall/2, handlecall/3, start_fetch_handler/5,
|
sendevent/3, sendevent_custom/3, handlecall/2, handlecall/3, start_fetch_handler/5,
|
||||||
start_log_handler/4, start_event_handler/4]).
|
start_log_handler/4, start_event_handler/4, fetch_reply/3]).
|
||||||
-define(TIMEOUT, 5000).
|
-define(TIMEOUT, 5000).
|
||||||
|
|
||||||
%% @doc Return the value for a specific header in an event or `{error,notfound}'.
|
%% @doc Return the value for a specific header in an event or `{error,notfound}'.
|
||||||
@ -58,6 +58,18 @@ send(Node, Term) ->
|
|||||||
timeout
|
timeout
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
fetch_reply(Node, FetchID, Reply) ->
|
||||||
|
{send, Node} ! {fetch_reply, FetchID, Reply},
|
||||||
|
receive
|
||||||
|
{ok, FetchID} ->
|
||||||
|
ok;
|
||||||
|
{error, FetchID, Reason} ->
|
||||||
|
{error, Reason}
|
||||||
|
after ?TIMEOUT ->
|
||||||
|
timeout
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
%% @doc Make a blocking API call to FreeSWITCH. The result of the API call is
|
%% @doc Make a blocking API call to FreeSWITCH. The result of the API call is
|
||||||
%% returned or `timeout' if FreeSWITCH fails to respond.
|
%% returned or `timeout' if FreeSWITCH fails to respond.
|
||||||
api(Node, Cmd, Args) ->
|
api(Node, Cmd, Args) ->
|
||||||
@ -268,7 +280,6 @@ start_handler(Node, Type, Module, Function, State) ->
|
|||||||
{foo, Node} ! Type,
|
{foo, Node} ! Type,
|
||||||
receive
|
receive
|
||||||
ok ->
|
ok ->
|
||||||
io:format("OK!!!!!!!~n"),
|
|
||||||
Self ! {Type, {ok, self()}},
|
Self ! {Type, {ok, self()}},
|
||||||
apply(Module, Function, [Node, State]);
|
apply(Module, Function, [Node, State]);
|
||||||
{error,Reason} ->
|
{error,Reason} ->
|
||||||
|
@ -205,18 +205,22 @@ static switch_status_t handle_msg_fetch_reply(listener_t *listener, ei_x_buff *
|
|||||||
/* Relay the status back to the fetch responder. */
|
/* Relay the status back to the fetch responder. */
|
||||||
if (status == is_waiting) {
|
if (status == is_waiting) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Found waiting slot for %s\n", uuid_str);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Found waiting slot for %s\n", uuid_str);
|
||||||
|
ei_x_encode_tuple_header(rbuf, 2);
|
||||||
ei_x_encode_atom(rbuf, "ok");
|
ei_x_encode_atom(rbuf, "ok");
|
||||||
|
_ei_x_encode_string(rbuf, uuid_str);
|
||||||
/* Return here to avoid freeing the reply. */
|
/* Return here to avoid freeing the reply. */
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
} else if (status == is_timeout) {
|
} else if (status == is_timeout) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Handler for %s timed out\n", uuid_str);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Handler for %s timed out\n", uuid_str);
|
||||||
ei_x_encode_tuple_header(rbuf, 2);
|
ei_x_encode_tuple_header(rbuf, 3);
|
||||||
ei_x_encode_atom(rbuf, "error");
|
ei_x_encode_atom(rbuf, "error");
|
||||||
|
_ei_x_encode_string(rbuf, uuid_str);
|
||||||
ei_x_encode_atom(rbuf, "timeout");
|
ei_x_encode_atom(rbuf, "timeout");
|
||||||
} else {
|
} else {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Found filled slot for %s\n", uuid_str);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Found filled slot for %s\n", uuid_str);
|
||||||
ei_x_encode_tuple_header(rbuf, 2);
|
ei_x_encode_tuple_header(rbuf, 3);
|
||||||
ei_x_encode_atom(rbuf, "error");
|
ei_x_encode_atom(rbuf, "error");
|
||||||
|
_ei_x_encode_string(rbuf, uuid_str);
|
||||||
ei_x_encode_atom(rbuf, "duplicate_response");
|
ei_x_encode_atom(rbuf, "duplicate_response");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -460,6 +460,11 @@ static switch_xml_t erlang_fetch(const char *sectionstr, const char *tag_name, c
|
|||||||
|
|
||||||
ei_get_type(rep->buff, &rep->index, &type, &size);
|
ei_get_type(rep->buff, &rep->index, &type, &size);
|
||||||
|
|
||||||
|
if (type == ERL_NIL_EXT) {
|
||||||
|
// empty string returned
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
if (type != ERL_STRING_EXT && type != ERL_BINARY_EXT) { /* XXX no unicode or character codes > 255 */
|
if (type != ERL_STRING_EXT && type != ERL_BINARY_EXT) { /* XXX no unicode or character codes > 255 */
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "XML fetch response contained non ASCII characters? (was type %d of size %d)\n", type,
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "XML fetch response contained non ASCII characters? (was type %d of size %d)\n", type,
|
||||||
size);
|
size);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user