Retain availability
This commit is contained in:
parent
0b1065e993
commit
74d2e3cb7c
1 changed files with 2 additions and 2 deletions
4
main.go
4
main.go
|
@ -33,7 +33,7 @@ func main() {
|
||||||
opts.OnConnect = connectHandler
|
opts.OnConnect = connectHandler
|
||||||
opts.SetKeepAlive(20 * time.Second)
|
opts.SetKeepAlive(20 * time.Second)
|
||||||
opts.SetAutoReconnect(true)
|
opts.SetAutoReconnect(true)
|
||||||
opts.SetWill("mqtt2exec/"+os.Args[2]+"/state", "offline", 1, false)
|
opts.SetWill("mqtt2exec/"+os.Args[2]+"/state", "offline", 1, true)
|
||||||
client := mqtt.NewClient(opts)
|
client := mqtt.NewClient(opts)
|
||||||
sleep := 1 * time.Second
|
sleep := 1 * time.Second
|
||||||
for {
|
for {
|
||||||
|
@ -72,5 +72,5 @@ func connectHandler(c mqtt.Client) {
|
||||||
if token.Error() != nil {
|
if token.Error() != nil {
|
||||||
log.Printf("mqtt2exec: Error subscribing to topic: %s", token.Error())
|
log.Printf("mqtt2exec: Error subscribing to topic: %s", token.Error())
|
||||||
}
|
}
|
||||||
c.Publish("mqtt2exec/"+os.Args[2]+"/state", 1, false, "online")
|
c.Publish("mqtt2exec/"+os.Args[2]+"/state", 1, true, "online")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue