mirror of
https://github.com/hybridgroup/gobot.git
synced 2025-05-01 13:48:57 +08:00
Add method to publish MQTT messages with retain flag
This commit is contained in:
parent
d8291f6de1
commit
06429046a5
@ -145,6 +145,16 @@ func (a *Adaptor) Publish(topic string, message []byte) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PublishAndRetain publishes a message under a specific topic with retain flag
|
||||||
|
func (a *Adaptor) PublishAndRetain(topic string, message []byte) bool {
|
||||||
|
if a.client == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
a.client.Publish(topic, byte(a.qos), true, message)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// PublishWithQOS allows per-publish QOS values to be set and returns a poken.Token
|
// PublishWithQOS allows per-publish QOS values to be set and returns a poken.Token
|
||||||
func (a *Adaptor) PublishWithQOS(topic string, qos int, message []byte) (paho.Token, error) {
|
func (a *Adaptor) PublishWithQOS(topic string, qos int, message []byte) (paho.Token, error) {
|
||||||
if a.client == nil {
|
if a.client == nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user