Bugfix connecting state

This commit is contained in:
Olivier Verhaegen 2023-04-12 16:02:19 +02:00 committed by GitHub
parent 1a0d1ce173
commit 3b24d81db5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -87,9 +87,7 @@ module.exports = function(RED) {
});
// Connect to server if needed and subscribe
node.status({fill:"grey",shape:"ring",text:"connecting"});
function subscribe() {
const subscribe = () => {
node.log('subscribing to: '+node.topic);
node.client.subscribe(node.topic, node.subscribeHeaders, function(body, headers) {
var newmsg={"headers":headers,"topic":node.topic}
@ -104,6 +102,7 @@ module.exports = function(RED) {
}
if (!node.server.connected) {
node.status({fill:"grey",shape:"ring",text:"connecting"});
node.client.connect(function(sessionId) {
subscribe();
}, function(error) {
@ -176,8 +175,8 @@ module.exports = function(RED) {
});
// Connect to server if needed
node.status({fill:"grey",shape:"ring",text:"connecting"});
if(!node.serverConfig.connected) {
node.status({fill:"grey",shape:"ring",text:"connecting"});
node.client.connect(function(sessionId) {}, function(error) {
node.status({fill:"grey",shape:"dot",text:"error"});
node.warn(error);
@ -250,8 +249,8 @@ module.exports = function(RED) {
});
// Connect to server if needed
node.status({fill:"grey",shape:"ring",text:"connecting"});
if(!node.serverConfig.connected) {
node.status({fill:"grey",shape:"ring",text:"connecting"});
node.client.connect(function(sessionId) {}, function(error) {
node.status({fill:"grey",shape:"dot",text:"error"});
node.warn(error);