Skip to content

Commit

Permalink
Add MQTTClient.PublishSynced (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
sikmir authored Dec 28, 2024
1 parent 6bd9cd9 commit 54c8b28
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions mqtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type MQTTClient interface {
Start()
Stop()
Publish(message MQTTMessage)
PublishSynced(message MQTTMessage)
Subscribe(callback MQTTMessageHandler, topics ...string)
Unsubscribe(topics ...string)
}
Expand Down
5 changes: 5 additions & 0 deletions testutils/fake_mqtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@ func (client *FakeMQTTClient) Publish(message wbgong.MQTTMessage) {
client.broker.Publish(client.id, message)
}

func (client *FakeMQTTClient) PublishSynced(message wbgong.MQTTMessage) {
client.ensureStarted()
client.broker.Publish(client.id, message)
}

func (client *FakeMQTTClient) Subscribe(callback wbgong.MQTTMessageHandler, topics ...string) {
client.Lock()
defer client.Unlock()
Expand Down

0 comments on commit 54c8b28

Please sign in to comment.