|
|
@@ -87,7 +87,7 @@ func HangupAllExcept(caller string) {
|
|
|
|
|
|
// Hangup task
|
|
|
func HangupTask(TaskName string) {
|
|
|
-
|
|
|
+ lfshook.NewLogger().Infof("HangupTask TaskName:%s ", TaskName)
|
|
|
taskInfo, ok := priority.RegistryTask.Get(TaskName)
|
|
|
if ok {
|
|
|
HangupAllLocalChan()
|
|
|
@@ -103,6 +103,8 @@ func InterruptRunningTask(toRunTask string) {
|
|
|
var taskName string
|
|
|
var ok bool
|
|
|
|
|
|
+ lfshook.NewLogger().Infof("InterruptRunningTask toRuntask=%s RunningTask:%s ", toRunTask, taskName)
|
|
|
+
|
|
|
if toRunTask != "PA" && toRunTask != "PAD-ICP" && toRunTask != "PAD-TMS" { // ignore C2C
|
|
|
taskName, task, ok = priority.RegistryTask.HighestPriorityRunningTask1()
|
|
|
if !ok {
|
|
|
@@ -115,17 +117,16 @@ func InterruptRunningTask(toRunTask string) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- lfshook.NewLogger().Infof("===InterruptRunningTask=toRuntask=%s==RunningTask:%s===chan:%s", toRunTask, taskName, task.RunChannel)
|
|
|
-
|
|
|
//same type return
|
|
|
if toRunTask == taskName {
|
|
|
if toRunTask == "PAD-ICP" || toRunTask == "PAD-TMS" || toRunTask == "PAD-OCC" {
|
|
|
|
|
|
+ //Auto Answer PAD-OCC one by one, clean the old confbridge and channels before answer a new PAD .
|
|
|
if toRunTask == "PAD-OCC" {
|
|
|
Hangup(task.RunChannel) //pad
|
|
|
ConfbridgeKick(task.ConfbridgeID, "all")
|
|
|
HangupIO() //io
|
|
|
- lfshook.NewLogger().Infof("===InterruptRunningTask=ret==== ")
|
|
|
+ //lfshook.NewLogger().Infof("===InterruptRunningTask=ret==== ")
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
@@ -156,10 +157,12 @@ func InterruptRunningTask(toRunTask string) {
|
|
|
case "PAD-ICP", "PAD-TMS": // Interrupt PAD task running,
|
|
|
priority.InterruptedPad = "PAD-ICP"
|
|
|
|
|
|
- lfshook.NewLogger().Infof("===InterruptRunningTask==hangup===PAD-ICP==%s==== ", task.RunType)
|
|
|
+ lfshook.NewLogger().Infof("InterruptRunningTask interrupt PAD-ICP/PAD-TMS ,Running type :%s !", task.RunType)
|
|
|
+
|
|
|
chans, err := CoreShowChannels()
|
|
|
if err != nil {
|
|
|
- lfshook.NewLogger().Errorf("CoreShowChannels %+v", err)
|
|
|
+ lfshook.NewLogger().Infof("InterruptRunningTask CoreShowChannels err:%+v", err)
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
//1. Redirect the connected PAD to 0300,hangup the other pad channel
|
|
|
@@ -169,7 +172,8 @@ func InterruptRunningTask(toRunTask string) {
|
|
|
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)
|
|
|
+ lfshook.NewLogger().Infof("InterruptRunningTask Redirect err:%+v", err)
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
number := strings.Split(strings.Split(ret.Channel, "-")[0], "/")[1]
|
|
|
@@ -183,7 +187,7 @@ func InterruptRunningTask(toRunTask string) {
|
|
|
//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)
|
|
|
+ lfshook.NewLogger().Infof("Hangup PAD Channel :%+v", ret.Channel)
|
|
|
Hangup(ret.Channel)
|
|
|
}
|
|
|
}
|
|
|
@@ -192,7 +196,7 @@ func InterruptRunningTask(toRunTask string) {
|
|
|
priority.RegistryTask.StopAndUnregister("PAD-ICP")
|
|
|
priority.RegistryTask.StopAndUnregister("PAD-TMS")
|
|
|
//2. hangup task channel (ICP + PACU)
|
|
|
- lfshook.NewLogger().Infof("===InterruptRunningTask=2. hangup task channel === ")
|
|
|
+ //lfshook.NewLogger().Infof("===InterruptRunningTask=2. hangup task channel === ")
|
|
|
HangupAllLocalChan()
|
|
|
HangupICP()
|
|
|
|
|
|
@@ -214,17 +218,18 @@ func InterruptRunningTask(toRunTask string) {
|
|
|
|
|
|
resCaller, err := QueueStatus("0301", "") // check OCC queue, get entries
|
|
|
if err != nil {
|
|
|
- lfshook.NewLogger().Infof("===QueueStatus==%+v", err)
|
|
|
+ lfshook.NewLogger().Infof("QueueStatus err:%+v", err)
|
|
|
+ return
|
|
|
}
|
|
|
for _, caller := range resCaller.Entrys {
|
|
|
- lfshook.NewLogger().Infof("===QueueStatus=entry=%+v", caller)
|
|
|
+ //lfshook.NewLogger().Infof("===QueueStatus=entry=%+v", caller)
|
|
|
time.Sleep(time.Millisecond * 50)
|
|
|
RedirectInQueue(caller.CallerIDNum, "0300", "queues-icp-redirect", caller.CallerIDNum) // redirect All PAD redirect to ICP queue
|
|
|
}
|
|
|
|
|
|
priority.RegistryTask.StopAndUnregister("PAD-OCC")
|
|
|
//2. Hangup connected PAD
|
|
|
- lfshook.NewLogger().Infof("===InterruptRunningTask=Hangup connected PAD=== ")
|
|
|
+ //lfshook.NewLogger().Infof("===InterruptRunningTask=Hangup connected PAD=== ")
|
|
|
Hangup(task.RunChannel)
|
|
|
|
|
|
//3. Hangup OI & ICP
|
|
|
@@ -241,7 +246,7 @@ func InterruptRunningTask(toRunTask string) {
|
|
|
}
|
|
|
|
|
|
default:
|
|
|
- lfshook.NewLogger().Infof("===InterruptRunningTask=default=== ")
|
|
|
+ lfshook.NewLogger().Infof("InterruptRunningTask goto default !")
|
|
|
//if !strings.Contains(priority.RunningPATaskChan, "0502@default") {
|
|
|
// Hangup(priority.RunningPATaskChan)
|
|
|
//}
|
|
|
@@ -274,12 +279,13 @@ func HangupAllPACU() {
|
|
|
func HangupAllLocalChan() {
|
|
|
chans, err := CoreShowChannels()
|
|
|
if err != nil {
|
|
|
- lfshook.NewLogger().Errorf("CoreShowChannels %+v", err)
|
|
|
+ lfshook.NewLogger().Infof("CoreShowChannels %+v", err)
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
for _, ret := range chans {
|
|
|
if strings.Contains(ret.Channel, "Local") && !strings.Contains(ret.Channel, "0502@default") {
|
|
|
- lfshook.NewLogger().Infof("HangupAllLocalChan=====hangup========= %+v", ret)
|
|
|
+ //lfshook.NewLogger().Infof("HangupAllLocalChan=====hangup========= %+v", ret)
|
|
|
Hangup(ret.Channel)
|
|
|
}
|
|
|
}
|
|
|
@@ -392,7 +398,7 @@ func ChanSpy(src, dst string, whisper, bargein bool) {
|
|
|
// Redirect 转接
|
|
|
func RedirectInQueue(channel, dst, dialrule, callerID string) (err error) {
|
|
|
//callerID := "redirect"
|
|
|
- lfshook.NewLogger().Infof("redirect src %s to dst %s", channel, dst)
|
|
|
+ //lfshook.NewLogger().Infof("redirect src %s to dst %s", channel, dst)
|
|
|
if !utils.IsChannel(channel) {
|
|
|
//callerID = channel
|
|
|
if channel, err = GetChannelByExtenNotBridged(channel); err != nil {
|
|
|
@@ -409,7 +415,7 @@ func RedirectInQueue(channel, dst, dialrule, callerID string) (err error) {
|
|
|
"Priority": "1",
|
|
|
"async": "true",
|
|
|
}
|
|
|
- lfshook.NewLogger().Infof("redirect %+v", action)
|
|
|
+ lfshook.NewLogger().Infof("RedirectInQueue: %+v", action)
|
|
|
res, _, err := AminInstance.Send(action)
|
|
|
if err != nil {
|
|
|
lfshook.NewLogger().Error(err)
|
|
|
@@ -421,7 +427,7 @@ func RedirectInQueue(channel, dst, dialrule, callerID string) (err error) {
|
|
|
// Redirect 转接
|
|
|
func Redirect(channel, dst, dialrule, callerID, callerName string) (err error) {
|
|
|
//callerID := "redirect"
|
|
|
- lfshook.NewLogger().Infof("redirect src %s to dst %s", channel, dst)
|
|
|
+ //lfshook.NewLogger().Infof("redirect src %s to dst %s", channel, dst)
|
|
|
if !utils.IsChannel(channel) {
|
|
|
callerID = channel
|
|
|
if channel, err = GetChannelByExten(channel); err != nil {
|
|
|
@@ -438,7 +444,7 @@ func Redirect(channel, dst, dialrule, callerID, callerName string) (err error) {
|
|
|
"Priority": "1",
|
|
|
"async": "true",
|
|
|
}
|
|
|
- lfshook.NewLogger().Infof("redirect %+v", action)
|
|
|
+ lfshook.NewLogger().Infof("Redirect: %+v", action)
|
|
|
res, _, err := AminInstance.Send(action)
|
|
|
if err != nil {
|
|
|
lfshook.NewLogger().Error(err)
|
|
|
@@ -449,12 +455,12 @@ func Redirect(channel, dst, dialrule, callerID, callerName string) (err error) {
|
|
|
|
|
|
func SetPadTimer() {
|
|
|
|
|
|
- toRunPadpriority := priority.GetPriorityByKey(priority.InterruptedPad) // 获取之前打断的报警优先级
|
|
|
+ toRunPadpriority := priority.GetPriorityByKey(priority.InterruptedPad) //Get PAD priori 获取之前打断的报警优先级
|
|
|
//toRunpriority := priority.GetPriorityByKey("PAD-ICP")
|
|
|
|
|
|
_, taskTmp, ok := priority.RegistryTask.HighestPriorityRunningTask()
|
|
|
if ok {
|
|
|
- lfshook.NewLogger().Infof("==SetPadTimer====runing:%d==toRun:%d=", taskTmp.Priority, toRunPadpriority)
|
|
|
+ lfshook.NewLogger().Infof("PAD SetPadTimer runing priority:%d toRun priority:%d", taskTmp.Priority, toRunPadpriority)
|
|
|
if taskTmp.Priority < toRunPadpriority { //higher priority task running ,do not set timer
|
|
|
return
|
|
|
}
|
|
|
@@ -462,26 +468,26 @@ func SetPadTimer() {
|
|
|
|
|
|
res, err := QueueStatus("0300", "") // check OCC queue , if empty OCC-PAD start
|
|
|
if err != nil {
|
|
|
- lfshook.NewLogger().Infof("===OCC-QueueStatus==%+v", err)
|
|
|
+ lfshook.NewLogger().Infof("QueueStatus err%+v", err)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
if res.Calls != "0" {
|
|
|
|
|
|
- lfshook.NewLogger().Infof("==SetPadTimer==QueueTimer===1====")
|
|
|
+ lfshook.NewLogger().Infof("PAD SetPadTimer Set QueueTimer timeout 30s !")
|
|
|
active.SetTimer = true
|
|
|
active.QueueTimer = time.AfterFunc(30*time.Second, func() { // check the PAD 30s timeout
|
|
|
|
|
|
res, err := QueueStatus("0301", "") // check OCC queue , if empty OCC-PAD start
|
|
|
if err != nil {
|
|
|
- lfshook.NewLogger().Infof("===OCC-QueueStatus==%+v", err)
|
|
|
+ lfshook.NewLogger().Infof("OCC QueueStatus err:%+v", err)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
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)
|
|
|
+ lfshook.NewLogger().Infof("ICP QueueStatus err:%+v", err)
|
|
|
return
|
|
|
}
|
|
|
sort.Slice(resCaller.Entrys, func(i, j int) bool {
|
|
|
@@ -491,7 +497,7 @@ func SetPadTimer() {
|
|
|
for _, caller := range resCaller.Entrys {
|
|
|
priority.ICPAnswer = 0
|
|
|
//lfshook.NewLogger().Infof("====SetPadTimer==QueueTimer==2=")
|
|
|
- lfshook.NewLogger().Infof("==SetPadTimer==Redirect to 0301 entry:%s=Pos:%s==", caller.CallerIDNum, caller.Position)
|
|
|
+ //lfshook.NewLogger().Infof("==SetPadTimer==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.Millisecond * 100) //200 ms delay
|
|
|
@@ -514,7 +520,7 @@ func ConfbridgeKick(confnum, channel string) (res map[string]string, err error)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
- lfshook.NewLogger().Infof("=======ConfbridgeKick==%+v", res)
|
|
|
+ lfshook.NewLogger().Infof("ConfbridgeKick res:%+v", res)
|
|
|
|
|
|
if res["Response"] != "Success" {
|
|
|
return nil, errors.New(res["Message"])
|
|
|
@@ -524,14 +530,12 @@ func ConfbridgeKick(confnum, channel string) (res map[string]string, err error)
|
|
|
}
|
|
|
|
|
|
func CPAConfbridgeKick(confnum string) (res map[string]string, err error) {
|
|
|
- lfshook.NewLogger().Infof("=======CPAConfbridgeKick==%s", confnum)
|
|
|
chans, err := ConfbridgeList(confnum)
|
|
|
if err != nil {
|
|
|
return nil, errors.New(res["Message"])
|
|
|
}
|
|
|
|
|
|
for _, confChan := range chans {
|
|
|
- lfshook.NewLogger().Infof("======CPAConfbridgeKick==1=%+v", confChan)
|
|
|
if !strings.Contains(confChan, "PJSIP/1481") {
|
|
|
ConfbridgeKick(confnum, confChan)
|
|
|
}
|
|
|
@@ -540,7 +544,6 @@ func CPAConfbridgeKick(confnum string) (res map[string]string, err error) {
|
|
|
}
|
|
|
|
|
|
func CPAConfbridgeReinvite(confID string) {
|
|
|
- lfshook.NewLogger().Infof("=====CPAConfbridgeReinvite==")
|
|
|
time.Sleep(time.Millisecond * 500)
|
|
|
for _, ext := range Speakers {
|
|
|
ConfbridgeReinvite(ext, "call-speakers-cpa", confID)
|
|
|
@@ -548,14 +551,13 @@ func CPAConfbridgeReinvite(confID string) {
|
|
|
}
|
|
|
|
|
|
func EMGConfbridgeKick(confnum string) (res map[string]string, err error) {
|
|
|
- lfshook.NewLogger().Infof("=====EMGConfbridgeKick==%s", confnum)
|
|
|
+
|
|
|
chans, err := ConfbridgeList(confnum)
|
|
|
if err != nil {
|
|
|
return nil, errors.New(res["Message"])
|
|
|
}
|
|
|
|
|
|
for _, confChan := range chans {
|
|
|
- lfshook.NewLogger().Infof("====EMGConfbridgeKick==1=%+v", confChan)
|
|
|
if !strings.Contains(confChan, "0502@default") {
|
|
|
ConfbridgeKick(confnum, confChan)
|
|
|
}
|
|
|
@@ -564,13 +566,11 @@ func EMGConfbridgeKick(confnum string) (res map[string]string, err error) {
|
|
|
}
|
|
|
|
|
|
func EMGConfbridgeReinvite(confID string) {
|
|
|
- lfshook.NewLogger().Infof("=======EMGConfbridgeReinvite==")
|
|
|
+
|
|
|
time.Sleep(time.Millisecond * 500)
|
|
|
for _, ext := range Speakers {
|
|
|
- lfshook.NewLogger().Infof("====1===EMGConfbridgeReinvite==")
|
|
|
ConfbridgeReinvite(ext, "call-speakers-emg", confID)
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
func ConfbridgeList(confnum string) (chans []string, err error) {
|
|
|
@@ -584,12 +584,11 @@ func ConfbridgeList(confnum string) (chans []string, err error) {
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
- lfshook.NewLogger().Infof("===ConfbridgeList=res=%+v", res)
|
|
|
+ lfshook.NewLogger().Infof("ConfbridgeList res:%+v", res)
|
|
|
|
|
|
if res["Response"] == "Success" {
|
|
|
for _, event := range events {
|
|
|
if event.Data["Event"] == "ConfbridgeList" {
|
|
|
- //lfshook.NewLogger().Infof("=======ConfbridgeList==%+v", event)
|
|
|
chans = append(chans, event.Data["Channel"])
|
|
|
}
|
|
|
}
|
|
|
@@ -600,9 +599,8 @@ func ConfbridgeList(confnum string) (chans []string, err error) {
|
|
|
}
|
|
|
|
|
|
func ConfbridgeReinvite(src, context, confID string) {
|
|
|
- lfshook.NewLogger().Infof("========ConfbridgeReinvite=======ext:%s==conf:%s===========", src, confID)
|
|
|
if ExtenStatus(src) != "Idle" {
|
|
|
- //lfshook.NewLogger().Infof("===============ext:%s==!Idle===========", src)
|
|
|
+ lfshook.NewLogger().Infof(" ConfbridgeReinvite ext:%s Not Idle !", src)
|
|
|
return
|
|
|
}
|
|
|
|