lua-mosquitto icon indicating copy to clipboard operation
lua-mosquitto copied to clipboard

mqtt5 support API design?

Open karlp opened this issue 5 years ago • 1 comments

None of the mqttv5 support functions are implemented yet. I'm considering what the APIs shoudl look like?

I believe ~all of the _v5 functions should just be automatically called IFF properties are present as the final argument? Does this make it too hard to use the "sensible defaults" for all the other parameters?

ala:

-- old
publish (topic, payload[, qos=0[, retain=nil]])
--new
publish (topic, payload[, qos=0[, retain=nil[, properties=nil]]])
if properties are present, the _v5 function is called after constructing a properties set.

I believe the properties should just be handled as lua arrays, no need to expose all the internals here. ala:

local props = {
   {m.PROP_RESPONSE_TOPIC, "some string"},
   {m.PROP_BLAH, 9999},
   {m.PROP_ETC, foo}
}
publish(topic, payload, 0, nil, props)

The lua lib can correctly create a proplist by type inspection.

I do NOT know how to best handle the callback registration. We can't always call _v5, as v5 might not be available. Do we have to store the v5 state from connect time or init time and then always use _v5 "as appropriate" ?

karlp avatar Mar 13 '20 11:03 karlp

You could just keep them seperate. Have publish_v5 etc then it would be very similar to https://mosquitto.org/api/files/mosquitto-h.html

It would make them very easy to distiniguish between and simple examples could then be maintained.

theBASTI0N avatar May 01 '20 00:05 theBASTI0N