dispatcher
This commit is contained in:
27
src/udi/dispatcher/dispatcher.go
Normal file
27
src/udi/dispatcher/dispatcher.go
Normal file
@ -0,0 +1,27 @@
|
||||
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")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user