From 52cfd0309a4801c5c14c3645b7739d169f10e0b6 Mon Sep 17 00:00:00 2001 From: Enrico Ferro Date: Thu, 19 Nov 2015 11:13:23 +0000 Subject: [PATCH 1/3] Add auth_key, cipher_key, UUID - Moved all the configuration in credentials --- nodes/pubnub-node-red.html | 43 +++++++++++++++++++++++++++++--------- nodes/pubnub-node-red.js | 23 +++++++++++++++----- 2 files changed, 51 insertions(+), 15 deletions(-) diff --git a/nodes/pubnub-node-red.html b/nodes/pubnub-node-red.html index 876a7ec..9bbf66e 100755 --- a/nodes/pubnub-node-red.html +++ b/nodes/pubnub-node-red.html @@ -25,7 +25,7 @@ outputs:1, icon: "pnTiny.png", label: function() { - return this.channel||"pubnub"; + return this.channel ||"pubnub"; }, labelStyle: function() { return this.channel?"node_label_italic":""; @@ -78,24 +78,47 @@ diff --git a/nodes/pubnub-node-red.js b/nodes/pubnub-node-red.js index 8d513cc..0bec20e 100755 --- a/nodes/pubnub-node-red.js +++ b/nodes/pubnub-node-red.js @@ -5,10 +5,17 @@ module.exports = function(RED) { // This is a config node holding the keys for connecting to PubNub function PubnubKeysNode(n) { RED.nodes.createNode(this,n); - this.publish_key = n.pub_key; - this.subscribe_key = n.sub_key; } - RED.nodes.registerType("pubnub-keys",PubnubKeysNode); + RED.nodes.registerType("pubnub-keys",PubnubKeysNode,{ + credentials: { + publish_key: { type:"text" }, + subscribe_key: { type:"text" }, + auth_key: { type:"password" }, + cipher_key: { type:"password" }, + ssl: { type:"bool" }, + uuid : { type:"text" } + } + }); // @@ -18,6 +25,8 @@ module.exports = function(RED) { RED.nodes.createNode(this,n); this.channel = n.channel; this.keys = n.keys; + + this.keysConfig = RED.nodes.getNode(this.keys); // Establish a new connection @@ -114,13 +123,17 @@ module.exports = function(RED) { // function PNInit(node) { node.status({fill:"red",shape:"ring",text:"disconnected"}); - var keys = node.keysConfig; + var keys = node.keysConfig.credentials; if (keys) { node.log("Connecting to PubNub (" + keys.publish_key + ":" + keys.subscribe_key+")"); node.pn_obj = PN.init({ publish_key : keys.publish_key, - subscribe_key : keys.subscribe_key + subscribe_key : keys.subscribe_key, + auth_key : keys.auth_key, + cipher_key : keys.cipher_key, + ssl : keys.ssl, + uuid : keys.uuid }); node.status({fill:"yellow",shape:"dot",text:"connected"}); } From f75644e8079df611b2a2939c20f72ffc876581c0 Mon Sep 17 00:00:00 2001 From: Enrico Ferro Date: Thu, 19 Nov 2015 11:18:01 +0000 Subject: [PATCH 2/3] Add Name in Box --- nodes/pubnub-node-red.html | 18 ++++++++++++++---- nodes/pubnub-node-red.js | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/nodes/pubnub-node-red.html b/nodes/pubnub-node-red.html index 9bbf66e..9fad07a 100755 --- a/nodes/pubnub-node-red.html +++ b/nodes/pubnub-node-red.html @@ -7,6 +7,10 @@ +
+ + +
You may listen to a list of comma-separated channels - ch1,ch2,etc.
@@ -25,14 +29,15 @@ outputs:1, icon: "pnTiny.png", label: function() { - return this.channel ||"pubnub"; + return this.name ||"pubnub"; }, labelStyle: function() { return this.channel?"node_label_italic":""; }, defaults: { keys: {type:"pubnub-keys",required:true}, - channel: {value:"node-red",required:true} + channel: {value:"node-red",required:true}, + name: {value:""} } }); @@ -47,6 +52,10 @@ +
+ + +
diff --git a/nodes/pubnub-node-red.js b/nodes/pubnub-node-red.js index 0bec20e..87733e6 100755 --- a/nodes/pubnub-node-red.js +++ b/nodes/pubnub-node-red.js @@ -127,7 +127,7 @@ module.exports = function(RED) { if (keys) { node.log("Connecting to PubNub (" + keys.publish_key + ":" + keys.subscribe_key+")"); - node.pn_obj = PN.init({ + node.pn_obj = PN({ publish_key : keys.publish_key, subscribe_key : keys.subscribe_key, auth_key : keys.auth_key, From a5f66f6600057ffe33fe3f80f64cc6c5bba7ce34 Mon Sep 17 00:00:00 2001 From: Enrico Ferro Date: Thu, 19 Nov 2015 11:53:52 +0000 Subject: [PATCH 3/3] Change to corporate backgroud --- nodes/pubnub-node-red.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nodes/pubnub-node-red.html b/nodes/pubnub-node-red.html index 9fad07a..0825bde 100755 --- a/nodes/pubnub-node-red.html +++ b/nodes/pubnub-node-red.html @@ -24,7 +24,7 @@