mirror of
https://github.com/brianshea2/meshmap.net.git
synced 2025-03-05 21:00:01 -08:00
use SubscribeMultiple
This commit is contained in:
parent
77509cb40e
commit
ec6cb716a6
|
@ -9,7 +9,6 @@ import (
|
|||
"log"
|
||||
"os"
|
||||
"regexp"
|
||||
"time"
|
||||
|
||||
"github.com/brianshea2/meshmap.net/internal/meshtastic/generated"
|
||||
mqtt "github.com/eclipse/paho.mqtt.golang"
|
||||
|
@ -56,18 +55,19 @@ func (c *MQTTClient) Connect() error {
|
|||
return err
|
||||
}
|
||||
log.Print("[info] connected")
|
||||
topics := make(map[string]byte)
|
||||
for i, region := range generated.Config_LoRaConfig_RegionCode_name {
|
||||
if i == 0 {
|
||||
continue
|
||||
}
|
||||
topic := "msh/" + region + "/#"
|
||||
token = c.Subscribe(topic, 0, nil)
|
||||
<-token.Done()
|
||||
if err := token.Error(); err != nil {
|
||||
return err
|
||||
}
|
||||
log.Printf("[info] subscribed to %v", topic)
|
||||
topics["msh/"+region+"/#"] = 0
|
||||
}
|
||||
token = c.SubscribeMultiple(topics, nil)
|
||||
<-token.Done()
|
||||
if err := token.Error(); err != nil {
|
||||
return err
|
||||
}
|
||||
log.Print("[info] subscribed")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue