Further tweaks to Pusher node - now sends objects ok,

and can receive what it sends...
Also slight rearrange of edit UI to make more like other nodes.
This commit is contained in:
Dave C-J 2014-05-24 18:29:27 +01:00
parent fe0222d498
commit a320ddce23
2 changed files with 23 additions and 21 deletions

View File

@ -18,17 +18,18 @@
<script type="text/x-red" data-template-name="pusher in">
<div class="form-row">
<label for="node-input-topic"><i class="icon-tasks"></i>App Key</label>
<input type="text" id="node-input-appkey_sub" placeholder="apikey">
<label for="node-input-channel"><i class="icon-random"></i> Channel</label>
<input type="text" id="node-input-channel" placeholder="my_channel">
</div>
<div class="form-row">
<label for="node-input-topic"><i class="icon-tasks"></i>Channel</label>
<input type="text" id="node-input-channel" placeholder="channel">
<label for="node-input-eventname"><i class="icon-tasks"></i> Event</label>
<input type="text" id="node-input-eventname" placeholder="test_event_name">
</div>
<div class="form-row">
<label for="node-input-topic"><i class="icon-tasks"></i>Event Name</label>
<input type="text" id="node-input-eventname" placeholder="eventname">
<label for="node-input-appkey_sub"><i class="icon-lock"></i> App Key</label>
<input type="text" id="node-input-appkey_sub" placeholder="key">
</div>
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
@ -89,28 +90,28 @@
<script type="text/x-red" data-template-name="pusher out">
<div class="form-row">
<label for="node-input-topic"><i class="icon-tasks"></i>App ID:</label>
<input type="text" id="node-input-appid" placeholder="appid">
<label for="node-input-channel"><i class="icon-random"></i> Channel</label>
<input type="text" id="node-input-channel" placeholder="my_channel">
</div>
<div class="form-row">
<label for="node-input-topic"><i class="icon-tasks"></i>App Key:</label>
<input type="text" id="node-input-appkey" placeholder="appkey">
<label for="node-input-eventname"><i class="icon-tasks"></i> Event</label>
<input type="text" id="node-input-eventname" placeholder="test_event_name">
</div>
<div class="form-row">
<label for="node-input-topic"><i class="icon-tasks"></i>App Secret:</label>
<input type="text" id="node-input-appsecret" placeholder="appsecret">
<label for="node-input-appid"><i class="icon-tag"></i> App ID</label>
<input type="text" id="node-input-appid" placeholder="app_id">
</div>
<div class="form-row">
<label for="node-input-topic"><i class="icon-tasks"></i>Channel:</label>
<input type="text" id="node-input-channel" placeholder="channel">
<label for="node-input-appkey"><i class="icon-lock"></i> App Key</label>
<input type="text" id="node-input-appkey" placeholder="key">
</div>
<div class="form-row">
<label for="node-input-topic"><i class="icon-tasks"></i>Even Name:</label>
<input type="text" id="node-input-eventname" placeholder="eventname">
<label for="node-input-topic"><i class="icon-asterisk"></i> App Secret</label>
<input type="password" id="node-input-appsecret" placeholder="secret">
</div>
<div class="form-row">

View File

@ -45,7 +45,8 @@ var RED = require(process.env.NODE_RED_HOME+"/red/red");
socket.bind(''+this.eventname,
function(data) {
var msg = {};
msg.payload = data;
if (data.hasOwnProperty("payload")) { msg.payload = data.payload; }
else { msg.payload = data; }
node.send(msg);
}
);
@ -76,14 +77,14 @@ function PusherNodeSend(n) {
this.eventname = n.eventname;
var pusher = new Pusher({
appId: this.appid,
key: this.appkey,
secret: this.appsecret
appId: this.appid,
key: this.appkey,
secret: this.appsecret
});
this.on("input", function(msg){
pusher.trigger(this.channel, this.eventname, {
"message": ""+msg.payload
"payload": msg.payload
});
});