amenzhinsky / iothub

Azure IoT Hub SDK for Golang
MIT License
53 stars 57 forks source link

Support for OnConnection Lister in MQTT transport #22

Open z-br opened 4 years ago

z-br commented 4 years ago

Setting the OnConnection listener on the MQTT Transports breaks subscriptions, because the library relies on it, so it is impossible to get notifications about disconnect. For disconnects, it is possible to customize the OnConnectionLost as such:

opts := mqtt.WithClientOptionsConfig(func(opts *paho.ClientOptions) {
        opts.OnConnectionLost = func(client paho.Client, e error) {
            onDisconnect(e)
        }
    })

It would be nice if there was someway to get OnConnect callbacks.