Currently the interface does not allow a user to disconnect 'gracefully' from the single client to which it is connected.
This addition allows a process which is connected to an MQTT broker to disconnect accordingly. The following indicates the behaviour of the interface and the 2 functions added
// Is my process currently connected to a broker?
.mqtt.isConnected[]
// Disconnect from a broker to which you are currently connected
/* timeout in milliseconds to allow the handling of in flight messages
.mqtt.disconnect[timeout]
Example usage:
$ q mqtt.q
KDB+ 4.0 2020.04.16 Copyright (C) 1993-2020 Kx Systems
// Check is connected logic
q).mqtt.isConnected[]
0b
q)hst:`$"tcp://localhost:1883"
q).mqtt.conn[hst;`src;()!()]
q).mqtt.isConnected[]
1b
// Highlight current behaviour by attempting to connect again
// results in a disconn callback
q).mqtt.conn[hst;`src;()!()]
q)(`disconn;())
// Gracefully disconnect and reconnect
q).mqtt.disconnect[1000]
"Client successfully destroyed"
q).mqtt.conn[hst;`src;()!()]
// Attempt to disconnect twice
q).mqtt.disconnect[1000]
"Client successfully destroyed"
q).mqtt.disconnect[1000]
'"No client is currently connected"
[0] .mqtt.disconnect[1000]
^
.mqtt.disconnect[timeout] updated to in line with offline suggested change to return null on successful execution. This is more in line with the currently released interfaces
This PR closes #33
Currently the interface does not allow a user to disconnect 'gracefully' from the single client to which it is connected.
This addition allows a process which is connected to an MQTT broker to disconnect accordingly. The following indicates the behaviour of the interface and the 2 functions added
Example usage: