I'm using the PubSubClient on some ESP-01 modules to make smart/connected devices around the house. I'm not super fond of the way all incoming messages get routed to the single callback. When I get a message, I have to parse the topic and deal with each topic in a switch statement. There's probably a better way to do this but I haven't thought of anything yet.
It would be nice if I could assign a separate callback for each subscribed topic. Right now I just have a list of strings, with the last item being "END", and I loop through subscribing to the items in the list until I hit END. That's fine, but I'd like to be able to dynamically load the topics from the network eventually, so I can't have a hard-coded list or switch statement.
Is there a way to do this? I understand that I'd need a callback for each potential topic but that's fine, I just don't know how to assign callbacks to the topics I'm subscribed to.
4would be easily parsed ........ the key could also be part of the message