package ws2 import ( "context" "encoding/json" "github.com/gogf/gf/v2/frame/g" "github.com/gorilla/websocket" "github.com/tiger1103/gfast/v3/api/constant" ) type OffPushFlowReq struct { g.Meta `path:"/device/off" method:"post" tags:"视频安全帽相关" summary:"关闭推流"` DevNum string `json:"devNum" dc:"设备id"` } type OffPushFlowRes struct { } func (w WsRouter) OffPushFlow(ctx context.Context, req *OffPushFlowReq) (res *OffPushFlowRes, err error) { SendDeviceOffPushFlow(constant.Conn, req.DevNum) return res, nil } // 设备关闭推流 func SendDeviceOffPushFlow(conn *websocket.Conn, DeviceId string) { activeDevicesMessage := map[string]string{ "act": "ma_stop_rtsp", "device_id": DeviceId, } conn.WriteJSON(activeDevicesMessage) } // MaStopRtspCommand 定义了停止RTSP流的命令结构体 type MaStopRtspCommand struct { Cmd string `json:"cmd"` // cmd 指令标识 DeviceID string `json:"device_id"` // device_id 设备ID Status bool `json:"status"` // status 返回状态 Msg string `json:"msg"` // msg 返回消息 MsgCode string `json:"msg_code"` // msg_code 返回消息码 } func HandStopPush(jsonString string) { var response MaStopRtspCommand json.Unmarshal([]byte(jsonString), &response) }