start fs decoupling

This commit is contained in:
Radu Ioan Fericean
2012-05-15 16:22:58 +03:00
parent e6b291d359
commit 8362c9dfa0
6 changed files with 24 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
[
{"TOR": 0,"CstmId":"vdf","Subject":"rif","DestinationPrefix":"0256", "ActivationPeriods": [
{"TOR": "0","CstmId":"vdf","Subject":"rif","DestinationPrefix":"0256", "ActivationPeriods": [
{"ActivationTime": "2012-01-01T00:00:00Z", "Intervals": [
{"BillingUnit":1,"ConnectFee":0,"Month":0,"MonthDay":0,"Ponder":0,"Price":0.2,"StartTime":"","EndTime":"18:00:00","WeekDays":[1,2,3,4,5]},
{"BillingUnit":1,"ConnectFee":0,"Month":0,"MonthDay":0,"Ponder":0,"Price":0.1,"StartTime":"18:00:00","EndTime":"","WeekDays":[1,2,3,4,5]},
@@ -8,7 +8,7 @@
}
]
},
{"TOR": 0,"CstmId":"vdf","Subject":"rif","DestinationPrefix":"0257", "ActivationPeriods": [
{"TOR": "0","CstmId":"vdf","Subject":"rif","DestinationPrefix":"0257", "ActivationPeriods": [
{"ActivationTime": "2012-01-01T00:00:00Z", "Intervals": [
{"BillingUnit":1,"ConnectFee":0,"Month":0,"MonthDay":0,"Ponder":0,"Price":0.1,"StartTime":"18:00:00","EndTime":"","WeekDays":[1,2,3,4,5]},
{"BillingUnit":1,"ConnectFee":0,"Month":0,"MonthDay":0,"Ponder":0,"Price":0.2,"StartTime":"","EndTime":"18:00:00","WeekDays":[1,2,3,4,5]},
@@ -23,14 +23,14 @@
}
]
},
{"TOR": 0,"CstmId":"vdf","Subject":"rif","DestinationPrefix":"0723", "ActivationPeriods": [
{"TOR": "0","CstmId":"vdf","Subject":"rif","DestinationPrefix":"0723", "ActivationPeriods": [
{"ActivationTime": "2012-01-01T00:00:00Z", "Intervals": [
{"BillingUnit":60,"ConnectFee":0,"Month":0,"MonthDay":0,"Ponder":0,"Price":1,"StartTime":"","EndTime":""}
]
}
]
},
{"TOR": 0,"CstmId":"vdf","Subject":"minutosu","DestinationPrefix":"0723", "ActivationPeriods": [
{"TOR": "0","CstmId":"vdf","Subject":"minutosu","DestinationPrefix":"0723", "ActivationPeriods": [
{"ActivationTime": "2012-01-01T00:00:00Z", "Intervals": [
{"BillingUnit":60,"ConnectFee":0,"Month":0,"MonthDay":0,"Ponder":0,"Price":1,"StartTime":"","EndTime":""}
]

View File

@@ -36,11 +36,17 @@ var (
const (
// Freswitch event proprities names
CALL_DIRECTION = "Call-Direction"
SUBJECT = "variable_sip_full_from"
DESTINATION = "variable_sip_full_to"
UUID = "Unique-ID"
CSTMID = "Caller-Dialplan"
ORIG_ID = "variable_sip_call_id" //- originator_id - match cdrs
SUBJECT = "variable_cgr_subject"
DESTINATION = "variable_cgr_destination"
TOR = "variable_cgr_tor"
UUID = "Unique-ID" // -Unique ID for this call leg
CSTMID = "variable_cgr_cstmid"
START_TIME = "Event-Date-GMT"
NAME = "Event-Name"
HEARTBEAT = "HEARTBEAT"
ANSWER = "CHANNEL_ANSWER"
HANGUP = "CHANNEL_HANGUP_COMPLETE"
)
// Creates a new event from a bod of text containing the key value proprieties.

View File

@@ -42,7 +42,8 @@ func NewSession(ev *Event, ed SessionDelegate) (s *Session) {
log.Print("Error parsing answer event start time, using time.Now!")
startTime = time.Now()
}
cd := &timespans.CallDescriptor{CstmId: ev.Fields[CSTMID],
cd := &timespans.CallDescriptor{TOR: ev.Fields[TOR],
CstmId: ev.Fields[CSTMID],
Subject: ev.Fields[SUBJECT],
DestinationPrefix: ev.Fields[DESTINATION],
TimeStart: startTime}

View File

@@ -63,12 +63,12 @@ func (sm *SessionManager) readNextEvent() (ev *Event) {
log.Print("Could not read from freeswitch connection!")
}
ev = NewEvent(body)
switch ev.Fields["Event-Name"] {
case "HEARTBEAT":
switch ev.Fields[NAME] {
case HEARTBEAT:
sm.OnHeartBeat(ev)
case "CHANNEL_ANSWER":
case ANSWER:
sm.OnChannelAnswer(ev)
case "CHANNEL_HANGUP_COMPLETE":
case HANGUP:
sm.OnChannelHangupComplete(ev)
default:
sm.OnOther(ev)

View File

@@ -51,7 +51,7 @@ func round(val float64, prec int) float64 {
The input stucture that contains call information.
*/
type CallDescriptor struct {
TOR int
TOR string
CstmId, Subject, DestinationPrefix string
TimeStart, TimeEnd time.Time
Amount float64
@@ -228,10 +228,9 @@ func (cd *CallDescriptor) GetCost() (*CallCost, error) {
The output structure that will be returned with the call cost information.
*/
type CallCost struct {
TOR int
CstmId, Subject, DestinationPrefix string
Cost, ConnectFee float64
Timespans []*TimeSpan
TOR, CstmId, Subject, DestinationPrefix string
Cost, ConnectFee float64
Timespans []*TimeSpan
}
/*