fixed debit loop callend issue

This commit is contained in:
Radu Ioan Fericean
2014-01-12 19:07:59 +02:00
parent d56bec9338
commit 995cfd9785
2 changed files with 10 additions and 1 deletions

View File

@@ -67,6 +67,13 @@ func (cc *CallCost) GetStartTime() time.Time {
return cc.Timespans[0].TimeStart
}
func (cc *CallCost) GetEndTime() time.Time {
if len(cc.Timespans) == 0 {
return time.Now()
}
return cc.Timespans[len(cc.Timespans)-1].TimeEnd
}
func (cc *CallCost) GetDuration() (td time.Duration) {
for _, ts := range cc.Timespans {
td += ts.GetDuration()

View File

@@ -20,9 +20,10 @@ package sessionmanager
import (
"fmt"
"time"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
"time"
)
// Session type holding the call information fields, a session delegate for specific
@@ -87,6 +88,7 @@ func (s *Session) startDebitLoop() {
}
nextCd.TimeEnd = nextCd.TimeStart.Add(s.sessionManager.GetDebitPeriod())
cc := s.sessionManager.LoopAction(s, &nextCd, index)
nextCd.TimeEnd = cc.GetEndTime()
time.Sleep(cc.GetDuration())
index++
}