Add topic as method parameter
This commit is contained in:
parent
8e95443548
commit
78241d8e5a
3
main.go
3
main.go
@ -84,7 +84,8 @@ func main() {
|
|||||||
|
|
||||||
mqtt.Setup(env)
|
mqtt.Setup(env)
|
||||||
mqtt.Connect()
|
mqtt.Connect()
|
||||||
go mqtt.Listen()
|
go mqtt.Listen("/ATB/#")
|
||||||
|
go mqtt.Listen("ATB/#")
|
||||||
|
|
||||||
http.HandleFunc("/devices", env.DevicesIndex)
|
http.HandleFunc("/devices", env.DevicesIndex)
|
||||||
go http.ListenAndServe(":3000", nil)
|
go http.ListenAndServe(":3000", nil)
|
||||||
|
@ -40,7 +40,7 @@ func Connect() {
|
|||||||
fmt.Println("connected to broker, topic = ", topic)
|
fmt.Println("connected to broker, topic = ", topic)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Listen() {
|
func Listen(topic string) {
|
||||||
if !client.IsConnected() {
|
if !client.IsConnected() {
|
||||||
log.Fatal("Client is not connected")
|
log.Fatal("Client is not connected")
|
||||||
return
|
return
|
||||||
@ -82,8 +82,6 @@ func Setup(environment *env.Env) {
|
|||||||
//fmt.Println("customer: ", *customer)
|
//fmt.Println("customer: ", *customer)
|
||||||
//fmt.Println("device: ", *device)
|
//fmt.Println("device: ", *device)
|
||||||
|
|
||||||
topic = "/ATB/#"
|
|
||||||
|
|
||||||
opts = createClientOptions(ev.Config.BrokerClientID, uri)
|
opts = createClientOptions(ev.Config.BrokerClientID, uri)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user