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

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 {
// l := icslog.GetIcsLog()
icsstat.NewSidVal()
for !exe.service.GetExit() {
for exe.service.GetStop() {
time.Sleep(time.Millisecond)
}
/////////////////////////////////////////////////////////////////////
// voice gateway start statistic tcp
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
}()
/////////////////////////////////////////////////////////////////////
select {
case err := <-cmdDone:
// l.Printf(icslog.LOG_LEVEL_INFO, -1, "Closed Gateway Stat TCP Connection: %s", err)
if err != nil {
//err.Print()
return err
}
case err1 := <-cmdDone1:
// l.Printf(icslog.LOG_LEVEL_INFO, -1, "Closed Agent Stat TCP Connection: %s", err1)
if err1 != nil {
//err.Print()
return err1
}
}
}
return nil
}