Преглед на файлове

add send recording file to stc

dujunchen преди 1 седмица
родител
ревизия
0804c5c41e
променени са 2 файла, в които са добавени 53 реда и са изтрити 3 реда
  1. 7 0
      internal/app/ami/action/index.go
  2. 46 3
      internal/app/stc/sendstatus/status.go

+ 7 - 0
internal/app/ami/action/index.go

@@ -32,6 +32,13 @@ func HandleAMI(event map[string]string) {
 		alstatus.AlarmStatus(event["CallerIDNum"], "dial") // Alarm dial ICP start
 	}
 	*/
+
+	case "UserEvent":
+		lfshook.NewLogger().Infof("========event:%s   File:%s", event["Event"], event["FILENAME"])
+		if event["UserEvent"] == "SetRecordFile" { //get  record file name
+			alstatus.SendRecordFile(event["FILENAME"], event["RecordType"])
+		}
+
 	case "Newchannel":
 		lfshook.NewLogger().Infof("=========%s", event["Event"])
 		if utils.IsPAIU(event["CallerIDNum"]) && event["Exten"] == "0300" { // Alarm dial queue start; PAD dialing

+ 46 - 3
internal/app/stc/sendstatus/status.go

@@ -10,8 +10,6 @@ import (
 	"pbx-api-gin/pkg/utils"
 )
 
-var AlarmHandling = 0
-
 func SendToStc(conn net.Conn, data []byte) {
 
 	_, err := conn.Write(data)
@@ -19,7 +17,7 @@ func SendToStc(conn net.Conn, data []byte) {
 		fmt.Println("send msg err:", err)
 		conn.Close()
 	}
-	lfshook.NewLogger().Logger.Infof("====data:==%x", data)
+	lfshook.NewLogger().Logger.Infof("==send==data:==%x", data)
 }
 
 // report alarm status to STC
@@ -147,3 +145,48 @@ func PaStatus(src string, patype string, operation string) {
 		SendToStc(socket.Conn8, encoded)
 	}
 }
+
+// report broadcast status to STC
+func SendRecordFile(filename, rcdtype string) {
+
+	//time.Sleep(5 * time.Second)
+	/*
+		if !utils.FileExists(filename) {
+			lfshook.NewLogger().Logger.Infof("===Recording filename not exist:%+v=", filename)
+			return
+		}
+	*/
+	protocol := msgdata.NewProtocol()
+	protocol.MessageID = 0x31
+
+	filenameHex := []byte(filename)
+	dataLen := len(filenameHex) + 1
+
+	protocol.DataLength = uint16(dataLen)
+	protocol.Data = make([]byte, dataLen)
+	copy(protocol.Data[1:], filenameHex)
+
+	switch rcdtype {
+	case "C2C": //
+		protocol.Data[0] = 0x01
+	case "PA": //
+		protocol.Data[0] = 0x02
+	case "PAD": //
+		protocol.Data[0] = 0x05
+	case "CPA": //
+		protocol.Data[0] = 0x06
+	case "OTR": //
+		protocol.Data[0] = 0x03
+		//lfshook.NewLogger().Logger.Infof("===Recording filename:%+v=", protocol.Data)
+	}
+	encoded, errEn := protocol.Encode()
+	if errEn != nil {
+		fmt.Println("Encode error:", errEn)
+		return
+	}
+
+	if active.Actived {
+		SendToStc(socket.Conn, encoded)
+		SendToStc(socket.Conn8, encoded)
+	}
+}