terrorsl/sMQTTBroker

limiting retained topic

MUTTAQUI opened this issue · 7 comments

Hello, is it possible to limit the retained topic

Can you be more specific?

More specifically, it would be great if I could specify the number of retained messages. That way, it would save me a lot of esp32 ram.

The protocol does not provide an opportunity to restrict published messages. I can add functions to get the number of saved messages and let's say a list of topics. Further through standard mechanisms you can delete messages.
By the way, now the message is added to the retained message list before it is passed to the callback, so you can delete it in the callback itself.

First of all thanks for your reply, I would be grateful if you can provide API to get the total number of saved topics, and saved messages and delete the saved messages.

can you please give an example

std::string name=broker.getRetaiedTopicName(index);
// remove topic
broker.publish(name,"");

Thanks for your reply, this will save me a lot of heap memory.