mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add Force parameter mqtt client.end() when called in disconnect
This commit is contained in:
parent
ca204dea2d
commit
3be75fa822
@ -765,11 +765,23 @@ module.exports = function(RED) {
|
||||
}
|
||||
callback && typeof callback == "function" && callback();
|
||||
};
|
||||
if(node.closing) {
|
||||
return _callback(false, force);
|
||||
}
|
||||
var endCallBack = function endCallBack() {
|
||||
}
|
||||
if(!node.client) { return _callback(); }
|
||||
if(node.closing) { return _callback(); }
|
||||
|
||||
let waitEnd = (client, ms) => {
|
||||
return new Promise( (resolve, reject) => {
|
||||
node.closing = true;
|
||||
if(!client) {
|
||||
resolve();
|
||||
} else {
|
||||
const t = setTimeout(reject, ms);
|
||||
client.end(true, () => {
|
||||
clearTimeout(t);
|
||||
resolve()
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
if(node.connected && node.closeMessage) {
|
||||
node.publish(node.closeMessage, function (err) {
|
||||
node.client.end(endCallBack);
|
||||
|
Loading…
Reference in New Issue
Block a user