Add topic as method parameter

This commit is contained in:
Siegfried Siegert 2020-11-22 12:42:30 +01:00
parent 8e95443548
commit 78241d8e5a
2 changed files with 3 additions and 4 deletions

View File

@ -84,7 +84,8 @@ func main() {
mqtt.Setup(env)
mqtt.Connect()
go mqtt.Listen()
go mqtt.Listen("/ATB/#")
go mqtt.Listen("ATB/#")
http.HandleFunc("/devices", env.DevicesIndex)
go http.ListenAndServe(":3000", nil)

View File

@ -40,7 +40,7 @@ func Connect() {
fmt.Println("connected to broker, topic = ", topic)
}
func Listen() {
func Listen(topic string) {
if !client.IsConnected() {
log.Fatal("Client is not connected")
return
@ -82,8 +82,6 @@ func Setup(environment *env.Env) {
//fmt.Println("customer: ", *customer)
//fmt.Println("device: ", *device)
topic = "/ATB/#"
opts = createClientOptions(ev.Config.BrokerClientID, uri)
}