missing handler handling
This commit is contained in:
@ -27,7 +27,7 @@ func InputDispatcher() {
|
||||
for {
|
||||
select {
|
||||
case message := <- mqtt.InputChannel:
|
||||
log.Printf("Message arrived in inputDispatcher, topic: %s, payload: %s\n", message.Topic, message.Payload)
|
||||
log.Printf("Message arrived in inputDispatcher, topic: %s\n", message.Topic)
|
||||
|
||||
for _, mapping := range config.Config.TopicMappings {
|
||||
log.Printf("Testing %s -> %s", mapping.Topics, mapping.Handler)
|
||||
@ -35,8 +35,12 @@ func InputDispatcher() {
|
||||
log.Printf("Testing %s in %s", message.Topic, subscribedTopic)
|
||||
if mqtt.TopicMatchesSubscription(message.Topic, subscribedTopic) {
|
||||
log.Printf("Handle message in handler %s", mapping.Handler)
|
||||
handler := handlerMap[mapping.Handler]
|
||||
handler, exists := handlerMap[mapping.Handler]
|
||||
if exists {
|
||||
handler.Handle(message.Topic, string(message.Payload))
|
||||
} else {
|
||||
log.Printf("Handler not found, message is lost")
|
||||
}
|
||||
} else {
|
||||
log.Printf("no match")
|
||||
}
|
||||
|
Reference in New Issue
Block a user