mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
started debit loop
This commit is contained in:
@@ -43,6 +43,12 @@ func NewSession(ev *Event) *Session {
|
||||
startTime: startTime}
|
||||
}
|
||||
|
||||
func (s *Session) StartDebitLoop() {
|
||||
for {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Session) GetSessionDurationFrom(now time.Time) (d time.Duration) {
|
||||
seconds := now.Sub(s.startTime).Seconds()
|
||||
d, err := time.ParseDuration(fmt.Sprintf("%ds", int(seconds)))
|
||||
@@ -69,3 +75,7 @@ func (s *Session) GetSessionCostFrom(now time.Time) (callCosts *timespans.CallCo
|
||||
func (s *Session) GetSessionCost() (callCosts *timespans.CallCost, err error) {
|
||||
return s.GetSessionCostFrom(time.Now())
|
||||
}
|
||||
|
||||
func (s *Session) Close() {
|
||||
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ func (sm *SessionManager) ReadNextEvent() (ev *Event) {
|
||||
return
|
||||
}
|
||||
|
||||
func (sm *SessionManager) GetSessionByUUID(uuid string) *Session {
|
||||
func (sm *SessionManager) GetSession(uuid string) *Session {
|
||||
for _, s := range sm.sessions {
|
||||
if s.uuid == uuid {
|
||||
return s
|
||||
@@ -73,15 +73,6 @@ func (sm *SessionManager) GetSessionByUUID(uuid string) *Session {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sm *SessionManager) GetSessionBySubject(subj string) (s *Session) {
|
||||
for _, s := range sm.sessions {
|
||||
if s.subject == subj {
|
||||
return s
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (sm *SessionManager) OnHeartBeat(ev *Event) {
|
||||
log.Print("heartbeat")
|
||||
}
|
||||
@@ -92,7 +83,8 @@ func (sm *SessionManager) OnChannelAnswer(ev *Event) {
|
||||
}
|
||||
|
||||
func (sm *SessionManager) OnChannelHangupComplete(ev *Event) {
|
||||
//s := GetSessionByUUID(ev.Fields[UUID])
|
||||
s := sm.GetSession(ev.Fields[UUID])
|
||||
s.Close()
|
||||
}
|
||||
|
||||
func (sm *SessionManager) OnOther(ev *Event) {
|
||||
|
||||
@@ -26,11 +26,11 @@ import (
|
||||
func TestConnect(t *testing.T) {
|
||||
sm := &SessionManager{}
|
||||
sm.Connect("localhost:8021", "ClueCon")
|
||||
for {
|
||||
ev := sm.ReadNextEvent()
|
||||
if ev == nil {
|
||||
t.Error("Got nil event!")
|
||||
}
|
||||
//log.Print(ev)
|
||||
//for {
|
||||
ev := sm.ReadNextEvent()
|
||||
if ev == nil {
|
||||
t.Error("Got nil event!")
|
||||
}
|
||||
//log.Print(ev)
|
||||
//}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user