mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
parent
d457b68941
commit
f3b315ea7c
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2013,2015 IBM Corp.
|
* Copyright 2013,2016 IBM Corp.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -123,6 +123,8 @@ module.exports = function(RED) {
|
|||||||
var self = this;
|
var self = this;
|
||||||
if (this.pusher) {
|
if (this.pusher) {
|
||||||
var stream = this.pusher.stream();
|
var stream = this.pusher.stream();
|
||||||
|
var closing = false;
|
||||||
|
var tout;
|
||||||
stream.on('message', function(res) {
|
stream.on('message', function(res) {
|
||||||
if (res.type === 'tickle') {
|
if (res.type === 'tickle') {
|
||||||
self.handleTickle(res);
|
self.handleTickle(res);
|
||||||
@ -136,21 +138,31 @@ module.exports = function(RED) {
|
|||||||
});
|
});
|
||||||
stream.on('close', function() {
|
stream.on('close', function() {
|
||||||
self.emitter.emit('stream_disconnected');
|
self.emitter.emit('stream_disconnected');
|
||||||
|
if (!closing) {
|
||||||
|
tout = setTimeout(function() {
|
||||||
|
stream.connect();
|
||||||
|
},15000);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
stream.on('error', function(err) {
|
stream.on('error', function(err) {
|
||||||
self.emitter.emit('stream_error', err);
|
self.emitter.emit('stream_error', err);
|
||||||
|
if (!closing) {
|
||||||
|
tout = setTimeout(function() {
|
||||||
|
stream.connect();
|
||||||
|
},15000);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
stream.connect();
|
stream.connect();
|
||||||
this.stream = stream;
|
this.stream = stream;
|
||||||
this.on("close",function() {
|
this.on("close",function() {
|
||||||
|
if (tout) { clearTimeout(tout); }
|
||||||
|
closing = true;
|
||||||
try {
|
try {
|
||||||
this.stream.close();
|
this.stream.close();
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
// Ignore error if not connected
|
// Ignore error if not connected
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -531,10 +543,10 @@ module.exports = function(RED) {
|
|||||||
self.error(err);
|
self.error(err);
|
||||||
});
|
});
|
||||||
config.onConfig('stream_connected', function() {
|
config.onConfig('stream_connected', function() {
|
||||||
self.status({fill: 'green', shape: 'ring', text: 'connected'});
|
self.status({fill:'green', shape:'dot', text:'connected'});
|
||||||
});
|
});
|
||||||
config.onConfig('stream_disconnected', function(err) {
|
config.onConfig('stream_disconnected', function(err) {
|
||||||
self.status({fill: 'red', shape: 'ring', text: 'disconnected'});
|
self.status({fill:'grey', shape:'ring', text:'disconnected'});
|
||||||
});
|
});
|
||||||
config.onConfig('stream_error', function(err) {
|
config.onConfig('stream_error', function(err) {
|
||||||
self.status({fill:'red', shape:'ring', text:'error, see log'});
|
self.status({fill:'red', shape:'ring', text:'error, see log'});
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name" : "node-red-node-pushbullet",
|
"name" : "node-red-node-pushbullet",
|
||||||
"version" : "0.0.7",
|
"version" : "0.0.8",
|
||||||
"description" : "A Node-RED node to send alerts via Pushbullet",
|
"description" : "A Node-RED node to send alerts via Pushbullet",
|
||||||
"dependencies" : {
|
"dependencies" : {
|
||||||
"pushbullet": "1.4.*",
|
"pushbullet": "1.4.*",
|
||||||
|
Loading…
Reference in New Issue
Block a user