/*
* mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
- * Copyright (C) 2013, Grasshopper
+ * Copyright (C) 2013-2014, Grasshopper
*
* Version: MPL 1.1
*
const void *jid;
void *component;
switch_core_hash_this(hi, &jid, NULL, &component);
- rayo_component_send_complete(RAYO_COMPONENT(component), COMPONENT_COMPLETE_STOP);
+ rayo_component_send_complete(RAYO_COMPONENT(component), COMPONENT_COMPLETE_HANGUP);
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Removing DTMF callback\n");
switch_core_event_hook_remove_recv_dtmf(session, input_handler_on_dtmf);
if (output->stop) {
rayo_component_send_complete(context->component, COMPONENT_COMPLETE_STOP);
} else {
- rayo_component_send_complete(context->component, OUTPUT_FINISH);
+ if (!strcmp(RAYO_ACTOR(context->component)->type, RAT_CALL_COMPONENT)) {
+ /* call output... check for hangup */
+ switch_core_session_t *session = switch_core_session_locate(context->component->parent->id);
+ if (session) {
+ if (switch_channel_get_state(switch_core_session_get_channel(session)) >= CS_HANGUP) {
+ rayo_component_send_complete(context->component, COMPONENT_COMPLETE_HANGUP);
+ } else {
+ rayo_component_send_complete(context->component, OUTPUT_FINISH);
+ }
+ switch_core_session_rwunlock(session);
+ } else {
+ /* session is gone */
+ rayo_component_send_complete(context->component, COMPONENT_COMPLETE_HANGUP);
+ }
+ } else {
+ /* mixer output... finished */
+ rayo_component_send_complete(context->component, OUTPUT_FINISH);
+ }
}
- /* TODO hangup / timed out */
+ /* TODO timed out */
/* cleanup internals */
switch_safe_free(context->ssml);
PROMPT_COMPONENT(prompt)->state = PCS_INPUT_OUTPUT;
/* send ref to client */
rayo_component_send_start(RAYO_COMPONENT(prompt), PROMPT_COMPONENT(prompt)->iq);
- iks_delete(PROMPT_COMPONENT(prompt)->iq);
break;
case PCS_START_INPUT_TIMERS:
PROMPT_COMPONENT(prompt)->input_jid = switch_core_strdup(RAYO_POOL(prompt), msg->from_jid);
PROMPT_COMPONENT(prompt)->state = PCS_INPUT;
/* send ref to client */
rayo_component_send_start(RAYO_COMPONENT(prompt), PROMPT_COMPONENT(prompt)->iq);
- iks_delete(PROMPT_COMPONENT(prompt)->iq);
start_input_timers(PROMPT_COMPONENT(prompt));
break;
case PCS_DONE:
RAYO_SEND_REPLY(prompt, RAYO_COMPONENT(prompt)->client_jid, iq);
/* done */
+ iks_delete(PROMPT_COMPONENT(prompt)->iq);
RAYO_UNLOCK(prompt);
RAYO_DESTROY(prompt);
break;
case PCS_START_INPUT:
- /* send presence error to client */
PROMPT_COMPONENT(prompt)->state = PCS_DONE;
iks_delete(PROMPT_COMPONENT(prompt)->iq);
- rayo_component_send_complete(RAYO_COMPONENT(prompt), COMPONENT_COMPLETE_ERROR);
+ if (iks_find(error, "item-not-found")) {
+ /* call is gone (hangup) */
+ rayo_component_send_complete(RAYO_COMPONENT(prompt), COMPONENT_COMPLETE_HANGUP);
+ } else {
+ /* send presence error to client */
+ rayo_component_send_complete(RAYO_COMPONENT(prompt), COMPONENT_COMPLETE_ERROR);
+ }
break;
case PCS_START_INPUT_OUTPUT:
PROMPT_COMPONENT(prompt)->state = PCS_DONE_STOP_OUTPUT;
RAYO_SEND_REPLY(prompt, RAYO_COMPONENT(prompt)->client_jid, iq);
/* done */
+ iks_delete(PROMPT_COMPONENT(prompt)->iq);
RAYO_UNLOCK(prompt);
RAYO_DESTROY(prompt);
presence = iks_copy(presence);
iks_insert_attrib(presence, "from", RAYO_JID(prompt));
iks_insert_attrib(presence, "to", RAYO_COMPONENT(prompt)->client_jid);
+ iks_delete(PROMPT_COMPONENT(prompt)->iq);
rayo_component_send_complete_event(RAYO_COMPONENT(prompt), presence);
break;
case PCS_OUTPUT:
PROMPT_COMPONENT(prompt)->state = PCS_START_INPUT;
/* start input with timers enabled and barge events disabled */
start_input(PROMPT_COMPONENT(prompt), 1, 0);
- iks_delete(PROMPT_COMPONENT(prompt)->iq);
break;
case PCS_START_INPUT_OUTPUT:
/* output finished before input started */
break;
case PCS_DONE_STOP_OUTPUT:
if (PROMPT_COMPONENT(prompt)->complete) {
+ iks_delete(PROMPT_COMPONENT(prompt)->iq);
rayo_component_send_complete_event(RAYO_COMPONENT(prompt), PROMPT_COMPONENT(prompt)->complete);
}
break;