started debit loop

This commit is contained in:
Radu Ioan Fericean
2012-05-04 18:38:22 +03:00
parent ad020cf456
commit 5aef01c4c8
3 changed files with 19 additions and 17 deletions

View File

@@ -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() {
}

View File

@@ -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) {

View File

@@ -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)
//}
}