mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
return o zero call costs
This commit is contained in:
@@ -24,6 +24,7 @@ import (
|
||||
"log"
|
||||
"net/rpc"
|
||||
//"net/rpc/jsonrpc"
|
||||
"net/rpc/jsonrpc"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ type FSSessionManager struct {
|
||||
buf *bufio.Reader
|
||||
sessions []*Session
|
||||
sessionDelegate *SessionDelegate
|
||||
postgresLogger *PostgresLogger //NewPostgresLogger("gosqltest", "rif", "testus")
|
||||
postgresLogger *PostgresLogger
|
||||
}
|
||||
|
||||
func NewFSSessionManager(db *sql.DB) *FSSessionManager {
|
||||
|
||||
@@ -36,6 +36,10 @@ func (psl *PostgresLogger) Close() {
|
||||
}
|
||||
|
||||
func (psl *PostgresLogger) Log(uuid string, cc *timespans.CallCost) {
|
||||
if psl.db == nil {
|
||||
timespans.Logger.Warning("Cannot write log to database.")
|
||||
return
|
||||
}
|
||||
tss, err := json.Marshal(cc.Timespans)
|
||||
if err != nil {
|
||||
log.Printf("Error marshalling timespans to json: %v", err)
|
||||
|
||||
@@ -72,6 +72,9 @@ func (rsd *SessionDelegate) OnChannelAnswer(ev Event, s *Session) {
|
||||
}
|
||||
|
||||
func (rsd *SessionDelegate) OnChannelHangupComplete(ev Event, s *Session) {
|
||||
if len(s.CallCosts) == 0 {
|
||||
return // why would we have 0 callcosts
|
||||
}
|
||||
lastCC := s.CallCosts[len(s.CallCosts)-1]
|
||||
// put credit back
|
||||
start := time.Now()
|
||||
|
||||
Reference in New Issue
Block a user