xmpp disconnect more cleanly/correctly

This commit is contained in:
Dave Conway-Jones 2021-02-26 16:05:03 +00:00
parent 9db89f3ea1
commit a9d1ca0491
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF
2 changed files with 11 additions and 11 deletions

View File

@ -211,18 +211,18 @@ module.exports = function(RED) {
for (const room of rooms) {
await that.client.send(xml('presence', {to:room, type:'unavailable'}));
}
// if (that.client.connected) {
await that.client.send(xml('presence', {type:'unavailable'}));
try{
if (RED.settings.verbose || LOGITALL) {
that.log("Calling stop() after close, status is "+that.client.status);
if (that.connected) {
await that.client.send(xml('presence', {type:'unavailable'}));
try{
if (RED.settings.verbose || LOGITALL) {
that.log("Calling stop() after close, status is "+that.client.status);
}
await that.client.stop().then(that.log("XMPP client stopped")).catch(error=>{that.warn("Got an error whilst closing xmpp session: "+error)});
}
catch(e) {
that.warn(e);
}
await that.client.stop().then(that.log("XMPP client stopped")).catch(error=>{that.warn("Got an error whilst closing xmpp session: "+error)});
}
catch(e) {
that.warn(e);
}
// }
done();
});
}

View File

@ -1,6 +1,6 @@
{
"name": "node-red-node-xmpp",
"version": "0.4.1",
"version": "0.4.2",
"description": "A Node-RED node to talk to an XMPP server",
"dependencies": {
"@xmpp/client": "^0.12.0"