Add method to publish MQTT messages with retain flag

This commit is contained in:
Vladimir Kotikov 2020-01-07 01:46:20 +03:00 committed by Ron Evans
parent d8291f6de1
commit 06429046a5
1 changed files with 10 additions and 0 deletions

View File

@ -145,6 +145,16 @@ func (a *Adaptor) Publish(topic string, message []byte) bool {
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
func (a *Adaptor) PublishWithQOS(topic string, qos int, message []byte) (paho.Token, error) {
if a.client == nil {