|
|
@ -22,7 +22,7 @@ func main() {
|
|
|
|
fmt.Printf("Received Message: %s from topic %s\n", msg.Payload(), msg.Topic())
|
|
|
|
fmt.Printf("Received Message: %s from topic %s\n", msg.Payload(), msg.Topic())
|
|
|
|
})
|
|
|
|
})
|
|
|
|
options.OnConnect = func(c mqtt.Client) { fmt.Println("Connected to Broker") }
|
|
|
|
options.OnConnect = func(c mqtt.Client) { fmt.Println("Connected to Broker") }
|
|
|
|
options.OnConnectionLost = func(c mqtt.Client, err error) { fmt.Println("Connection Lost: %v", err) }
|
|
|
|
options.OnConnectionLost = func(c mqtt.Client, err error) { fmt.Printf("Connection Lost: %v\n", err) }
|
|
|
|
client := mqtt.NewClient(options)
|
|
|
|
client := mqtt.NewClient(options)
|
|
|
|
if token := client.Connect(); token.Wait() && token.Error() != nil {
|
|
|
|
if token := client.Connect(); token.Wait() && token.Error() != nil {
|
|
|
|
panic(token.Error())
|
|
|
|
panic(token.Error())
|
|
|
|