yosssi / gmq

Pure Go MQTT Client
MIT License
345 stars 46 forks source link

API provides no means to see retain flag on received messages #15

Open beanz opened 2 years ago

beanz commented 2 years ago

After a client subscribes, sometimes the first message it receives on a topic is a retained message. Such messages might be old and the client may not wish to act upon such a message so it is useful to be able to distinguish this case. The protocol is such that messages published by the server to the client only have the retain flag set if the message is such a message (that is even if the client that published it set the retain flag the server resets it when it is published if it is sent straightaway.) There is currently no way to distinguish these messages as the handler interface doesn't seem to expose the retain flag.

Not sure if there is a good way to add this while retaining backward compatibility sadly.