|
|
@@ -36,11 +36,12 @@ func HandleAMI(event map[string]string) {
|
|
|
//lfshook.NewLogger().Infof("===PA interrupt PAD====== ")
|
|
|
|
|
|
InterruptRunningTask("PA")
|
|
|
-
|
|
|
+ time.Sleep(time.Millisecond * 100) //wait endpoimt release
|
|
|
case "*": //Cab cab interrupt PAD
|
|
|
//lfshook.NewLogger().Infof("===Cab cab interrupt PAD====== ")
|
|
|
|
|
|
InterruptRunningTask("C2C")
|
|
|
+ time.Sleep(time.Millisecond * 100) //wait endpoimt release
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -58,8 +59,8 @@ func HandleAMI(event map[string]string) {
|
|
|
if priority.CheckPriority("ManuPa") {
|
|
|
//hangup others if priority is higher
|
|
|
lfshook.NewLogger().Infof("UserEvent event :PA start")
|
|
|
- InterruptRunningTask("PA") //PA interrupt other
|
|
|
-
|
|
|
+ InterruptRunningTask("PA") //PA interrupt other
|
|
|
+ time.Sleep(time.Millisecond * 100) //wait endpoimt release
|
|
|
} else {
|
|
|
Hangup(event["CallerIDNum"]) //lowwer priority ,hangup caller
|
|
|
}
|
|
|
@@ -75,8 +76,8 @@ func HandleAMI(event map[string]string) {
|
|
|
}
|
|
|
|
|
|
//hangup others if priority is higher
|
|
|
- InterruptRunningTask("CPA") //CPA interrupt other
|
|
|
-
|
|
|
+ InterruptRunningTask("CPA") //CPA interrupt other
|
|
|
+ time.Sleep(time.Millisecond * 100) //wait endpoimt release
|
|
|
} else {
|
|
|
Hangup(event["CallerIDNum"]) //lowwer priority ,hangup caller
|
|
|
}
|
|
|
@@ -92,7 +93,7 @@ func HandleAMI(event map[string]string) {
|
|
|
if ok {
|
|
|
if taskName == "PAD-ICP" || taskName == "PAD-TMS" || taskName == "PA" {
|
|
|
InterruptRunningTask("C2C")
|
|
|
-
|
|
|
+ time.Sleep(time.Millisecond * 100) //wait endpoimt release
|
|
|
} else {
|
|
|
lfshook.NewLogger().Infof("CabCab hangup other the one caller %s", event["CallerIDNum"])
|
|
|
if event["CallerIDNum"] == "2311" {
|
|
|
@@ -218,6 +219,7 @@ func HandleAMI(event map[string]string) {
|
|
|
|
|
|
// OCC hangup detected, hangup other running channels
|
|
|
InterruptRunningTask("PAD-OCC")
|
|
|
+ time.Sleep(time.Millisecond * 100) //wait endpoimt release
|
|
|
|
|
|
res, _ := QueueStatus("0301", "") // check OCC queue ,if empty PAD end
|
|
|
if res.Calls == "0" { //OCC queue is empty
|
|
|
@@ -303,52 +305,52 @@ func HandleAMI(event map[string]string) {
|
|
|
res, _ := QueueStatus("0300", "") // check ICP queue ,if empty PAD end
|
|
|
res1, _ := QueueStatus("0301", "") // check OCC queue ,if empty PAD end
|
|
|
|
|
|
- lfshook.NewLogger().Infof("ICP Queue calls:%s OCC Queue calls:%s", res.Calls, res1.Calls)
|
|
|
- if res.Calls == "0" && res1.Calls == "0" {
|
|
|
+ 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
|
|
|
+ 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")
|
|
|
+ //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-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)
|
|
|
- }
|
|
|
+ //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
|
|
|
+ //}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -385,9 +387,17 @@ func HandleAMI(event map[string]string) {
|
|
|
//lfshook.NewLogger().Infof("==2=QueueCallerJoin===runing:%d=====toRun:=%d==Status:%s", taskTmp, toRunpriority, event["ChannelStateDesc"])
|
|
|
|
|
|
//if (priority.RunningTypePriority > toRunpriority || priority.RunningTypePriority == 0) && event["ChannelStateDesc"] != "Up" {
|
|
|
- active.SetTimer = true
|
|
|
+ //active.SetTimer = true
|
|
|
+ //lfshook.NewLogger().Logger.Infof("=========Start PAD timer !=============")
|
|
|
+ if active.QueueTimer != nil {
|
|
|
+ if active.QueueTimer.Stop() {
|
|
|
+ lfshook.NewLogger().Logger.Infof("=========Release PAD timer true !============")
|
|
|
+ } else {
|
|
|
+ lfshook.NewLogger().Logger.Infof("=========Release PAD timer false ! ============")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //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
|
|
|
@@ -430,7 +440,8 @@ func HandleAMI(event map[string]string) {
|
|
|
if utils.IsPAIU(event["CallerIDNum"]) && event["Queue"] == "0301" && priority.OCCAnswer == 0 { // The first PAD to OCC ,caller is PAD
|
|
|
|
|
|
if priority.CheckPriority("PAD-OCC") {
|
|
|
- InterruptRunningTask("PAD-OCC") //PAD-OCC interrupt other
|
|
|
+ InterruptRunningTask("PAD-OCC") //PAD-OCC interrupt other
|
|
|
+ time.Sleep(time.Millisecond * 100) //wait endpoimt release
|
|
|
priority.OCCAnswer = 1
|
|
|
|
|
|
time.Sleep(time.Millisecond * 300)
|
|
|
@@ -453,7 +464,7 @@ func HandleAMI(event map[string]string) {
|
|
|
|
|
|
case "ConfbridgeJoin":
|
|
|
lfshook.NewLogger().Infof("=========%+v", event["Event"])
|
|
|
-
|
|
|
+ lfshook.NewLogger().Infof("=========%+v", event)
|
|
|
//set priority and send PA status msg
|
|
|
switch event["CallerIDName"] {
|
|
|
case "EMG":
|
|
|
@@ -472,9 +483,12 @@ func HandleAMI(event map[string]string) {
|
|
|
alstatus.PaStatus("", "EMG", "start")
|
|
|
//check PAD timer
|
|
|
if priority.AllTasks.PADOCC.Priority > priority.AllTasks.EMG.Priority {
|
|
|
- if active.SetTimer {
|
|
|
- active.QueueTimer.Stop()
|
|
|
- active.SetTimer = false
|
|
|
+ if active.QueueTimer != nil {
|
|
|
+ if active.QueueTimer.Stop() {
|
|
|
+ lfshook.NewLogger().Logger.Infof("=========Release PAD timer true !============")
|
|
|
+ } else {
|
|
|
+ lfshook.NewLogger().Logger.Infof("=========Release PAD timer false ! ============")
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -496,9 +510,12 @@ func HandleAMI(event map[string]string) {
|
|
|
|
|
|
//check PAD timer
|
|
|
if priority.AllTasks.PADOCC.Priority > priority.AllTasks.SPC.Priority {
|
|
|
- if active.SetTimer {
|
|
|
- active.QueueTimer.Stop()
|
|
|
- active.SetTimer = false
|
|
|
+ if active.QueueTimer != nil {
|
|
|
+ if active.QueueTimer.Stop() {
|
|
|
+ lfshook.NewLogger().Logger.Infof("=========Release PAD timer true !============")
|
|
|
+ } else {
|
|
|
+ lfshook.NewLogger().Logger.Infof("=========Release PAD timer false ! ============")
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -519,9 +536,12 @@ func HandleAMI(event map[string]string) {
|
|
|
alstatus.PaStatus("", "DCS", "start")
|
|
|
//check PAD timer
|
|
|
if priority.AllTasks.PADOCC.Priority > priority.AllTasks.DCS.Priority {
|
|
|
- if active.SetTimer {
|
|
|
- active.QueueTimer.Stop()
|
|
|
- active.SetTimer = false
|
|
|
+ if active.QueueTimer != nil {
|
|
|
+ if active.QueueTimer.Stop() {
|
|
|
+ lfshook.NewLogger().Logger.Infof("=========Release PAD timer true !============")
|
|
|
+ } else {
|
|
|
+ lfshook.NewLogger().Logger.Infof("=========Release PAD timer false ! ============")
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -544,9 +564,12 @@ func HandleAMI(event map[string]string) {
|
|
|
|
|
|
//check PAD timer
|
|
|
if priority.AllTasks.PADOCC.Priority > priority.AllTasks.STN.Priority {
|
|
|
- if active.SetTimer {
|
|
|
- active.QueueTimer.Stop()
|
|
|
- active.SetTimer = false
|
|
|
+ if active.QueueTimer != nil {
|
|
|
+ if active.QueueTimer.Stop() {
|
|
|
+ lfshook.NewLogger().Logger.Infof("=========Release PAD timer true !============")
|
|
|
+ } else {
|
|
|
+ lfshook.NewLogger().Logger.Infof("=========Release PAD timer false ! ============")
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -569,9 +592,12 @@ func HandleAMI(event map[string]string) {
|
|
|
|
|
|
//check PAD timer
|
|
|
if priority.AllTasks.PADOCC.Priority > priority.AllTasks.CHK.Priority {
|
|
|
- if active.SetTimer {
|
|
|
- active.QueueTimer.Stop()
|
|
|
- active.SetTimer = false
|
|
|
+ if active.QueueTimer != nil {
|
|
|
+ if active.QueueTimer.Stop() {
|
|
|
+ lfshook.NewLogger().Logger.Infof("=========Release PAD timer true !============")
|
|
|
+ } else {
|
|
|
+ lfshook.NewLogger().Logger.Infof("=========Release PAD timer false ! ============")
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return
|
|
|
@@ -592,9 +618,12 @@ func HandleAMI(event map[string]string) {
|
|
|
|
|
|
//check PAD timer
|
|
|
if priority.AllTasks.PADOCC.Priority > priority.AllTasks.VOL.Priority {
|
|
|
- if active.SetTimer {
|
|
|
- active.QueueTimer.Stop()
|
|
|
- active.SetTimer = false
|
|
|
+ if active.QueueTimer != nil {
|
|
|
+ if active.QueueTimer.Stop() {
|
|
|
+ lfshook.NewLogger().Logger.Infof("=========Release PAD timer true !============")
|
|
|
+ } else {
|
|
|
+ lfshook.NewLogger().Logger.Infof("=========Release PAD timer false ! ============")
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -625,9 +654,12 @@ func HandleAMI(event map[string]string) {
|
|
|
|
|
|
//check PAD timer
|
|
|
if priority.AllTasks.PADOCC.Priority > priority.AllTasks.PA.Priority {
|
|
|
- if active.SetTimer {
|
|
|
- active.QueueTimer.Stop()
|
|
|
- active.SetTimer = false
|
|
|
+ if active.QueueTimer != nil {
|
|
|
+ if active.QueueTimer.Stop() {
|
|
|
+ lfshook.NewLogger().Logger.Infof("=========Release PAD timer true !============")
|
|
|
+ } else {
|
|
|
+ lfshook.NewLogger().Logger.Infof("=========Release PAD timer false ! ============")
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -648,9 +680,12 @@ func HandleAMI(event map[string]string) {
|
|
|
|
|
|
//check PAD timer
|
|
|
if priority.AllTasks.PADOCC.Priority > priority.AllTasks.CPA.Priority {
|
|
|
- if active.SetTimer {
|
|
|
- active.QueueTimer.Stop()
|
|
|
- active.SetTimer = false
|
|
|
+ if active.QueueTimer != nil {
|
|
|
+ if active.QueueTimer.Stop() {
|
|
|
+ lfshook.NewLogger().Logger.Infof("=========Release PAD timer true !============")
|
|
|
+ } else {
|
|
|
+ lfshook.NewLogger().Logger.Infof("=========Release PAD timer false ! ============")
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -905,9 +940,12 @@ func HandleAMI(event map[string]string) {
|
|
|
|
|
|
//check PAD timer
|
|
|
if priority.AllTasks.PADOCC.Priority > priority.AllTasks.C2C.Priority {
|
|
|
- if active.SetTimer {
|
|
|
- active.QueueTimer.Stop()
|
|
|
- active.SetTimer = false
|
|
|
+ if active.QueueTimer != nil {
|
|
|
+ if active.QueueTimer.Stop() {
|
|
|
+ lfshook.NewLogger().Logger.Infof("=========Release PAD timer true !============")
|
|
|
+ } else {
|
|
|
+ lfshook.NewLogger().Logger.Infof("=========Release PAD timer false ! ============")
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|