|
|
@@ -258,22 +258,22 @@ func HandleAMI(event map[string]string) {
|
|
|
priority.OCCAnswer = 0
|
|
|
priority.PADOccStart = 0
|
|
|
|
|
|
- //clean confbridge
|
|
|
+ /*//clean confbridge
|
|
|
taskTmp, _ := priority.RegistryTask.Get("PAD-OCC")
|
|
|
ConfbridgeKick(taskTmp.ConfbridgeID, "all")
|
|
|
|
|
|
- //check resume
|
|
|
- priority.RegistryTask.StopAndUnregister("PAD-OCC")
|
|
|
- taskName, task, ok := priority.RegistryTask.HighestPriorityRunningTask1()
|
|
|
- if ok {
|
|
|
- if taskName == "EMG" {
|
|
|
- EMGConfbridgeReinvite(task.ConfbridgeID)
|
|
|
- } else if taskName == "CPA" {
|
|
|
- CPAConfbridgeReinvite(task.ConfbridgeID)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- break
|
|
|
+ //check resume
|
|
|
+ priority.RegistryTask.StopAndUnregister("PAD-OCC")
|
|
|
+ taskName, task, ok := priority.RegistryTask.HighestPriorityRunningTask1()
|
|
|
+ if ok {
|
|
|
+ if taskName == "EMG" {
|
|
|
+ EMGConfbridgeReinvite(task.ConfbridgeID)
|
|
|
+ } else if taskName == "CPA" {
|
|
|
+ CPAConfbridgeReinvite(task.ConfbridgeID)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ */
|
|
|
+ //break
|
|
|
} else { //OCC queue is not empty
|
|
|
|
|
|
time.Sleep(time.Millisecond * 100) //wait io idle
|
|
|
@@ -333,57 +333,81 @@ func HandleAMI(event map[string]string) {
|
|
|
//lfshook.NewLogger().Infof("===hangup PAD =======================%s", number)
|
|
|
|
|
|
if utils.IsPAIU(number) {
|
|
|
- res, _ := QueueStatus("0300", "") // check ICP queue ,if empty PAD end
|
|
|
- res1, _ := QueueStatus("0301", "") // check OCC queue ,if empty PAD end
|
|
|
- if res == nil || res1 == nil {
|
|
|
- return
|
|
|
- }
|
|
|
- lfshook.NewLogger().Infof("===Hangup PAD====== ICP Queue calls:%s OCC Queue calls:%s", res.Calls, res1.Calls)
|
|
|
- //if res.Calls == "0" && res1.Calls == "0" {
|
|
|
-
|
|
|
- if priority.PADStart == 1 {
|
|
|
- //SetPadTimer()
|
|
|
- alstatus.PaStatus("", "PAD", "end")
|
|
|
- priority.PADStart = 0
|
|
|
- //priority.PADTMSStart = 0
|
|
|
-
|
|
|
- //clean confbridge
|
|
|
- //PAD-ICP
|
|
|
- taskTmp, ok := priority.RegistryTask.Get("PAD-ICP")
|
|
|
- if ok {
|
|
|
- ConfbridgeKick(taskTmp.ConfbridgeID, "all")
|
|
|
- }
|
|
|
+
|
|
|
+ //clean confbridge & clean task info
|
|
|
+ //PAD-ICP
|
|
|
+ taskTmp, ok := priority.RegistryTask.Get("PAD-ICP")
|
|
|
+ if ok {
|
|
|
+ ConfbridgeKick(taskTmp.ConfbridgeID, "all")
|
|
|
priority.RegistryTask.StopAndUnregister("PAD-ICP")
|
|
|
+ }
|
|
|
|
|
|
- // PAD-TMS
|
|
|
- taskTmp, ok = priority.RegistryTask.Get("PAD-TMS")
|
|
|
- if ok {
|
|
|
- ConfbridgeKick(taskTmp.ConfbridgeID, "all")
|
|
|
- }
|
|
|
+ // PAD-TMS
|
|
|
+ taskTmp, ok = priority.RegistryTask.Get("PAD-TMS")
|
|
|
+ if ok {
|
|
|
+ ConfbridgeKick(taskTmp.ConfbridgeID, "all")
|
|
|
priority.RegistryTask.StopAndUnregister("PAD-TMS")
|
|
|
+ }
|
|
|
|
|
|
- //PAD-OCC
|
|
|
- taskTmp, ok = priority.RegistryTask.Get("PAD-OCC")
|
|
|
- if ok {
|
|
|
- ConfbridgeKick(taskTmp.ConfbridgeID, "all")
|
|
|
- }
|
|
|
+ //PAD-OCC
|
|
|
+ taskTmp, ok = priority.RegistryTask.Get("PAD-OCC")
|
|
|
+ if ok {
|
|
|
+ ConfbridgeKick(taskTmp.ConfbridgeID, "all")
|
|
|
priority.RegistryTask.StopAndUnregister("PAD-OCC")
|
|
|
+ }
|
|
|
|
|
|
- //check resume
|
|
|
- taskName, task, ok := priority.RegistryTask.HighestPriorityRunningTask1()
|
|
|
- if ok {
|
|
|
- if taskName == "EMG" {
|
|
|
- EMGConfbridgeReinvite(task.ConfbridgeID)
|
|
|
- } else if taskName == "CPA" {
|
|
|
- CPAConfbridgeReinvite(task.ConfbridgeID)
|
|
|
+ //Check PAD END
|
|
|
+ res, _ := QueueStatus("0300", "") // check ICP queue ,if empty PAD end
|
|
|
+ res1, _ := QueueStatus("0301", "") // check OCC queue ,if empty PAD end
|
|
|
+ if res == nil || res1 == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ lfshook.NewLogger().Infof("===Hangup PAD====== ICP Queue calls:%s OCC Queue calls:%s", res.Calls, res1.Calls)
|
|
|
+ if res.Calls == "0" && res1.Calls == "0" {
|
|
|
+
|
|
|
+ if priority.PADStart == 1 {
|
|
|
+ //SetPadTimer()
|
|
|
+ alstatus.PaStatus("", "PAD", "end")
|
|
|
+ priority.PADStart = 0
|
|
|
+ //priority.PADTMSStart = 0
|
|
|
+ /*
|
|
|
+ //clean confbridge
|
|
|
+ //PAD-ICP
|
|
|
+ taskTmp, ok := priority.RegistryTask.Get("PAD-ICP")
|
|
|
+ if ok {
|
|
|
+ ConfbridgeKick(taskTmp.ConfbridgeID, "all")
|
|
|
+ }
|
|
|
+ priority.RegistryTask.StopAndUnregister("PAD-ICP")
|
|
|
+
|
|
|
+ // PAD-TMS
|
|
|
+ taskTmp, ok = priority.RegistryTask.Get("PAD-TMS")
|
|
|
+ if ok {
|
|
|
+ ConfbridgeKick(taskTmp.ConfbridgeID, "all")
|
|
|
+ }
|
|
|
+ priority.RegistryTask.StopAndUnregister("PAD-TMS")
|
|
|
+
|
|
|
+ //PAD-OCC
|
|
|
+ taskTmp, ok = priority.RegistryTask.Get("PAD-OCC")
|
|
|
+ if ok {
|
|
|
+ ConfbridgeKick(taskTmp.ConfbridgeID, "all")
|
|
|
+ }
|
|
|
+ priority.RegistryTask.StopAndUnregister("PAD-OCC")
|
|
|
+ */
|
|
|
+ //check resume
|
|
|
+ taskName, task, ok := priority.RegistryTask.HighestPriorityRunningTask1()
|
|
|
+ if ok {
|
|
|
+ if taskName == "EMG" {
|
|
|
+ EMGConfbridgeReinvite(task.ConfbridgeID)
|
|
|
+ } else if taskName == "CPA" {
|
|
|
+ CPAConfbridgeReinvite(task.ConfbridgeID)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- priority.ICPAnswer = 0
|
|
|
- priority.OCCAnswer = 0
|
|
|
- break
|
|
|
- //}
|
|
|
+ priority.ICPAnswer = 0
|
|
|
+ priority.OCCAnswer = 0
|
|
|
+ break
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -432,8 +456,8 @@ func HandleAMI(event map[string]string) {
|
|
|
}
|
|
|
}
|
|
|
lfshook.NewLogger().Logger.Infof("=========Start PAD timer !======%d=======", active.PADTimeout)
|
|
|
- //active.QueueTimer = time.AfterFunc(time.Duration(active.PADTimeout)*time.Second, func() { // check the PAD 30s timeout
|
|
|
- active.QueueTimer = time.AfterFunc(30*time.Second, func() { // check the PAD 30s timeout
|
|
|
+ active.QueueTimer = time.AfterFunc(time.Duration(active.PADTimeout)*time.Second, func() { // check the PAD 30s timeout
|
|
|
+ //active.QueueTimer = time.AfterFunc(30*time.Second, func() { // check the PAD 30s timeout
|
|
|
//if both not active , return
|
|
|
if active.ActivedCab == "" {
|
|
|
return
|
|
|
@@ -962,12 +986,11 @@ func HandleAMI(event map[string]string) {
|
|
|
case "DialEnd":
|
|
|
//lfshook.NewLogger().Infof("=========%s", event["Event"])
|
|
|
//Cab Cab start
|
|
|
- if utils.IsICP(event["CallerIDNum"]) && event["Exten"] == " 0400" && event["DialStatus"] == "ANSWER" {
|
|
|
-
|
|
|
+ if utils.IsICP(event["CallerIDNum"]) && event["Exten"] == "0400" && event["DialStatus"] == "ANSWER" {
|
|
|
//================================
|
|
|
task := priority.TaskInfo{
|
|
|
- RunChannel: "",
|
|
|
- LocalChan: "",
|
|
|
+ RunChannel: event["Channel"],
|
|
|
+ LocalChan: event["Channel"],
|
|
|
RunType: "C2C",
|
|
|
Priority: priority.AllTasks.C2C.Priority,
|
|
|
ConfbridgeID: "",
|
|
|
@@ -1037,6 +1060,11 @@ func HandleAMI(event map[string]string) {
|
|
|
alstatus.OccPad("start")
|
|
|
priority.PADOccStart = 1
|
|
|
}
|
|
|
+
|
|
|
+ if priority.PADStart == 0 {
|
|
|
+ alstatus.PaStatus("", "PAD", "start")
|
|
|
+ priority.PADStart = 1
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if utils.IsPACU(event["CallerIDNum"]) && utils.IsPAIU(event["CallerIDName"]) { //ICP and PACU connected
|