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