|
@@ -23,33 +23,111 @@ var AminInstance *amigo.Amigo
|
|
|
var trainInfo = ""
|
|
var trainInfo = ""
|
|
|
|
|
|
|
|
func HandleAMI(event map[string]string) {
|
|
func HandleAMI(event map[string]string) {
|
|
|
- //lfshook.NewLogger().Infof("===start======%s", event["Event"]
|
|
|
|
|
|
|
|
|
|
switch event["Event"] {
|
|
switch event["Event"] {
|
|
|
|
|
|
|
|
case "DTMFBegin": //ICP interrupt PAD
|
|
case "DTMFBegin": //ICP interrupt PAD
|
|
|
|
|
+ lfshook.NewLogger().Infof("=========%s====caller:%s=====digit:%s==", event["Event"], event["CallerIDNum"], event["Digit"])
|
|
|
|
|
+ if priority.RunningType != "PAD-ICP" && priority.RunningType != "PAD-TMS" && priority.RunningType != "PAD-OCC" {
|
|
|
|
|
+ break
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if utils.IsICP(event["CallerIDNum"]) {
|
|
|
|
|
- exten := strings.Split(strings.Split(event["Channel"], "/")[1], "-")[0] //get ICP exten number
|
|
|
|
|
- if utils.IsICP(exten) {
|
|
|
|
|
- chans, err := CoreShowChannels()
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- lfshook.NewLogger().Errorf("CoreShowChannels %+v", err)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if utils.IsICP(event["CallerIDNum"]) && event["Exten"] != "" {
|
|
|
|
|
+
|
|
|
|
|
+ chans, err := CoreShowChannels()
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ lfshook.NewLogger().Errorf("CoreShowChannels %+v", err)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //PA interrupt PAD
|
|
|
|
|
+ if event["Digit"] == "#" {
|
|
|
|
|
|
|
|
//1. Redirect the connected PAD to 0300
|
|
//1. Redirect the connected PAD to 0300
|
|
|
- for _, ret := range chans {
|
|
|
|
|
- //lfshook.NewLogger().Infof("===HangupRunningTask=PAD1====Chans-ret===%+v==== ", ret)
|
|
|
|
|
- if utils.IsPAIU(ret.CallerIDNum) && ret.ChannelStateDesc == "Up" && utils.IsICP(ret.ConnectedLineNum) { //hangup pad call ICP channel
|
|
|
|
|
- //lfshook.NewLogger().Infof("===Hangup=Chan===%+v==== ", ret.Channel)
|
|
|
|
|
- Hangup(ret.Channel)
|
|
|
|
|
- } else if ret.ConnectedLineNum == "<unknown>" { //redirect pad chanspy channel
|
|
|
|
|
- //lfshook.NewLogger().Infof("===Redirect=Chan===%+v==== ", ret.Channel)
|
|
|
|
|
- err := Redirect(ret.Channel, "0300", "default", exten, "PAD")
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- lfshook.NewLogger().Errorf("Redirect %+v", err)
|
|
|
|
|
|
|
+ if priority.RunningType == "PAD-ICP" || priority.RunningType == "PAD-TMS" {
|
|
|
|
|
+ for _, ret := range chans {
|
|
|
|
|
+ //hangup pad call ICP channel
|
|
|
|
|
+ if utils.IsPAIU(ret.CallerIDNum) {
|
|
|
|
|
+ if ret.ConnectedLineNum == "<unknown>" { //redirect pad chanspy channel
|
|
|
|
|
+ err := Redirect(ret.Channel, "0300", "queues-icp-redirect", "", "PAD")
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ lfshook.NewLogger().Errorf("Redirect %+v", err)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ number := strings.Split(strings.Split(ret.Channel, "-")[0], "/")[1]
|
|
|
|
|
+ active.NotifyPaiu(number, "hold")
|
|
|
|
|
+ //HangupAllLocalChan()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for _, ret := range chans {
|
|
|
|
|
+ //hangup pad call ICP channel
|
|
|
|
|
+ if utils.IsPAIU(ret.CallerIDNum) {
|
|
|
|
|
+ if utils.IsPAIU(ret.CallerIDNum) && ret.ChannelStateDesc == "Up" && utils.IsICP(ret.ConnectedLineNum) {
|
|
|
|
|
+ lfshook.NewLogger().Infof("===Hangup=Chan===%+v==== ", ret.Channel)
|
|
|
|
|
+ Hangup(ret.Channel)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ HangupRunningTask("PA")
|
|
|
|
|
+ } else if priority.RunningType == "PAD-OCC" {
|
|
|
|
|
+ //2. hangup connected PAD, and redirect all PADs in 0301 to 0300
|
|
|
|
|
+ priority.OCCAnswer = 0
|
|
|
|
|
+
|
|
|
|
|
+ resCaller, err := QueueStatus("0301", "") // check OCC queue, get entries
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ lfshook.NewLogger().Infof("===QueueStatus==%+v", err)
|
|
|
|
|
+ }
|
|
|
|
|
+ for _, caller := range resCaller.Entrys {
|
|
|
|
|
+ lfshook.NewLogger().Infof("===QueueStatus=entry=%+v", caller)
|
|
|
|
|
+ time.Sleep(time.Microsecond * 100)
|
|
|
|
|
+ RedirectInQueue(caller.CallerIDNum, "0300", "queues-icp-redirect", caller.CallerIDNum) // redirect All PAD redirect to ICP queue
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* for _, ret := range chans {
|
|
|
|
|
+ //hangup pad call ICP channel
|
|
|
|
|
+ if utils.IsPAIU(ret.CallerIDNum) {
|
|
|
|
|
+ lfshook.NewLogger().Infof("===DTMFBegin=hangup=%+v==%s=== ", ret.Channel, ret.ChannelStateDesc)
|
|
|
|
|
+
|
|
|
|
|
+ if ret.ConnectedLineNum == "<unknown>" && ret.ChannelStateDesc != "Ring" { //redirect pad chanspy channel
|
|
|
|
|
+ Hangup(ret.Channel)
|
|
|
|
|
+ } else if utils.IsICP(ret.ConnectedLineNum) && ret.ChannelStateDesc == "Up" {
|
|
|
|
|
+ Hangup(ret.Channel)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }*/
|
|
|
|
|
+ HangupRunningTask("PA")
|
|
|
|
|
+ //HangupAllLocalChan()
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if event["Digit"] == "*" { //Cab cab interrupt PAD
|
|
|
|
|
+ lfshook.NewLogger().Infof("===Cab cab interrupt PAD====== ")
|
|
|
|
|
+ if priority.RunningType == "PAD-ICP" || priority.RunningType == "PAD-TMS" {
|
|
|
|
|
+ for _, ret := range chans {
|
|
|
|
|
+
|
|
|
|
|
+ if utils.IsPAIU(ret.CallerIDNum) {
|
|
|
|
|
+ if ret.ConnectedLineNum == "<unknown>" && ret.ChannelStateDesc == "Up" { //redirect pad chanspy channel
|
|
|
|
|
+ err := Redirect(ret.Channel, "0300", "queues-icp-redirect", "", "PAD")
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ lfshook.NewLogger().Errorf("Redirect %+v", err)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ number := strings.Split(strings.Split(ret.Channel, "-")[0], "/")[1]
|
|
|
|
|
+ active.NotifyPaiu(number, "hold")
|
|
|
|
|
+ HangupAllLocalChan()
|
|
|
|
|
+
|
|
|
|
|
+ } else if utils.IsPAIU(ret.CallerIDNum) && ret.ChannelStateDesc == "Up" && utils.IsICP(ret.ConnectedLineNum) {
|
|
|
|
|
+ lfshook.NewLogger().Infof("===Hangup=Chan===%+v==== ", ret.Channel)
|
|
|
|
|
+ Hangup(ret.Channel)
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ priority.InterruptedPad = priority.RunningType
|
|
|
|
|
+ HangupAllLocalChan()
|
|
|
|
|
+ Hangup(priority.RunningPATaskChan)
|
|
|
|
|
+ priority.CleanPriorityTag()
|
|
|
|
|
+ //HangupRunningTask("C2C")
|
|
|
|
|
+ } else if priority.RunningType == "PAD-OCC" {
|
|
|
|
|
+ HangupICP()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -57,8 +135,65 @@ func HandleAMI(event map[string]string) {
|
|
|
case "UserEvent": // RCD filename; PA;CPA; CabCab
|
|
case "UserEvent": // RCD filename; PA;CPA; CabCab
|
|
|
lfshook.NewLogger().Infof("========event:%s File:%s", event["Event"], event["FILENAME"])
|
|
lfshook.NewLogger().Infof("========event:%s File:%s", event["Event"], event["FILENAME"])
|
|
|
|
|
|
|
|
- //Get record file name ,encode and upload
|
|
|
|
|
- if event["UserEvent"] == "SetRecordFile" {
|
|
|
|
|
|
|
+ if event["UserEvent"] == "CallType" && (event["Type"] == "PA" || event["Type"] == "CPA") { //PA start; check manual PA priority
|
|
|
|
|
+ //PA & CPA interrupt others
|
|
|
|
|
+ if utils.IsICP(event["CallerIDNum"]) {
|
|
|
|
|
+ //priority.PAStart = 1
|
|
|
|
|
+ if active.ActivedCab == "" { //No active Signal on both side,Hangup caller
|
|
|
|
|
+ Hangup(event["CallerIDNum"])
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if priority.CheckPriority("ManuPa") {
|
|
|
|
|
+ //hangup others if priority is higher
|
|
|
|
|
+ HangupRunningTask("PA") //PA interrupt other
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Hangup(event["CallerIDNum"]) //lowwer priority ,hangup caller
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ } else if utils.IsIO(event["CallerIDNum"]) { // CPA
|
|
|
|
|
+ if priority.CheckPriority("CPA") {
|
|
|
|
|
+ if active.ActivedCab == "" { //No active Signal on both side,Hangup caller
|
|
|
|
|
+ Hangup(event["CallerIDNum"])
|
|
|
|
|
+ } else if active.ActivedCab == "1" && event["CallerIDNum"] == "1411" {
|
|
|
|
|
+ Hangup(event["CallerIDNum"])
|
|
|
|
|
+ } else if active.ActivedCab == "8" && event["CallerIDNum"] == "1481" {
|
|
|
|
|
+ Hangup(event["CallerIDNum"])
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //hangup others if priority is higher
|
|
|
|
|
+ if priority.RunningType != "" {
|
|
|
|
|
+ HangupRunningTask("CPA") //CPA interrupt other
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //call to ICP ; can not stop calling ICP
|
|
|
|
|
+ lfshook.NewLogger().Info("==Running CabCab , CPA start call ICP(ICP is on the phone)=====")
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Hangup(event["CallerIDNum"]) //lowwer priority ,hangup caller
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if event["UserEvent"] == "CallType" && event["Type"] == "C2C" { //CabCab start; check cab cab priority
|
|
|
|
|
+
|
|
|
|
|
+ if priority.CheckPriority("CabCab") { // interrupt OCC-PAD
|
|
|
|
|
+ //C2C start PAD interrupt
|
|
|
|
|
+ if priority.RunningType == "PAD-ICP" || priority.RunningType == "PAD-TMS" || priority.RunningType == "PA" {
|
|
|
|
|
+ HangupRunningTask("C2C")
|
|
|
|
|
+ //Hangup the other ICP
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+ lfshook.NewLogger().Infof("========CabCab hangup other one====caller %s", event["CallerIDNum"])
|
|
|
|
|
+ if event["CallerIDNum"] == "2311" {
|
|
|
|
|
+ Hangup("2381")
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Hangup("2311")
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else { // hangup caller; C2C start failed
|
|
|
|
|
+ lfshook.NewLogger().Infof("========CabCab hangup caller====%s", event["CallerIDNum"])
|
|
|
|
|
+ Hangup(event["CallerIDNum"])
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //Get record file name ,encode and upload
|
|
|
|
|
+ } else if event["UserEvent"] == "SetRecordFile" {
|
|
|
|
|
|
|
|
if configs.ConfigGlobal.ProcessRecord != "yes" {
|
|
if configs.ConfigGlobal.ProcessRecord != "yes" {
|
|
|
break
|
|
break
|
|
@@ -114,7 +249,7 @@ func HandleAMI(event map[string]string) {
|
|
|
file := strings.Replace(filepath, ".wav", "", -1)
|
|
file := strings.Replace(filepath, ".wav", "", -1)
|
|
|
DstFile = fmt.Sprintf("%s-encrypted.wav", file)
|
|
DstFile = fmt.Sprintf("%s-encrypted.wav", file)
|
|
|
|
|
|
|
|
- lfshook.NewLogger().Infof("===========Bin file====%s", DstFile)
|
|
|
|
|
|
|
+ lfshook.NewLogger().Infof("Bin file====%s", DstFile)
|
|
|
err = utils.AudioFileEncode(DstFile, filepath)
|
|
err = utils.AudioFileEncode(DstFile, filepath)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
lfshook.NewLogger().Infof("Encode file: %s err: %+v", DstFile, err)
|
|
lfshook.NewLogger().Infof("Encode file: %s err: %+v", DstFile, err)
|
|
@@ -155,60 +290,6 @@ func HandleAMI(event map[string]string) {
|
|
|
lfshook.NewLogger().Infof("No files to upload!!!")
|
|
lfshook.NewLogger().Infof("No files to upload!!!")
|
|
|
break
|
|
break
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- } else if event["UserEvent"] == "CallType" && (event["Type"] == "PA" || event["Type"] == "CPA") { //PA start; check manual PA priority
|
|
|
|
|
- //PA & CPA interrupt others
|
|
|
|
|
- if utils.IsICP(event["CallerIDNum"]) {
|
|
|
|
|
-
|
|
|
|
|
- if active.ActivedCab == "" { //No active Signal on both side,Hangup caller
|
|
|
|
|
- Hangup(event["CallerIDNum"])
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if priority.CheckPriority("ManuPa") {
|
|
|
|
|
- //hangup others if priority is higher
|
|
|
|
|
- HangupRunningTask("PA") //PA interrupt other
|
|
|
|
|
- } else {
|
|
|
|
|
- Hangup(event["CallerIDNum"]) //lowwer priority ,hangup caller
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- } else if utils.IsIO(event["CallerIDNum"]) { // CPA
|
|
|
|
|
- if priority.CheckPriority("CPA") {
|
|
|
|
|
- if active.ActivedCab == "" { //No active Signal on both side,Hangup caller
|
|
|
|
|
- Hangup(event["CallerIDNum"])
|
|
|
|
|
- } else if active.ActivedCab == "1" && event["CallerIDNum"] == "1411" {
|
|
|
|
|
- Hangup(event["CallerIDNum"])
|
|
|
|
|
- } else if active.ActivedCab == "8" && event["CallerIDNum"] == "1481" {
|
|
|
|
|
- Hangup(event["CallerIDNum"])
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //hangup others if priority is higher
|
|
|
|
|
- if priority.RunningType != "C2C" {
|
|
|
|
|
- HangupRunningTask("CPA") //CPA interrupt other
|
|
|
|
|
- } else {
|
|
|
|
|
- //call to ICP ; can not stop calling ICP
|
|
|
|
|
- lfshook.NewLogger().Info("==Running CabCab , CPA start call ICP(ICP is on the phone)=====")
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- Hangup(event["CallerIDNum"]) //lowwer priority ,hangup caller
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- } else if event["UserEvent"] == "CallType" && event["Type"] == "C2C" { //CabCab start; check cab cab priority
|
|
|
|
|
-
|
|
|
|
|
- if priority.CheckPriority("CabCab") {
|
|
|
|
|
-
|
|
|
|
|
- if priority.RunningType == "PA" || priority.RunningType == "PAD-ICP" || priority.RunningType == "PAD-TMS" {
|
|
|
|
|
- HangupRunningTask("C2C") //C2C interrupt other
|
|
|
|
|
- } else {
|
|
|
|
|
- //Hangup the other ICP
|
|
|
|
|
- if event["CallerIDNum"] == "2311" {
|
|
|
|
|
- Hangup("2381")
|
|
|
|
|
- } else {
|
|
|
|
|
- Hangup("2311")
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- } else { // hangup caller; C2C start failed
|
|
|
|
|
- Hangup(event["CallerIDNum"])
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
case "Hangup":
|
|
case "Hangup":
|
|
@@ -300,8 +381,15 @@ func HandleAMI(event map[string]string) {
|
|
|
//priority.CleanPriorityTag()
|
|
//priority.CleanPriorityTag()
|
|
|
//HangupAllLocalChan()
|
|
//HangupAllLocalChan()
|
|
|
if priority.PADStart == 1 {
|
|
if priority.PADStart == 1 {
|
|
|
|
|
+ SetPadTimer()
|
|
|
alstatus.PaStatus(event["CallerIDNum"], "PAD", "end")
|
|
alstatus.PaStatus(event["CallerIDNum"], "PAD", "end")
|
|
|
priority.PADStart = 0
|
|
priority.PADStart = 0
|
|
|
|
|
+
|
|
|
|
|
+ priority.CleanPriorityTag()
|
|
|
|
|
+
|
|
|
|
|
+ if active.CONBID != "" {
|
|
|
|
|
+ ConfbridgeKick(active.CONBID, "all")
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
/*if priority.ResumeEmgPara.FileName != "" {
|
|
/*if priority.ResumeEmgPara.FileName != "" {
|
|
|
CheckEmgResume()
|
|
CheckEmgResume()
|
|
@@ -331,34 +419,41 @@ func HandleAMI(event map[string]string) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if priority.ICPAnswer == 0 && ICPQueue.Calls == "1" { //ICP did not answer any first call to the ICP queue ; Ready to Set Occ Queue Timer
|
|
if priority.ICPAnswer == 0 && ICPQueue.Calls == "1" { //ICP did not answer any first call to the ICP queue ; Ready to Set Occ Queue Timer
|
|
|
|
|
+ toRunpriority, _ := strconv.Atoi(priority.GetPriorityByKey("PAD-ICP"))
|
|
|
|
|
|
|
|
- active.QueueTimer = time.AfterFunc(30*time.Second, func() { // check the PAD 30s timeout
|
|
|
|
|
|
|
+ //PAD press key
|
|
|
|
|
+ lfshook.NewLogger().Infof("===QueueCallerJoin===runing:%d=====toRun:=%d==Status:%s", priority.RunningTypePriority, toRunpriority, event["ChannelStateDesc"])
|
|
|
|
|
+ if (priority.RunningTypePriority > toRunpriority || priority.RunningTypePriority == 0) && event["ChannelStateDesc"] != "Up" {
|
|
|
|
|
|
|
|
- res, err := QueueStatus("0301", "") // check OCC queue , if empty OCC-PAD start
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- lfshook.NewLogger().Infof("===OCC-QueueStatus==%+v", err)
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ active.QueueTimer = time.AfterFunc(30*time.Second, func() { // check the PAD 30s timeout
|
|
|
|
|
|
|
|
- if res.Calls == "0" { // OCC queue empty
|
|
|
|
|
- resCaller, err := QueueStatus("0300", "") // check ICP queue, get entries
|
|
|
|
|
|
|
+ res, err := QueueStatus("0301", "") // check OCC queue , if empty OCC-PAD start
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
- lfshook.NewLogger().Infof("==ICP=QueueStatus==%+v", err)
|
|
|
|
|
|
|
+ lfshook.NewLogger().Infof("===OCC-QueueStatus==%+v", err)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- sort.Slice(resCaller.Entrys, func(i, j int) bool {
|
|
|
|
|
- return resCaller.Entrys[i].Position < resCaller.Entrys[j].Position
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- for _, caller := range resCaller.Entrys {
|
|
|
|
|
- priority.ICPAnswer = 0
|
|
|
|
|
- lfshook.NewLogger().Infof("====Redirect to 0301 entry:%s=Pos:%s==", caller.CallerIDNum, caller.Position)
|
|
|
|
|
- //order by pos
|
|
|
|
|
- RedirectInQueue(caller.CallerIDNum, "0301", "queues-occ", caller.CallerIDNum) // redirect All ICP-PAD redirect to OCC queue
|
|
|
|
|
- time.Sleep(time.Microsecond * 500) //200 ms delay
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if res.Calls == "0" { // OCC queue empty
|
|
|
|
|
+ resCaller, err := QueueStatus("0300", "") // check ICP queue, get entries
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ lfshook.NewLogger().Infof("==ICP=QueueStatus==%+v", err)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ sort.Slice(resCaller.Entrys, func(i, j int) bool {
|
|
|
|
|
+ return resCaller.Entrys[i].Position < resCaller.Entrys[j].Position
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ for _, caller := range resCaller.Entrys {
|
|
|
|
|
+ priority.ICPAnswer = 0
|
|
|
|
|
+ lfshook.NewLogger().Infof("====QueueCallerJoin==QueueTimer===%s", event["Event"])
|
|
|
|
|
+ lfshook.NewLogger().Infof("====Redirect to 0301 entry:%s=Pos:%s==", caller.CallerIDNum, caller.Position)
|
|
|
|
|
+ //order by pos
|
|
|
|
|
+ RedirectInQueue(caller.CallerIDNum, "0301", "queues-occ", caller.CallerIDNum) // redirect All ICP-PAD redirect to OCC queue
|
|
|
|
|
+ time.Sleep(time.Microsecond * 500) //200 ms delay
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
break
|
|
break
|
|
@@ -417,6 +512,7 @@ func HandleAMI(event map[string]string) {
|
|
|
priority.RunningType = "EMG"
|
|
priority.RunningType = "EMG"
|
|
|
//Pa status report
|
|
//Pa status report
|
|
|
priority.RunningTypePriority, _ = strconv.Atoi(priority.Priority.EMG)
|
|
priority.RunningTypePriority, _ = strconv.Atoi(priority.Priority.EMG)
|
|
|
|
|
+ active.CONBID = event["Conference"]
|
|
|
alstatus.PaStatus("", "EMG", "start")
|
|
alstatus.PaStatus("", "EMG", "start")
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -426,6 +522,7 @@ func HandleAMI(event map[string]string) {
|
|
|
priority.RunningType = "SPC"
|
|
priority.RunningType = "SPC"
|
|
|
//Pa status report
|
|
//Pa status report
|
|
|
priority.RunningTypePriority, _ = strconv.Atoi(priority.Priority.SPC)
|
|
priority.RunningTypePriority, _ = strconv.Atoi(priority.Priority.SPC)
|
|
|
|
|
+ active.CONBID = event["Conference"]
|
|
|
alstatus.PaStatus("", "SPC", "start")
|
|
alstatus.PaStatus("", "SPC", "start")
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -435,6 +532,7 @@ func HandleAMI(event map[string]string) {
|
|
|
priority.RunningType = "DCS"
|
|
priority.RunningType = "DCS"
|
|
|
//Pa status report
|
|
//Pa status report
|
|
|
priority.RunningTypePriority, _ = strconv.Atoi(priority.Priority.DCS)
|
|
priority.RunningTypePriority, _ = strconv.Atoi(priority.Priority.DCS)
|
|
|
|
|
+ active.CONBID = event["Conference"]
|
|
|
alstatus.PaStatus("", "DCS", "start")
|
|
alstatus.PaStatus("", "DCS", "start")
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -444,6 +542,7 @@ func HandleAMI(event map[string]string) {
|
|
|
priority.RunningType = "STN"
|
|
priority.RunningType = "STN"
|
|
|
//Pa status report
|
|
//Pa status report
|
|
|
priority.RunningTypePriority, _ = strconv.Atoi(priority.Priority.STN)
|
|
priority.RunningTypePriority, _ = strconv.Atoi(priority.Priority.STN)
|
|
|
|
|
+ active.CONBID = event["Conference"]
|
|
|
alstatus.PaStatus("", "STN", "start")
|
|
alstatus.PaStatus("", "STN", "start")
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -453,6 +552,7 @@ func HandleAMI(event map[string]string) {
|
|
|
priority.RunningType = "CHK"
|
|
priority.RunningType = "CHK"
|
|
|
//Pa status report
|
|
//Pa status report
|
|
|
priority.RunningTypePriority, _ = strconv.Atoi(priority.Priority.CHK)
|
|
priority.RunningTypePriority, _ = strconv.Atoi(priority.Priority.CHK)
|
|
|
|
|
+ active.CONBID = event["Conference"]
|
|
|
alstatus.PaStatus("", "CHK", "start")
|
|
alstatus.PaStatus("", "CHK", "start")
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -462,11 +562,19 @@ func HandleAMI(event map[string]string) {
|
|
|
priority.RunningType = "VOL"
|
|
priority.RunningType = "VOL"
|
|
|
//Pa status report
|
|
//Pa status report
|
|
|
priority.RunningTypePriority, _ = strconv.Atoi(priority.Priority.VOL)
|
|
priority.RunningTypePriority, _ = strconv.Atoi(priority.Priority.VOL)
|
|
|
|
|
+ active.CONBID = event["Conference"]
|
|
|
alstatus.PaStatus("", "VOL", "start")
|
|
alstatus.PaStatus("", "VOL", "start")
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ //get confbridge id for join back to confbridge
|
|
|
|
|
+ if event["Context"] == "pad-page-occ-icp" && utils.IsPAIU(event["CallerIDNum"]) {
|
|
|
|
|
+ active.CONBID = event["Conference"]
|
|
|
|
|
+ } else if event["Context"] == "cpa-rule" && utils.IsIO(event["CallerIDNum"]) {
|
|
|
|
|
+ active.CONBID = event["Conference"]
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//Send PA start msg to STC
|
|
//Send PA start msg to STC
|
|
|
if utils.IsICP(event["CallerIDNum"]) && event["Exten"] == "0500" { // PA start
|
|
if utils.IsICP(event["CallerIDNum"]) && event["Exten"] == "0500" { // PA start
|
|
|
lfshook.NewLogger().Infof("====PA status:%s=====", "start")
|
|
lfshook.NewLogger().Infof("====PA status:%s=====", "start")
|
|
@@ -528,78 +636,172 @@ func HandleAMI(event map[string]string) {
|
|
|
case "ConfbridgeLeave":
|
|
case "ConfbridgeLeave":
|
|
|
lfshook.NewLogger().Infof("=========%s", event["Event"])
|
|
lfshook.NewLogger().Infof("=========%s", event["Event"])
|
|
|
if utils.IsICP(event["CallerIDNum"]) && event["Exten"] == "0500" { // PA end
|
|
if utils.IsICP(event["CallerIDNum"]) && event["Exten"] == "0500" { // PA end
|
|
|
|
|
+ SetPadTimer()
|
|
|
lfshook.NewLogger().Infof("====PA status =====%s", "end")
|
|
lfshook.NewLogger().Infof("====PA status =====%s", "end")
|
|
|
priority.CleanPriorityTag()
|
|
priority.CleanPriorityTag()
|
|
|
alstatus.PaStatus(event["CallerIDNum"], "PA", "end")
|
|
alstatus.PaStatus(event["CallerIDNum"], "PA", "end")
|
|
|
if priority.ResumeEmgPara.FileName != "" {
|
|
if priority.ResumeEmgPara.FileName != "" {
|
|
|
CheckEmgResume()
|
|
CheckEmgResume()
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ if active.CONBID != "" {
|
|
|
|
|
+ ConfbridgeKick(active.CONBID, "all")
|
|
|
|
|
+ }
|
|
|
} else if utils.IsIO(event["CallerIDNum"]) && event["Exten"] == "0501" { //CPA end
|
|
} else if utils.IsIO(event["CallerIDNum"]) && event["Exten"] == "0501" { //CPA end
|
|
|
lfshook.NewLogger().Infof("====CPA status =====%s", "end")
|
|
lfshook.NewLogger().Infof("====CPA status =====%s", "end")
|
|
|
|
|
+ SetPadTimer()
|
|
|
priority.CleanPriorityTag()
|
|
priority.CleanPriorityTag()
|
|
|
alstatus.PaStatus(event["CallerIDNum"], "CPA", "end")
|
|
alstatus.PaStatus(event["CallerIDNum"], "CPA", "end")
|
|
|
if priority.ResumeEmgPara.FileName != "" {
|
|
if priority.ResumeEmgPara.FileName != "" {
|
|
|
CheckEmgResume()
|
|
CheckEmgResume()
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ if active.CONBID != "" {
|
|
|
|
|
+ ConfbridgeKick(active.CONBID, "all")
|
|
|
|
|
+ }
|
|
|
//lfshook.NewLogger().Infof("=========%s", event["Event"])
|
|
//lfshook.NewLogger().Infof("=========%s", event["Event"])
|
|
|
} else if event["CallerIDName"] == "EMG" && event["Exten"] == "0502" { // EMG broadcast hangup
|
|
} else if event["CallerIDName"] == "EMG" && event["Exten"] == "0502" { // EMG broadcast hangup
|
|
|
|
|
+ SetPadTimer()
|
|
|
priority.CleanPriorityTag()
|
|
priority.CleanPriorityTag()
|
|
|
alstatus.PaStatus(event["CallerIDName"], "EMG", "end")
|
|
alstatus.PaStatus(event["CallerIDName"], "EMG", "end")
|
|
|
priority.ResumeEmgPara = priority.BroadcastResumeParas{}
|
|
priority.ResumeEmgPara = priority.BroadcastResumeParas{}
|
|
|
-
|
|
|
|
|
|
|
+ if active.CONBID != "" {
|
|
|
|
|
+ ConfbridgeKick(active.CONBID, "all")
|
|
|
|
|
+ }
|
|
|
} else if event["CallerIDName"] == "STN" && event["Exten"] == "0503" {
|
|
} else if event["CallerIDName"] == "STN" && event["Exten"] == "0503" {
|
|
|
|
|
+ SetPadTimer()
|
|
|
priority.CleanPriorityTag()
|
|
priority.CleanPriorityTag()
|
|
|
alstatus.PaStatus(event["CallerIDName"], "STN", "end")
|
|
alstatus.PaStatus(event["CallerIDName"], "STN", "end")
|
|
|
if priority.ResumeEmgPara.FileName != "" {
|
|
if priority.ResumeEmgPara.FileName != "" {
|
|
|
CheckEmgResume()
|
|
CheckEmgResume()
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ if active.CONBID != "" {
|
|
|
|
|
+ ConfbridgeKick(active.CONBID, "all")
|
|
|
|
|
+ }
|
|
|
} else if event["CallerIDName"] == "DCS" && event["Exten"] == "0504" {
|
|
} else if event["CallerIDName"] == "DCS" && event["Exten"] == "0504" {
|
|
|
|
|
+ SetPadTimer()
|
|
|
priority.CleanPriorityTag()
|
|
priority.CleanPriorityTag()
|
|
|
alstatus.PaStatus(event["CallerIDName"], "DCS", "end")
|
|
alstatus.PaStatus(event["CallerIDName"], "DCS", "end")
|
|
|
if priority.ResumeEmgPara.FileName != "" {
|
|
if priority.ResumeEmgPara.FileName != "" {
|
|
|
CheckEmgResume()
|
|
CheckEmgResume()
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ if active.CONBID != "" {
|
|
|
|
|
+ ConfbridgeKick(active.CONBID, "all")
|
|
|
|
|
+ }
|
|
|
} else if event["CallerIDName"] == "SPC" && event["Exten"] == "0505" {
|
|
} else if event["CallerIDName"] == "SPC" && event["Exten"] == "0505" {
|
|
|
|
|
+ SetPadTimer()
|
|
|
priority.CleanPriorityTag()
|
|
priority.CleanPriorityTag()
|
|
|
alstatus.PaStatus(event["CallerIDName"], "SPC", "end")
|
|
alstatus.PaStatus(event["CallerIDName"], "SPC", "end")
|
|
|
if priority.ResumeEmgPara.FileName != "" {
|
|
if priority.ResumeEmgPara.FileName != "" {
|
|
|
CheckEmgResume()
|
|
CheckEmgResume()
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ if active.CONBID != "" {
|
|
|
|
|
+ ConfbridgeKick(active.CONBID, "all")
|
|
|
|
|
+ }
|
|
|
} else if event["CallerIDName"] == "CHK" && event["Exten"] == "0510" {
|
|
} else if event["CallerIDName"] == "CHK" && event["Exten"] == "0510" {
|
|
|
|
|
+ SetPadTimer()
|
|
|
priority.CleanPriorityTag()
|
|
priority.CleanPriorityTag()
|
|
|
alstatus.PaStatus(event["CallerIDName"], "CHK", "end")
|
|
alstatus.PaStatus(event["CallerIDName"], "CHK", "end")
|
|
|
if priority.ResumeEmgPara.FileName != "" {
|
|
if priority.ResumeEmgPara.FileName != "" {
|
|
|
CheckEmgResume()
|
|
CheckEmgResume()
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ if active.CONBID != "" {
|
|
|
|
|
+ ConfbridgeKick(active.CONBID, "all")
|
|
|
|
|
+ }
|
|
|
} else if event["CallerIDName"] == "VOL" && event["Exten"] == "0513" {
|
|
} else if event["CallerIDName"] == "VOL" && event["Exten"] == "0513" {
|
|
|
|
|
+ SetPadTimer()
|
|
|
priority.CleanPriorityTag()
|
|
priority.CleanPriorityTag()
|
|
|
alstatus.PaStatus(event["CallerIDName"], "VOL", "end")
|
|
alstatus.PaStatus(event["CallerIDName"], "VOL", "end")
|
|
|
if priority.ResumeEmgPara.FileName != "" {
|
|
if priority.ResumeEmgPara.FileName != "" {
|
|
|
CheckEmgResume()
|
|
CheckEmgResume()
|
|
|
}
|
|
}
|
|
|
|
|
+ if active.CONBID != "" {
|
|
|
|
|
+ ConfbridgeKick(active.CONBID, "all")
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
case "DialEnd":
|
|
case "DialEnd":
|
|
|
//lfshook.NewLogger().Infof("=========%s", event["Event"])
|
|
//lfshook.NewLogger().Infof("=========%s", event["Event"])
|
|
|
//Cab Cab start
|
|
//Cab Cab start
|
|
|
if utils.IsICP(event["CallerIDNum"]) && utils.IsICP(event["ConnectedLineNum"]) && event["DialStatus"] == "ANSWER" {
|
|
if utils.IsICP(event["CallerIDNum"]) && utils.IsICP(event["ConnectedLineNum"]) && event["DialStatus"] == "ANSWER" {
|
|
|
|
|
+
|
|
|
|
|
+ priority.TmpRunningTypePriority = priority.RunningTypePriority
|
|
|
priority.RunningTypePriority, _ = strconv.Atoi(priority.Priority.CabCab)
|
|
priority.RunningTypePriority, _ = strconv.Atoi(priority.Priority.CabCab)
|
|
|
|
|
+
|
|
|
|
|
+ priority.TmpRunningType = priority.RunningType
|
|
|
priority.RunningType = "C2C"
|
|
priority.RunningType = "C2C"
|
|
|
|
|
+
|
|
|
alstatus.PaStatus(event["CallerIDNum"], "C2C", "start")
|
|
alstatus.PaStatus(event["CallerIDNum"], "C2C", "start")
|
|
|
|
|
+ } else if utils.IsICP(event["CallerIDNum"]) && utils.IsICP(event["ConnectedLineNum"]) && event["DialStatus"] == "NOANSWER" {
|
|
|
|
|
+
|
|
|
|
|
+ lfshook.NewLogger().Infof("===%s======%s", event["Event"], priority.RunningType)
|
|
|
|
|
+ //ICPs go back to confbridge
|
|
|
|
|
+ switch priority.RunningType {
|
|
|
|
|
+ case "PAD-OCC":
|
|
|
|
|
+ go DialICP("8", "2311", "confbridge-join", active.CONBID, "1") //ICP1---call
|
|
|
|
|
+ go DialICP("8", "2381", "confbridge-join", active.CONBID, "8") //ICP8---call
|
|
|
|
|
+ case "CPA":
|
|
|
|
|
+ go DialICP("2", "2311", "confbridge-join", active.CONBID, "1") //ICP1---call
|
|
|
|
|
+ go DialICP("2", "2381", "confbridge-join", active.CONBID, "8") //ICP8---call
|
|
|
|
|
+ case "EMG":
|
|
|
|
|
+ go DialICP("3", "2311", "confbridge-join", active.CONBID, "1") //ICP1---call
|
|
|
|
|
+ go DialICP("3", "2381", "confbridge-join", active.CONBID, "8") //ICP8---call
|
|
|
|
|
+ case "SPC":
|
|
|
|
|
+ go DialICP("6", "2311", "confbridge-join", active.CONBID, "1") //ICP1---call
|
|
|
|
|
+ go DialICP("6", "2381", "confbridge-join", active.CONBID, "8") //ICP8---call
|
|
|
|
|
+ case "STN":
|
|
|
|
|
+ go DialICP("4", "2311", "confbridge-join", active.CONBID, "1") //ICP1---call
|
|
|
|
|
+ go DialICP("4", "2381", "confbridge-join", active.CONBID, "8") //ICP8---call
|
|
|
|
|
+ case "DCS":
|
|
|
|
|
+ go DialICP("5", "2311", "confbridge-join", active.CONBID, "1") //ICP1---call
|
|
|
|
|
+ go DialICP("5", "2381", "confbridge-join", active.CONBID, "8") //ICP8---call
|
|
|
|
|
+ case "CHK":
|
|
|
|
|
+ go DialICP("10", "2311", "confbridge-join", active.CONBID, "1") //ICP1---call
|
|
|
|
|
+ go DialICP("10", "2381", "confbridge-join", active.CONBID, "8") //ICP8---call
|
|
|
|
|
+ case "VOL":
|
|
|
|
|
+ go DialICP("11", "2311", "confbridge-join", active.CONBID, "1") //ICP1---call
|
|
|
|
|
+ go DialICP("11", "2381", "confbridge-join", active.CONBID, "8") //ICP8---call
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
case "BridgeLeave":
|
|
case "BridgeLeave":
|
|
|
//lfshook.NewLogger().Infof("=========%s", event["Event"])
|
|
//lfshook.NewLogger().Infof("=========%s", event["Event"])
|
|
|
//Cab Cab end
|
|
//Cab Cab end
|
|
|
if utils.IsICP(event["CallerIDNum"]) && utils.IsICP(event["ConnectedLineNum"]) && event["Exten"] == "0400" {
|
|
if utils.IsICP(event["CallerIDNum"]) && utils.IsICP(event["ConnectedLineNum"]) && event["Exten"] == "0400" {
|
|
|
- priority.RunningTypePriority = 0
|
|
|
|
|
- priority.RunningType = ""
|
|
|
|
|
|
|
+ SetPadTimer()
|
|
|
|
|
+
|
|
|
|
|
+ priority.RunningTypePriority = priority.TmpRunningTypePriority
|
|
|
|
|
+ priority.TmpRunningTypePriority = 0
|
|
|
|
|
+ priority.RunningType = priority.TmpRunningType
|
|
|
|
|
+
|
|
|
|
|
+ //ICPs go back to confbridge
|
|
|
|
|
+ switch priority.TmpRunningType {
|
|
|
|
|
+ case "PAD-OCC":
|
|
|
|
|
+ go DialICP("8", "2311", "confbridge-join", active.CONBID, "1") //ICP1---call
|
|
|
|
|
+ go DialICP("8", "2381", "confbridge-join", active.CONBID, "8") //ICP8---call
|
|
|
|
|
+ case "CPA":
|
|
|
|
|
+ go DialICP("2", "2311", "confbridge-join", active.CONBID, "1") //ICP1---call
|
|
|
|
|
+ go DialICP("2", "2381", "confbridge-join", active.CONBID, "8") //ICP8---call
|
|
|
|
|
+ case "EMG":
|
|
|
|
|
+ go DialICP("3", "2311", "confbridge-join", active.CONBID, "1") //ICP1---call
|
|
|
|
|
+ go DialICP("3", "2381", "confbridge-join", active.CONBID, "8") //ICP8---call
|
|
|
|
|
+ case "SPC":
|
|
|
|
|
+ go DialICP("6", "2311", "confbridge-join", active.CONBID, "1") //ICP1---call
|
|
|
|
|
+ go DialICP("6", "2381", "confbridge-join", active.CONBID, "8") //ICP8---call
|
|
|
|
|
+ case "STN":
|
|
|
|
|
+ go DialICP("4", "2311", "confbridge-join", active.CONBID, "1") //ICP1---call
|
|
|
|
|
+ go DialICP("4", "2381", "confbridge-join", active.CONBID, "8") //ICP8---call
|
|
|
|
|
+ case "DCS":
|
|
|
|
|
+ go DialICP("5", "2311", "confbridge-join", active.CONBID, "1") //ICP1---call
|
|
|
|
|
+ go DialICP("5", "2381", "confbridge-join", active.CONBID, "8") //ICP8---call
|
|
|
|
|
+ case "CHK":
|
|
|
|
|
+ go DialICP("10", "2311", "confbridge-join", active.CONBID, "1") //ICP1---call
|
|
|
|
|
+ go DialICP("10", "2381", "confbridge-join", active.CONBID, "8") //ICP8---call
|
|
|
|
|
+ case "VOL":
|
|
|
|
|
+ go DialICP("11", "2311", "confbridge-join", active.CONBID, "1") //ICP1---call
|
|
|
|
|
+ go DialICP("11", "2381", "confbridge-join", active.CONBID, "8") //ICP8---call
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ priority.TmpRunningType = ""
|
|
|
|
|
+
|
|
|
alstatus.PaStatus(event["CallerIDNum"], "C2C", "end")
|
|
alstatus.PaStatus(event["CallerIDNum"], "C2C", "end")
|
|
|
}
|
|
}
|
|
|
|
|
|