Skip to content

Commit

Permalink
disconnect on node close
Browse files Browse the repository at this point in the history
  • Loading branch information
realSixi committed Jul 18, 2022
1 parent c19218a commit 511dc41
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/ring-alarm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ const init = (RED: NodeAPI) => {
console.log('Refreshed Token', tokenUpdate);
updateToken(tokenUpdate.newRefreshToken);
});


this.on('close', () => {
this.api.disconnect();
});
} else {
RED.log.error('No Token!');
}

}

RED.nodes.registerType('ring-config', RingConfigNode, {
Expand Down Expand Up @@ -128,6 +132,7 @@ const init = (RED: NodeAPI) => {
RED.nodes.registerType('Device Listener', function(this: nodeRed.Node, config: { config: string } & NodeDef) {
RED.nodes.createNode(this, config);


let configNode: RingConfigNodeType = RED.nodes.getNode(config.config) as RingConfigNodeType;
if (configNode && configNode.api) {
const api = configNode.api;
Expand All @@ -152,6 +157,8 @@ const init = (RED: NodeAPI) => {
console.log('other device update', deviceUpdate);
}
});


});

this.status({
Expand Down

0 comments on commit 511dc41

Please sign in to comment.