|
@@ -121,11 +121,13 @@ func (M *MQTTBrokerNode) OnMessage(ctx ruleEngine.Context, message *protocol.Mes
|
|
}
|
|
}
|
|
topic := stringBuf.String()
|
|
topic := stringBuf.String()
|
|
fmt.Printf("+++++++++++++++%v\r\n", M.mqttClient)
|
|
fmt.Printf("+++++++++++++++%v\r\n", M.mqttClient)
|
|
- token := M.mqttClient.Publish(topic, 0, false, message.Data)
|
|
|
|
- if token.Error() != nil {
|
|
|
|
- ctx.TellNext(message, protocol.Failure)
|
|
|
|
- } else {
|
|
|
|
- ctx.TellNext(message, protocol.Success)
|
|
|
|
|
|
+ if M.mqttClient != nil {
|
|
|
|
+ token := M.mqttClient.Publish(topic, 0, false, message.Data)
|
|
|
|
+ if token.Error() != nil {
|
|
|
|
+ ctx.TellNext(message, protocol.Failure)
|
|
|
|
+ } else {
|
|
|
|
+ ctx.TellNext(message, protocol.Success)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
return nil
|
|
return nil
|