summaryrefslogtreecommitdiff
path: root/cache.go
diff options
context:
space:
mode:
Diffstat (limited to 'cache.go')
-rw-r--r--cache.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/cache.go b/cache.go
index 31c8ba5..e5a4e4f 100644
--- a/cache.go
+++ b/cache.go
@@ -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
}