mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
【feat】添加tcp指令下发
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
package nodes
|
||||
|
||||
import (
|
||||
"pandax/pkg/global"
|
||||
"pandax/pkg/mqtt"
|
||||
"pandax/iothub/client/mqttclient"
|
||||
"pandax/pkg/rule_engine/message"
|
||||
)
|
||||
|
||||
type rpcRequestNode struct {
|
||||
bareNode
|
||||
Timeout int `json:"timeout"`
|
||||
Payload mqtt.RpcPayload `json:"payload"`
|
||||
Timeout int `json:"timeout"`
|
||||
Payload mqttclient.RpcPayload `json:"payload"`
|
||||
}
|
||||
|
||||
type rpcRequestNodeFactory struct{}
|
||||
@@ -28,7 +27,7 @@ func (n *rpcRequestNode) Handle(msg *message.Message) error {
|
||||
successLableNode := n.GetLinkedNode("Success")
|
||||
failureLableNode := n.GetLinkedNode("Failure")
|
||||
|
||||
var rpc = &mqtt.RpcRequest{Client: global.MqttClient, Mode: "double", Timeout: n.Timeout}
|
||||
var rpc = &mqttclient.RpcRequest{Client: mqttclient.MqttClient, Mode: "double", Timeout: n.Timeout}
|
||||
rpc.GetRequestId()
|
||||
respPayload, err := rpc.RequestCmd(n.Payload)
|
||||
if err != nil {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package nodes
|
||||
|
||||
import (
|
||||
"pandax/pkg/global"
|
||||
"pandax/pkg/mqtt"
|
||||
"pandax/iothub/client/mqttclient"
|
||||
"pandax/pkg/rule_engine/message"
|
||||
)
|
||||
|
||||
@@ -30,11 +29,11 @@ func (n *rpcRespondNode) Handle(msg *message.Message) error {
|
||||
if RequestId == 0 {
|
||||
RequestId = int(msg.Metadata.GetValue("requestId").(float64))
|
||||
}
|
||||
var datas = mqtt.RpcPayload{
|
||||
var datas = mqttclient.RpcPayload{
|
||||
Method: msg.Msg.GetValue("method").(string),
|
||||
Params: msg.Msg.GetValue("params"),
|
||||
}
|
||||
rpc := &mqtt.RpcRequest{Client: global.MqttClient, RequestId: RequestId}
|
||||
rpc := &mqttclient.RpcRequest{Client: mqttclient.MqttClient, RequestId: RequestId}
|
||||
err := rpc.RespondTpc(datas)
|
||||
if err != nil {
|
||||
if failureLableNode != nil {
|
||||
|
||||
Reference in New Issue
Block a user