This patch adds 2 important variables to the originate subsystem
originate_retries: This variable controls how many times the system should retry the entire dialstring before exiting on failure (default 1) originate_retry_sleep_ms: This variable controls how long in milliseconds to pause between retries (default 1000) *NOTE* when using the , and & symbols to call sequential or simultaneous channels in conjunction with this feature, the *entire* dialstring will be repeated as many times as you specify in ${originate_retries} Here is an example using the bridge application to originate the call. (The feature will also work anywhere else an origination can be made.) <extension name="1000"> <condition field="destination_number" expression="^1000$"> <action application="set" data="originate_retries=10"/> <action application="set" data="originate_retry_sleep_ms=1000"/> <action application="bridge" data="sofia/$${domain}/1000@somehost.com"/> </condition> </extension> git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4776 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
c5e0757737
commit
4450a80bd8
|
@ -2498,7 +2498,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
|
|||
switch_frame_t *read_frame = NULL;
|
||||
switch_memory_pool_t *pool = NULL;
|
||||
int r = 0, i, and_argc = 0, or_argc = 0;
|
||||
int32_t idx = IDX_NADA;
|
||||
int32_t sleep_ms = 1000, try =0, retries = 1, idx = IDX_NADA;
|
||||
switch_codec_t write_codec = {0};
|
||||
switch_frame_t write_frame = {0};
|
||||
uint8_t fdata[1024], pass = 0;
|
||||
|
@ -2512,6 +2512,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
|
|||
switch_event_t *var_event = NULL;
|
||||
uint8_t fail_on_single_reject = 0;
|
||||
uint8_t ring_ready = 0;
|
||||
char *loop_data = NULL;
|
||||
|
||||
write_frame.data = fdata;
|
||||
|
||||
*bleg = NULL;
|
||||
|
@ -2605,7 +2607,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
|
|||
}
|
||||
}
|
||||
|
||||
// When using the AND operator, the fail_on_single_reject flage may be set in order to indicate that a single
|
||||
// When using the AND operator, the fail_on_single_reject flag may be set in order to indicate that a single
|
||||
// rejections should terminate the attempt rather than a timeout, answer, or rejection by all.
|
||||
if ((var = switch_event_get_header(var_event, "fail_on_single_reject")) && switch_true(var)) {
|
||||
fail_on_single_reject = 1;
|
||||
|
@ -2619,6 +2621,28 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
|
|||
early_ok = 0;
|
||||
}
|
||||
|
||||
if ((var_val = switch_event_get_header(var_event, "originate_retries")) && switch_true(var_val)) {
|
||||
int32_t tmp;
|
||||
tmp = atoi(var_val);
|
||||
if (tmp > 0 && tmp < 101) {
|
||||
retries = tmp;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"Invalid originate_retries setting of %d ignored, value must be between 1 and 100\n", tmp);
|
||||
}
|
||||
}
|
||||
|
||||
if ((var_val = switch_event_get_header(var_event, "originate_retry_sleep_ms")) && switch_true(var_val)) {
|
||||
int32_t tmp;
|
||||
tmp = atoi(var_val);
|
||||
if (tmp > 500 && tmp < 60000) {
|
||||
sleep_ms = tmp;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"Invalid originate_retry_sleep_ms setting of %d ignored, value must be between 500 and 60000\n", tmp);
|
||||
}
|
||||
}
|
||||
|
||||
if (!cid_name_override) {
|
||||
cid_name_override = switch_event_get_header(var_event, "origination_caller_id_name");
|
||||
}
|
||||
|
@ -2628,7 +2652,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
|
|||
}
|
||||
|
||||
|
||||
or_argc = switch_separate_string(data, '|', pipe_names, (sizeof(pipe_names) / sizeof(pipe_names[0])));
|
||||
|
||||
for (try = 0; try < retries; try++) {
|
||||
switch_safe_free(loop_data);
|
||||
assert(loop_data = strdup(data));
|
||||
or_argc = switch_separate_string(loop_data, '|', pipe_names, (sizeof(pipe_names) / sizeof(pipe_names[0])));
|
||||
|
||||
if (caller_channel && or_argc > 1 && !ringback_data) {
|
||||
switch_channel_ring_ready(caller_channel);
|
||||
|
@ -2655,6 +2683,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
|
|||
var = NULL;
|
||||
to = 0;
|
||||
|
||||
if (try > 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Originate attempt %d/%d in %d ms\n", try + 1, retries, sleep_ms);
|
||||
switch_yield(sleep_ms * 1000);
|
||||
}
|
||||
|
||||
and_argc = switch_separate_string(pipe_names[r], ',', peer_names, (sizeof(peer_names) / sizeof(peer_names[0])));
|
||||
|
||||
if (caller_channel && !sent_ring && and_argc > 1 && !ringback_data) {
|
||||
|
@ -3135,10 +3168,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
|
|||
}
|
||||
|
||||
if (status == SWITCH_STATUS_SUCCESS) {
|
||||
break;
|
||||
goto outer_for;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
outer_for:
|
||||
switch_safe_free(loop_data);
|
||||
switch_safe_free(odata);
|
||||
return status;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue