I am using the phao mqtt module to communicate with a mqtt server.
Now I want to subscribe to a topic, for this I need to pass a callback with type MessageHandler
. Is it somehow possible to pass an additional parameter to the MessageHandler
?
My handler looks like this so far:
var MyMessageHandler mqtt.MessageHandler = func(client mqtt.Client, msg mqtt.Message) {
fmt.Printf("Received message: %s from topic: %s
", msg.Payload(), msg.Topic())
# Call here a stuct method
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…