FSMOD-40 - handle CS_REPORTING like CS_HANGUP

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16954 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Rupa Schomaker 2010-03-09 17:46:00 +00:00
parent f31e90a61c
commit 2377367d05
1 changed files with 16 additions and 13 deletions

View File

@ -484,22 +484,25 @@ static switch_status_t do_billing(switch_core_session_t *session)
/* Update the last time we billed */
nibble_data->lastts = ts;
/* Save this location, but only if the channel/session are not hungup (otherwise, we're done) */
if (channel && switch_channel_get_state(channel) != CS_HANGUP) {
/* Save this location */
if (channel) {
switch_channel_set_private(channel, "_nibble_data_", nibble_data);
/* See if this person has enough money left to continue the call */
balance = get_balance(billaccount);
if (balance <= nobal_amt) {
/* Not enough money - reroute call to nobal location */
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Balance of %f fell below allowed amount of %f! (Account %s)\n",
balance, nobal_amt, billaccount);
/* don't verify ballance and transfer to nobal if we're done with call */
if (switch_channel_get_state(channel) != CS_REPORTING && switch_channel_get_state(channel) != CS_HANGUP) {
/* See if this person has enough money left to continue the call */
balance = get_balance(billaccount);
if (balance <= nobal_amt) {
/* Not enough money - reroute call to nobal location */
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Balance of %f fell below allowed amount of %f! (Account %s)\n",
balance, nobal_amt, billaccount);
/* IMPORTANT: Billing must be paused before the transfer occurs! This prevents infinite loops, since the transfer will result */
/* in nibblebill checking the call again in the routing process for an allowed balance! */
/* If you intend to give the user the option to re-up their balance, you must clear & resume billing once the balance is updated! */
nibblebill_pause(session);
transfer_call(session, globals.nobal_action);
/* IMPORTANT: Billing must be paused before the transfer occurs! This prevents infinite loops, since the transfer will result */
/* in nibblebill checking the call again in the routing process for an allowed balance! */
/* If you intend to give the user the option to re-up their balance, you must clear & resume billing once the balance is updated! */
nibblebill_pause(session);
transfer_call(session, globals.nobal_action);
}
}
}