diff options
Diffstat (limited to 'cache.go')
| -rw-r--r-- | cache.go | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -3,21 +3,19 @@ package main import ( "fmt" "log" - - mqtt "github.com/eclipse/paho.mqtt.golang" ) type States map[string]bool type Cache struct { - Client mqtt.Client + Tx chan MQTTMessage States map[string]bool } -func NewCache(client mqtt.Client) Cache { +func NewCache(tx chan MQTTMessage) Cache { var cache Cache - cache.Client = client + cache.Tx = tx cache.States = make(States) return cache @@ -42,7 +40,10 @@ func (c *Cache) Update(states States) { } else { payload = []byte("closed") } - _ = c.Client.Publish(topic, QOS, RETAINED, payload) + c.Tx <- MQTTMessage{ + Topic: topic, + Payload: payload, + } } c.States[id] = state } |
