|
|
|
@ -278,16 +278,20 @@ func (s *IcsSession) RequestInvite(inviteto string) {
|
|
|
|
|
inviteMethod := fmt.Sprintf("sip:%s@172.31.29.47;transport=%s", s.AgentName, transport) // nlb(DNS)를 한번 갔다온 ip를 넣어줘야함.
|
|
|
|
|
s.uri = fmt.Sprintf("sip:%s@%s", s.AgentName, ip)
|
|
|
|
|
to := fmt.Sprintf("<sip:%s@%s;user=phone>", s.AgentName, ip)
|
|
|
|
|
from := fmt.Sprintf("<sip:%s@%s>;tag=%s", inviteto, ip, sipasm.GenerateTag())
|
|
|
|
|
if conf.Representative.Value {
|
|
|
|
|
inviteMethod = fmt.Sprintf("sip:%s@%s;transport=%s", "AISB", ip, transport)
|
|
|
|
|
s.uri = fmt.Sprintf("sip:%s@%s", "AISB", ip)
|
|
|
|
|
to = fmt.Sprintf("<sip:%s@%s;user=phone>", "AISB", ip)
|
|
|
|
|
agentName := s.AgentName
|
|
|
|
|
agentSplit := agentName[len(agentName)-2:len(agentName)]
|
|
|
|
|
telNo := fmt.Sprintf("010243427%s", agentSplit)
|
|
|
|
|
from = fmt.Sprintf("<sip:%s@%s>;tag=%s", telNo, ip, sipasm.GenerateTag())
|
|
|
|
|
}
|
|
|
|
|
reqInvite := sipasm.NewSIPMessage(sipasm.ICSSIP_METHOD_INVITE, inviteMethod)
|
|
|
|
|
|
|
|
|
|
via := fmt.Sprintf("SIP/2.0/UDP %s:5090;branch=%s", ip, sipasm.GenerateBranch())
|
|
|
|
|
maxforwards := "70"
|
|
|
|
|
from := fmt.Sprintf("<sip:%s@%s>;tag=%s", inviteto, ip, sipasm.GenerateTag())
|
|
|
|
|
|
|
|
|
|
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Set URI [%s]", s.uri)
|
|
|
|
|
|
|
|
|
@ -376,7 +380,7 @@ func (s *IcsSession) PassInvite(sip *icspacketparser.SIP) *icserror.IcsError {
|
|
|
|
|
ip := conf.InfoConfig.ServerIP
|
|
|
|
|
port := conf.SIPConfig.Port
|
|
|
|
|
|
|
|
|
|
fmt.Println("sip.Media ", sip.Media)
|
|
|
|
|
// fmt.Println("sip.Media ", sip.Media)
|
|
|
|
|
mediaPort, _ := strconv.Atoi(sip.Media)
|
|
|
|
|
|
|
|
|
|
proxy := conf.SIPConfig.SIPProxy
|
|
|
|
@ -423,7 +427,7 @@ func (s *IcsSession) PassInvite(sip *icspacketparser.SIP) *icserror.IcsError {
|
|
|
|
|
formats := strings.Split(format, " ")
|
|
|
|
|
reqInvite.SDP = sipasm.NewSDPMessage(ip, mediaPort, formats[:], 0)
|
|
|
|
|
sdpLength := fmt.Sprintf("%d", len(reqInvite.SDP.String()))
|
|
|
|
|
fmt.Println("###### X-AICALL ", sip.XAICall)
|
|
|
|
|
// fmt.Println("###### X-AICALL ", sip.XAICall)
|
|
|
|
|
// refer := strings.Split(sip.XAICall, "@")[0]
|
|
|
|
|
|
|
|
|
|
reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_VIA, via)
|
|
|
|
@ -448,23 +452,23 @@ func (s *IcsSession) PassInvite(sip *icspacketparser.SIP) *icserror.IcsError {
|
|
|
|
|
reqInvite)
|
|
|
|
|
|
|
|
|
|
// sendINVITE := fmt.Sprintf("%+v",sip)
|
|
|
|
|
wlen, werr := (*s.sipNeter).WriteSIP([]byte(reqInvite.String()))
|
|
|
|
|
_, werr := (*s.sipNeter).WriteSIP([]byte(reqInvite.String()))
|
|
|
|
|
if werr != nil {
|
|
|
|
|
l.Print(icslog.LOG_LEVEL_FATAL, s.ID, werr.GetMessage())
|
|
|
|
|
s.SetAgentStatus(STATUS_AGENT_READY)
|
|
|
|
|
return werr
|
|
|
|
|
}
|
|
|
|
|
fmt.Println(wlen)
|
|
|
|
|
// fmt.Println(wlen)
|
|
|
|
|
|
|
|
|
|
s.InviteSIP = nil
|
|
|
|
|
s1 := icspacketparser.NewSIP()
|
|
|
|
|
err := s1.SipParser([]byte(reqInvite.String()))
|
|
|
|
|
if err != nil {
|
|
|
|
|
fmt.Printf("########### ererererrererer %s \r\n %+v\r\n", reqInvite.String(), s.InviteSIP)
|
|
|
|
|
// fmt.Printf("########### ererererrererer %s \r\n %+v\r\n", reqInvite.String(), s.InviteSIP)
|
|
|
|
|
} else {
|
|
|
|
|
s.InviteSIP = &s1
|
|
|
|
|
fmt.Printf("########### %+v\r\n",s1)
|
|
|
|
|
fmt.Printf("########### %s, \r\n %+v\r\n",reqInvite.String(), s.InviteSIP)
|
|
|
|
|
// fmt.Printf("########### %+v\r\n",s1)
|
|
|
|
|
// fmt.Printf("########### %s, \r\n %+v\r\n",reqInvite.String(), s.InviteSIP)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// s.RemoveSession()
|
|
|
|
@ -672,7 +676,7 @@ func (s *IcsSession) ProcInvite(sip *icspacketparser.SIP) *icserror.IcsError {
|
|
|
|
|
//TODO : agent conf
|
|
|
|
|
//station := conf.AgentConfig[s.ID].Name
|
|
|
|
|
s.Station = s.AgentInfo.Name
|
|
|
|
|
fmt.Println("s.Station = s.AgentInfo.Name>>>>>", s.Station)
|
|
|
|
|
// fmt.Println("s.Station = s.AgentInfo.Name>>>>>", s.Station)
|
|
|
|
|
///////////
|
|
|
|
|
cust1 := strings.SplitN(sip.From, "@", 2)
|
|
|
|
|
cust2 := strings.SplitN(cust1[0], ":", 2)
|
|
|
|
@ -886,7 +890,7 @@ func (s *IcsSession) ProcACKInvite(sip *icspacketparser.SIP) *icserror.IcsError
|
|
|
|
|
s.SetAgentStatus(STATUS_AGENT_CALLING)
|
|
|
|
|
}
|
|
|
|
|
status := s.GetAgentStatus()
|
|
|
|
|
fmt.Println("BOT STATUS ", status == STATUS_AGENT_CALLING)
|
|
|
|
|
// fmt.Println("BOT STATUS ", status == STATUS_AGENT_CALLING)
|
|
|
|
|
if status == STATUS_AGENT_CALLING {
|
|
|
|
|
ackMethod := fmt.Sprintf("sip:01025670081@%s;transport=%s", "192.168.0.222:5090", transport)
|
|
|
|
|
|
|
|
|
@ -1080,7 +1084,7 @@ func (s *IcsSession) ProcACKInvite(sip *icspacketparser.SIP) *icserror.IcsError
|
|
|
|
|
///////////////////////////////////////////
|
|
|
|
|
///////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
fmt.Println(s)
|
|
|
|
|
// fmt.Println(s)
|
|
|
|
|
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Sent Data(%d) [%s]->[%s]>\n%s",
|
|
|
|
|
wlen,
|
|
|
|
|
(*s.sipNeter).LocalAddr().String(),
|
|
|
|
@ -1271,8 +1275,8 @@ func (s *IcsSession) SendRequestInvite() {
|
|
|
|
|
l := icslog.GetIcsLog()
|
|
|
|
|
conf := icsconf.GetIcsConfig()
|
|
|
|
|
|
|
|
|
|
fmt.Println("######### sim loop count!! ", conf.SimLoopCount)
|
|
|
|
|
fmt.Printf("Send Call Start Sip(%s) count %d!!!!!!!", s.AgentName, s.simLoopCount)
|
|
|
|
|
// fmt.Println("######### sim loop count!! ", conf.SimLoopCount)
|
|
|
|
|
// fmt.Printf("Send Call Start Sip(%s) count %d!!!!!!!", s.AgentName, s.simLoopCount)
|
|
|
|
|
if s.simLoopCount < conf.SimLoopCount {
|
|
|
|
|
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Send Call Start Sip(%s) count %d!!!!!!!\r\n", s.AgentName, s.simLoopCount)
|
|
|
|
|
time.Sleep(time.Second*1)
|
|
|
|
@ -1346,8 +1350,8 @@ func (s *IcsSession) ProcSIP20Bye(sip *icspacketparser.SIP) *icserror.IcsError {
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// s.RemoveSession()
|
|
|
|
|
fmt.Println("######### sim loop count!! ", conf.SimLoopCount)
|
|
|
|
|
fmt.Printf("Send Call Start Sip(%s) count %d!!!!!!!", s.AgentName, s.simLoopCount)
|
|
|
|
|
// fmt.Println("######### sim loop count!! ", conf.SimLoopCount)
|
|
|
|
|
// fmt.Printf("Send Call Start Sip(%s) count %d!!!!!!!", s.AgentName, s.simLoopCount)
|
|
|
|
|
if s.simLoopCount < conf.SimLoopCount {
|
|
|
|
|
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Send Call Start Sip(%s) count %d!!!!!!!\r\n", s.AgentName, s.simLoopCount)
|
|
|
|
|
s.RequestInvite("01024342788")
|
|
|
|
@ -1404,7 +1408,7 @@ func (s *IcsSession) SendRTPCB(t *icscbtimer.IcsCBTimer) {
|
|
|
|
|
voiceFilePath := "/home/icsvsim/voice/Sample.pcm"
|
|
|
|
|
readPcmData, ferr := ioutil.ReadFile(voiceFilePath)
|
|
|
|
|
if ferr != nil {
|
|
|
|
|
fmt.Println("Read Voice File error ", ferr)
|
|
|
|
|
// fmt.Println("Read Voice File error ", ferr)
|
|
|
|
|
l.Printf(icslog.LOG_LEVEL_ERROR, s.ID, "############ VoiceFile Read ERROR")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
@ -1743,7 +1747,7 @@ func (s *IcsSession) ReadRTP() {
|
|
|
|
|
// func (s *IcsSession)ExpiredRTP(t *icscbtimer.IcsCBTimer) {
|
|
|
|
|
func (s *IcsSession)ExpiredRTP(t time.Ticker) {
|
|
|
|
|
s.mychannel = make(chan bool)
|
|
|
|
|
fmt.Println("### timer start")
|
|
|
|
|
// fmt.Println("### timer start")
|
|
|
|
|
// valCheckTimer := time.NewTicker(time.Second)
|
|
|
|
|
s.expRead = time.Now()
|
|
|
|
|
for {
|
|
|
|
@ -1755,7 +1759,7 @@ func (s *IcsSession)ExpiredRTP(t time.Ticker) {
|
|
|
|
|
fmt.Println("agent : ", s.AgentName , " ", tm)
|
|
|
|
|
} else if !s.expCheck {
|
|
|
|
|
if time.Now().Sub(s.expRead) > time.Second {
|
|
|
|
|
fmt.Printf("### session expired %s\n", s.AgentName)
|
|
|
|
|
// fmt.Printf("### session expired %s\n", s.AgentName)
|
|
|
|
|
s.RTPSenderCallBackTimer.Start()
|
|
|
|
|
s.expCheck = true
|
|
|
|
|
}
|
|
|
|
@ -2026,11 +2030,11 @@ func (s *IcsSession) RequestBYESIM() {
|
|
|
|
|
func (s *IcsSession) RequestBYE(inviteSIP *icspacketparser.SIP) {
|
|
|
|
|
l := icslog.GetIcsLog()
|
|
|
|
|
conf := icsconf.GetIcsConfig()
|
|
|
|
|
fmt.Printf("inviteSIP %+v\r\n", inviteSIP)
|
|
|
|
|
// fmt.Printf("inviteSIP %+v\r\n", inviteSIP)
|
|
|
|
|
ip := conf.InfoConfig.ServerIP
|
|
|
|
|
port := conf.SIPConfig.Port
|
|
|
|
|
transport := conf.SIPConfig.Transport
|
|
|
|
|
fmt.Println(">>>contact", inviteSIP.Contact)
|
|
|
|
|
// fmt.Println(">>>contact", inviteSIP.Contact)
|
|
|
|
|
// contactName1 := strings.SplitN(inviteSIP.Contact, "sip:", 2)
|
|
|
|
|
// contactName := strings.SplitN(contactName1[1], "@", 2)
|
|
|
|
|
|
|
|
|
|