From 0eb6110d8e8f9f42409926dc6e0bce8269622f61 Mon Sep 17 00:00:00 2001 From: JungJun Date: Fri, 24 Jun 2022 17:19:35 +0900 Subject: [PATCH] =?UTF-8?q?=EC=8B=9C=EB=82=98=EB=A6=AC=EC=98=A4=20?= =?UTF-8?q?=EB=B0=94=EC=A7=84,=20STTMAXTIME=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- icsconf/icsconf.go | 6 +- icshttp/handler.go | 139 ++++++++++++++++++++++++--------------------- 2 files changed, 79 insertions(+), 66 deletions(-) diff --git a/icsconf/icsconf.go b/icsconf/icsconf.go index 3d3866f..cf3fdbf 100644 --- a/icsconf/icsconf.go +++ b/icsconf/icsconf.go @@ -314,8 +314,10 @@ func (c IcsConfig) ShowConfig() string { } type ScenarioConfig struct { - Order []string `xml:"method,attr"` - Value []string `xml:"value,attr"` + Order []string `xml:"method,attr"` + Value []string `xml:"value,attr"` + BargeIn []string `xml:"bargeIn,attr"` + SttMaxTime []int `xml:"sttMaxTime,attr"` } type SimConfig struct { diff --git a/icshttp/handler.go b/icshttp/handler.go index 480f0f5..d8cee12 100644 --- a/icshttp/handler.go +++ b/icshttp/handler.go @@ -179,71 +179,82 @@ func (s *ScenarioSession) BOTPFunc(w http.ResponseWriter, r *http.Request) { // 현재 들어온 method로 분기 // next 시나리오로 넘겨주기 - if request.Method == "HANGUP" { - s.ByeCheck(request.Method, request.Token) + fmt.Printf("response %+v", request) + if request.Method != "INIT" && request.TalkText == "" { + response.ResultCode = 200 + response.Token = request.Token + response.Action = "END" + response.AnounceMents = "서비스에 장애가 발생하였습니다. 상담사를 연결해드리겠습니다." + response.Data.BargeIn = "Y" + response.Data.RecodingFile = "Y" + response.Data.SttMaxTime = 0 } else { - switch request.Method { - case "INIT": - token := createToken(request.CallId) - response.ResultCode = 200 - response.Token = token - response.Action = scnarioConf.Order[1] - response.AnounceMents = scnarioConf.Value[0] - response.Data.BargeIn = "N" - response.Data.RecodingFile = "Y" - response.Data.SttMaxTime = 4 - - s.m.Lock() - s.session[token] = ResStatus{Count: 1, Status: scnarioConf.Order[0]} - s.m.Unlock() - case "STT": - response.ResultCode = 200 - response.Token = request.Token - response.Action = scnarioConf.Order[s.session[request.Token].Count+1] - response.AnounceMents = scnarioConf.Value[s.session[request.Token].Count] - response.Data.BargeIn = "N" - response.Data.RecodingFile = "Y" - response.Data.SttMaxTime = 4 - - s.m.Lock() - s.session[request.Token] = ResStatus{Count: s.session[request.Token].Count + 1, Status: scnarioConf.Order[s.session[request.Token].Count+1]} - s.m.Unlock() - case "DTMF": - response.ResultCode = 200 - response.Token = request.Token - response.Action = scnarioConf.Order[s.session[request.Token].Count+1] - response.AnounceMents = scnarioConf.Value[s.session[request.Token].Count] - response.Data.BargeIn = "N" - response.Data.RecodingFile = "Y" - response.Data.SttMaxTime = 3 - - s.m.Lock() - s.session[request.Token] = ResStatus{Count: s.session[request.Token].Count + 1, Status: scnarioConf.Order[s.session[request.Token].Count+1]} - s.m.Unlock() - case "REFER": - response.Data.TelNo = "010-1234-1234" - - s.m.Lock() - s.session[request.Token] = ResStatus{Count: s.session[request.Token].Count + 1, Status: scnarioConf.Order[s.session[request.Token].Count+1]} - s.m.Unlock() - case "BYE": // 전화 종료 요청 - response.ResultCode = 200 - response.Token = request.Token - response.Action = "END" - response.AnounceMents = "접수가 완료되었습니다." - response.Data.BargeIn = "Y" - response.Data.RecodingFile = "Y" - response.Data.SttMaxTime = 0 - // case "HANGUP": - // response.ResultCode = 200 - // response.Token = request.Token - // response.Action = "" - // response.AnounceMents = "" - // response.Data.BargeIn = "" - // response.Data.RecodingFile = "" - // response.Data.SttMaxTime = 0 - // if ByeCheck(request.Method, request.Token) { - // } + if request.Method == "HANGUP" { + s.ByeCheck(request.Method, request.Token) + } else { + switch request.Method { + case "INIT": + token := createToken(request.CallId) + response.ResultCode = 200 + response.Token = token + response.Action = scnarioConf.Order[1] + response.AnounceMents = scnarioConf.Value[0] + response.Data.BargeIn = scnarioConf.BargeIn[0] + response.Data.RecodingFile = "Y" + response.Data.SttMaxTime = scnarioConf.SttMaxTime[0] + + s.m.Lock() + s.session[token] = ResStatus{Count: 1, Status: scnarioConf.Order[0]} + s.m.Unlock() + case "STT": + response.ResultCode = 200 + response.Token = request.Token + response.Action = scnarioConf.Order[s.session[request.Token].Count+1] + response.AnounceMents = scnarioConf.Value[s.session[request.Token].Count] + response.Data.BargeIn = scnarioConf.BargeIn[s.session[request.Token].Count] + response.Data.RecodingFile = "Y" + response.Data.SttMaxTime = scnarioConf.SttMaxTime[s.session[request.Token].Count] + + s.m.Lock() + s.session[request.Token] = ResStatus{Count: s.session[request.Token].Count + 1, Status: scnarioConf.Order[s.session[request.Token].Count+1]} + s.m.Unlock() + case "DTMF": + response.ResultCode = 200 + response.Token = request.Token + response.Action = scnarioConf.Order[s.session[request.Token].Count+1] + response.AnounceMents = scnarioConf.Value[s.session[request.Token].Count] + response.Data.BargeIn = "N" + response.Data.RecodingFile = "Y" + response.Data.SttMaxTime = 3 + + s.m.Lock() + s.session[request.Token] = ResStatus{Count: s.session[request.Token].Count + 1, Status: scnarioConf.Order[s.session[request.Token].Count+1]} + s.m.Unlock() + case "REFER": + response.Data.TelNo = "010-1234-1234" + + s.m.Lock() + s.session[request.Token] = ResStatus{Count: s.session[request.Token].Count + 1, Status: scnarioConf.Order[s.session[request.Token].Count+1]} + s.m.Unlock() + case "BYE": // 전화 종료 요청 + response.ResultCode = 200 + response.Token = request.Token + response.Action = "END" + response.AnounceMents = "접수가 완료되었습니다." + response.Data.BargeIn = "Y" + response.Data.RecodingFile = "Y" + response.Data.SttMaxTime = 0 + // case "HANGUP": + // response.ResultCode = 200 + // response.Token = request.Token + // response.Action = "" + // response.AnounceMents = "" + // response.Data.BargeIn = "" + // response.Data.RecodingFile = "" + // response.Data.SttMaxTime = 0 + // if ByeCheck(request.Method, request.Token) { + // } + } } }