Revert "close fix" - seems to cause more hangs on redeploy than before.

This commit is contained in:
Dave C-J 2013-12-19 15:00:45 +00:00
parent 1fd5e800a6
commit 9347ef2401
1 changed files with 13 additions and 15 deletions

View File

@ -44,18 +44,15 @@ function Blink1Node(n) {
else {
// you can add fancy colours by name here if you want...
// these are the @cheerlight ones.
var result = msg.payload.toLowerCase().match(/red|green|blue|cyan|white|warmwhite|purple|magenta|yellow|orange|black/g);
var colors = {"red":"#FF0000","green":"#008000","blue":"#0000FF","cyan":"#00FFFF","white":"#FFFFFF",
"warmwhite":"#FDF5E6","purple":"#800080","magenta":"#FF00FF","yellow":"#FFFF00","orange":"#FFA500","black":"#000000"}
if (result != null) {
for (var colour in result) {
var c = colors[result[colour]];
var r = parseInt(c.slice(1,3),16);
var g = parseInt(c.slice(3,5),16);
var b = parseInt(c.slice(5),16);
if (node.fade == 0) { blink1.setRGB( r, g, b ); }
else { blink1.fadeToRGB(node.fade, r, g, b ); }
}
if (msg.payload.toLowerCase() in colors) {
var c = colors[msg.payload.toLowerCase()];
var r = parseInt(c.slice(1,3),16);
var g = parseInt(c.slice(3,5),16);
var b = parseInt(c.slice(5),16);
if (node.fade == 0) { blink1.setRGB( r, g, b ); }
else { blink1.fadeToRGB(node.fade, r, g, b ); }
}
else {
node.warn("Blink1 : invalid msg : "+msg.payload);
@ -66,11 +63,12 @@ function Blink1Node(n) {
node.warn("No Blink1 found");
}
});
this.on("close", function() {
if (blink1 && typeof blink1.close == "function") {
blink1.close();
}
});
// This ought to work but seems to cause more hangs on closing than not...
//this.on("close", function() {
//if (blink1 && typeof blink1.close == "function") {
//blink1.close();
//}
//});
var blink1 = new Blink1.Blink1();
}
catch(e) {