eclipse-mosquitto / mosquitto

Eclipse Mosquitto - An open source MQTT broker
https://mosquitto.org
Other
9.1k stars 2.4k forks source link

Usage of mosquitto_callback_register is unclear #2324

Open jplatte opened 3 years ago

jplatte commented 3 years ago

It seems like with a v4 (auth) plugin I can't be notified when a client disconnects to discard client-specific data that I stored in the plugin userdata. The plugin API v5 seems to fix this by allowing one to mosquitto_callback_register a callback for disconnect events, but I can't find any documentation on what to pass for event_data, nor what MOSQ_FUNC_generic_callback is exactly.

jplatte commented 3 years ago

Alternatively, can I store client-specific plugin v4 data in the userdata of the mosquitto instance passed to the plugin functions? This seems like it couldn't work for setups where multiple (non-collaborating) plugins are loaded, but currently I only care about a single-plugin setup.

This probably can't work either because there would be no sensible place to free the mosquitto userdata.

ralight commented 3 years ago

@jplatte You're right, this is a significant missing part, and I'm aware it needs writing. There are some examples here: https://github.com/eclipse/mosquitto/tree/master/plugins

ghost commented 3 years ago

Camera hotel gpd