hsaturn / TinyMqtt

ESP 8266 / 32 / WROOM Small footprint Mqtt Broker and Client
GNU General Public License v3.0
191 stars 40 forks source link

Conflict with other MqttClient libraries #95

Closed alranel closed 11 months ago

alranel commented 1 year ago

Hello! I'm here with a class naming issue that sometimes pops up among Arduino libraries where the same class name is declared by multiple libraries, which make them not usable at the same time.

In my use case, I'm successfully using MqttBroker from TinyMqtt in combination with the ArduinoIoTCloud library which is based on ArduinoMqttClient to build a gateway.

The problem is that both libraries declare a MqttClient class so they can't be combined in the same sketch, so I have to copy TinyMqtt to my repo and modify it so that the class has a different name. It would be nice to be able to use this upstream library as a direct dependency to avoid the fork.

I understand you will not accept changes that break retrocompatibility, so I have the following proposal for you:

  1. Move MqttClient to a TinyMqtt namespace (TinyMqtt::MqttClient) and to dedicated files (TinyMqttClient.h/cpp);
  2. Have the following in TinyMqtt.h:
    #include <TinyMqttClient.h>
    using namespace TinyMqtt;

So users who don't want to export MqttClient to the global namespace can just include TinyMqttClient.h directly.

If you agree with this proposal (which I believe makes TinyMqtt less invasive thus more versatile) I can submit a pull request. :)