package dispatcher import "log" import "udi/mqtt" import "udi/config" func InputDispatcher() { for { select { case message := <- mqtt.InputChannel: log.Printf("Message arrived in inputDispatcher, topic: %s, payload: %s\n", message.Topic, message.Payload) for _, mapping := range config.Config.TopicMappings { log.Printf("Testing %s -> %s", mapping.Topics, mapping.Plugin) for _, subscribedTopic := range mapping.Topics { log.Printf("Testing %s in %s", message.Topic, subscribedTopic) if mqtt.TopicMatchesSubscription(message.Topic, subscribedTopic) { log.Printf("Handle message in plugin %s", mapping.Plugin) } else { log.Printf("no match") } } } } } }