You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
1.9 KiB
Go

3 years ago
package icsapp
import (
"time"
"gitlab.com/ics_cinnamon/voiceStatistics/icsconf"
"gitlab.com/ics_cinnamon/voiceStatistics/icserror"
"gitlab.com/ics_cinnamon/voiceStatistics/icsnet"
"gitlab.com/ics_cinnamon/voiceStatistics/icsstat"
"gitlab.com/ics_cinnamon/voiceStatistics/icssvc"
)
const (
LINEEND1 = "\r\n"
LINEEND2 = "EOM"
)
type IcsExec struct {
service *icssvc.IcsService
config *icsconf.IcsConfig
hbNet *icsnet.IcsTCPNet
//pcap icspcap.IcsPcap
}
func Init(conf *icsconf.IcsConfig) (e *IcsExec) {
e = &IcsExec{}
e.service = icssvc.GetServiceStatus()
e.config = conf
//e.pcap = icspcap.New()
return e
}
func (exe IcsExec) Execute() *icserror.IcsError {
2 years ago
// l := icslog.GetIcsLog()
icsstat.NewSidVal()
3 years ago
for !exe.service.GetExit() {
for exe.service.GetStop() {
time.Sleep(time.Millisecond)
}
/////////////////////////////////////////////////////////////////////
// voice gateway start statistic tcp
3 years ago
cmdDone := make(chan *icserror.IcsError)
go func() {
cmdErr := icsstat.ListenStatMNG()
if cmdErr != nil {
cmdDone <- cmdErr
return
}
//defer sm.Close()
//cmdDone <- nil
}()
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
// voice agent start statistic tcp
cmdDone1 := make(chan *icserror.IcsError)
go func() {
cmdErr := icsstat.ListenStatMNG1()
if cmdErr != nil {
cmdDone1 <- cmdErr
return
}
//defer sm.Close()
//cmdDone <- nil
}()
/////////////////////////////////////////////////////////////////////
3 years ago
select {
case err := <-cmdDone:
2 years ago
// l.Printf(icslog.LOG_LEVEL_INFO, -1, "Closed Gateway Stat TCP Connection: %s", err)
3 years ago
if err != nil {
//err.Print()
return err
}
case err1 := <-cmdDone1:
2 years ago
// l.Printf(icslog.LOG_LEVEL_INFO, -1, "Closed Agent Stat TCP Connection: %s", err1)
if err1 != nil {
//err.Print()
return err1
}
3 years ago
}
}
return nil
}