[Freeswitch-svn] [commit] r4193 - freeswitch/trunk/src
Freeswitch SVN
mikej at freeswitch.org
Sat Feb 10 16:47:12 EST 2007
Author: mikej
Date: Sat Feb 10 16:47:12 2007
New Revision: 4193
Modified:
freeswitch/trunk/src/switch_ivr.c
Log:
adding fail_on_single_reject dialplan option that can be set, which then immediately rejects the call even when sent to multiple destinations upon one party rejecting, useful if you are doing a ring all (, separated in the dial string for multiple calls at once) and you want a single rejection to make the call flow to the next action in the dialplan (in combination w/ continue_on_fail) for example to flow to voicemail. Thanks to George Shaw for this patch.
Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c (original)
+++ freeswitch/trunk/src/switch_ivr.c Sat Feb 10 16:47:12 2007
@@ -2339,21 +2339,22 @@
switch_core_session_t **peer_sessions,
uint32_t len,
int32_t *idx,
+ uint32_t *hups,
char *file,
char *key,
uint8_t early_ok)
{
uint32_t i;
- uint32_t hups = 0;
- *idx = -1;
+ *hups = 0;
+ *idx = IDX_NADA;
for (i = 0; i < len; i++) {
if (!peer_channels[i]) {
continue;
}
if (switch_channel_get_state(peer_channels[i]) >= CS_HANGUP) {
- hups++;
+ (*hups)++;
} else if ((switch_channel_test_flag(peer_channels[i], CF_ANSWERED) ||
(early_ok && len == 1 && switch_channel_test_flag(peer_channels[i], CF_EARLY_MEDIA))) &&
!switch_channel_test_flag(peer_channels[i], CF_TAGGED)) {
@@ -2382,7 +2383,7 @@
}
}
- if (hups == len) {
+ if (*hups == len) {
return 0;
} else {
return 1;
@@ -2454,6 +2455,7 @@
uint8_t sent_ring = 0, early_ok = 1;
switch_core_session_message_t *message = NULL;
switch_event_t *var_event = NULL;
+ uint8_t fail_on_single_reject = 0;
write_frame.data = fdata;
@@ -2548,6 +2550,12 @@
}
}
+ // When using the AND operator, the fail_on_single_reject flage 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;
+ }
+
if (file && !strcmp(file, "undef")) {
file = NULL;
}
@@ -2573,6 +2581,7 @@
}
for (r = 0; r < or_argc; r++) {
+ uint32_t hups;
reason = SWITCH_CAUSE_UNALLOCATED;
memset(peer_names, 0, sizeof(peer_names));
peer_session = NULL;
@@ -2841,9 +2850,10 @@
}
while ((!caller_channel || switch_channel_ready(caller_channel)) &&
- check_channel_status(peer_channels, peer_sessions, and_argc, &idx, file, key, early_ok)) {
+ check_channel_status(peer_channels, peer_sessions, and_argc, &idx, &hups, file, key, early_ok)) {
- if ((to = (uint8_t)((time(NULL) - start) >= (time_t)timelimit_sec))) {
+ // When the AND operator is being used, and fail_on_single_reject is set, a hangup indicates that the call should fail.
+ if ((to = (uint8_t)((time(NULL) - start) >= (time_t)timelimit_sec)) || (fail_on_single_reject && hups)) {
idx = IDX_CANCEL;
goto notready;
}
More information about the Freeswitch-svn
mailing list