From a43bfeedfd26015c0f37f8b8a36be374190dc232 Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Wed, 19 Sep 2012 14:43:18 +0300 Subject: [PATCH] sending amount in get max session time --- sessionmanager/sessiondelegate.go | 1 + timespans/calldesc.go | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sessionmanager/sessiondelegate.go b/sessionmanager/sessiondelegate.go index 23466affe..2f10374f8 100644 --- a/sessionmanager/sessiondelegate.go +++ b/sessionmanager/sessiondelegate.go @@ -55,6 +55,7 @@ func (rsd *SessionDelegate) OnChannelPark(ev Event, sm SessionManager) { Subject: ev.GetSubject(), Account: ev.GetAccount(), Destination: ev.GetDestination(), + Amount: rsd.DebitPeriod.Seconds(), TimeStart: startTime} var remainingSeconds float64 err = rsd.Connector.GetMaxSessionTime(cd, &remainingSeconds) diff --git a/timespans/calldesc.go b/timespans/calldesc.go index f4002d83c..fca26caa3 100644 --- a/timespans/calldesc.go +++ b/timespans/calldesc.go @@ -292,11 +292,13 @@ func (cd *CallDescriptor) GetMaxSessionTime() (seconds float64, err error) { _, err = cd.LoadActivationPeriods() now := time.Now() availableCredit, availableSeconds := 0.0, 0.0 + Logger.Debug(fmt.Sprintf("cd: %+v", cd)) if userBalance, err := cd.getUserBalance(); err == nil && userBalance != nil { if userBalance.Type == UB_TYPE_POSTPAID { return -1, nil } else { availableSeconds, availableCredit, _ = userBalance.getSecondsForPrefix(cd.Destination) + Logger.Debug(fmt.Sprintf("available sec: %v credit: %v", availableSeconds, availableCredit)) } } else { return cd.Amount, err @@ -305,7 +307,6 @@ func (cd *CallDescriptor) GetMaxSessionTime() (seconds float64, err error) { if availableCredit == 0 { return availableSeconds, nil } - // the price of a seccond cannot be determined because all the seconds can have a different cost. // therfore we get the cost for the whole period and then if there are not enough money we backout in steps of 10%. maxSessionSeconds := cd.Amount