[core] add new prompt functionality to ask for pin over dialogbox

This commit is contained in:
Anthony Minessale 2020-04-10 16:48:24 +00:00 committed by Andrey Volk
parent ffbe8500ec
commit b18ea498df
5 changed files with 55 additions and 1 deletions

View File

@ -1069,6 +1069,7 @@ SWITCH_DECLARE(void) switch_dial_handle_list_add_global_var(switch_dial_handle_l
SWITCH_DECLARE(void) switch_dial_handle_list_add_global_var_printf(switch_dial_handle_list_t *hl, const char *var, const char *fmt, ...); SWITCH_DECLARE(void) switch_dial_handle_list_add_global_var_printf(switch_dial_handle_list_t *hl, const char *var, const char *fmt, ...);
SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_orig_and_bridge(switch_core_session_t *session, const char *data, switch_dial_handle_list_t *hl, switch_call_cause_t *cause); SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_orig_and_bridge(switch_core_session_t *session, const char *data, switch_dial_handle_list_t *hl, switch_call_cause_t *cause);
SWITCH_DECLARE(switch_status_t) switch_ivr_orig_and_bridge(switch_core_session_t *session, const char *data, switch_dial_handle_t *dh, switch_call_cause_t *cause); SWITCH_DECLARE(switch_status_t) switch_ivr_orig_and_bridge(switch_core_session_t *session, const char *data, switch_dial_handle_t *dh, switch_call_cause_t *cause);
SWITCH_DECLARE(switch_status_t) switch_ivr_send_prompt(switch_core_session_t *session, const char *type, const char *text, const char *regex);
SWITCH_DECLARE(switch_status_t) switch_ivr_play_and_collect_input(switch_core_session_t *session, SWITCH_DECLARE(switch_status_t) switch_ivr_play_and_collect_input(switch_core_session_t *session,
const char *prompt, const char *prompt,

View File

@ -1173,6 +1173,7 @@ typedef enum {
SWITCH_MESSAGE_RESAMPLE_EVENT, SWITCH_MESSAGE_RESAMPLE_EVENT,
SWITCH_MESSAGE_HEARTBEAT_EVENT, SWITCH_MESSAGE_HEARTBEAT_EVENT,
SWITCH_MESSAGE_INDICATE_SESSION_ID, SWITCH_MESSAGE_INDICATE_SESSION_ID,
SWITCH_MESSAGE_INDICATE_PROMPT,
SWITCH_MESSAGE_INVALID SWITCH_MESSAGE_INVALID
} switch_core_session_message_types_t; } switch_core_session_message_types_t;

View File

@ -2623,6 +2623,40 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_
} }
break; break;
case SWITCH_MESSAGE_INDICATE_PROMPT:
{
const char *type = NULL, *text = NULL, *regex = NULL;
cJSON *jmsg = NULL, *params = NULL;
jsock_t *jsock = NULL;
if ((jsock = get_jsock(tech_pvt->jsock_uuid))) {
type = msg->string_array_arg[0];
text = msg->string_array_arg[1];
regex = msg->string_array_arg[2];
if (type && (!strcasecmp(type, "dtmf") || !strcasecmp(type, "message")) && text) {
jmsg = jrpc_new_req("verto.prompt", tech_pvt->call_id, &params);
cJSON_AddItemToObject(params, "type", cJSON_CreateString(type));
cJSON_AddItemToObject(params, "text", cJSON_CreateString(text));
if (regex) {
cJSON_AddItemToObject(params, "regex", cJSON_CreateString(regex));
}
jsock_queue_event(jsock, &jmsg, SWITCH_TRUE);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Error Parsing Media Params\n");
r = SWITCH_STATUS_FALSE;
}
switch_thread_rwlock_unlock(jsock->rwlock);
}
}
break;
case SWITCH_MESSAGE_INDICATE_MEDIA_RENEG: case SWITCH_MESSAGE_INDICATE_MEDIA_RENEG:
{ {
jsock_t *jsock = NULL; jsock_t *jsock = NULL;

View File

@ -827,6 +827,8 @@ static const char *message_names[] = {
"RING_EVENT", "RING_EVENT",
"RESAMPLE_EVENT", "RESAMPLE_EVENT",
"HEARTBEAT_EVENT", "HEARTBEAT_EVENT",
"SESSION_ID",
"PROMPT",
"INVALID" "INVALID"
}; };

View File

@ -1506,6 +1506,22 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess
return status; return status;
} }
SWITCH_DECLARE(switch_status_t) switch_ivr_send_prompt(switch_core_session_t *session, const char *type, const char *text, const char *regex)
{
switch_core_session_message_t msg = { 0 };
msg.message_id = SWITCH_MESSAGE_INDICATE_PROMPT;
msg.string_array_arg[0] = type;
msg.string_array_arg[1] = text;
msg.string_array_arg[2] = regex;
msg.from = __FILE__;
switch_core_session_receive_message(session, &msg);
return SWITCH_STATUS_SUCCESS;
}
SWITCH_DECLARE(switch_status_t) switch_ivr_hold(switch_core_session_t *session, const char *message, switch_bool_t moh) SWITCH_DECLARE(switch_status_t) switch_ivr_hold(switch_core_session_t *session, const char *message, switch_bool_t moh)
{ {
switch_core_session_message_t msg = { 0 }; switch_core_session_message_t msg = { 0 };