Add topic as method parameter
This commit is contained in:
		
							
								
								
									
										3
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								main.go
									
									
									
									
									
								
							@@ -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)
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user