mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Update pusher dependencies & code (#974)
* update pusher dependencies & code * Update package.json * update pusher icon * Reverting some package.json changes * add contributors * Add padding to icon * resize icon * Updated available clusters * update broken link to cluster option * Update clusters for out node
This commit is contained in:
parent
a8edd0cb56
commit
0a0917b67a
Binary file not shown.
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 1.3 KiB |
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "node-red-node-pusher",
|
"name": "node-red-node-pusher",
|
||||||
"version": "0.1.0",
|
"version": "0.1.1",
|
||||||
"description": "A Node-RED node to send and receive messages using Pusher.com",
|
"description": "A Node-RED node to send and receive messages using Pusher.com",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"pusher": "^1.5.1",
|
"pusher": "^5.1.2",
|
||||||
"pusher-client": "^1.1.0"
|
"pusher-js": "^8.0.1"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -25,5 +25,11 @@
|
|||||||
"name": "Dave Conway-Jones",
|
"name": "Dave Conway-Jones",
|
||||||
"email": "ceejay@vnet.ibm.com",
|
"email": "ceejay@vnet.ibm.com",
|
||||||
"url": "http://nodered.org"
|
"url": "http://nodered.org"
|
||||||
|
},
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "Shaqaruden",
|
||||||
|
"email": "shaqaruden@gmail.com"
|
||||||
}
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
<script type="text/x-red" data-template-name="pusher in">
|
<script type="text/x-red" data-template-name="pusher in">
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-channel"><i class="fa fa-random"></i> Channel</label>
|
<label for="node-input-channel"><i class="fa fa-random"></i> Channel</label>
|
||||||
<input type="text" id="node-input-channel" placeholder="my_channel">
|
<input type="text" id="node-input-channel" placeholder="Channel">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-eventname"><i class="fa fa-tasks"></i> Event</label>
|
<label for="node-input-eventname"><i class="fa fa-tasks"></i> Event</label>
|
||||||
<input type="text" id="node-input-eventname" placeholder="test_event_name">
|
<input type="text" id="node-input-eventname" placeholder="Event Name">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-pusherappkeysub"><i class="fa fa-lock"></i> App Key</label>
|
<label for="node-input-pusherappkeysub"><i class="fa fa-lock"></i> App Key</label>
|
||||||
@ -15,10 +15,15 @@
|
|||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-cluster"><i class="fa fa-server"></i> Cluster</label>
|
<label for="node-input-cluster"><i class="fa fa-server"></i> Cluster</label>
|
||||||
<select type="text" id="node-input-cluster">
|
<select type="text" id="node-input-cluster">
|
||||||
<option value="mt1">us-east-1 (US - default)</option>
|
<option value="mt1">N. Virginia (US - default)</option>
|
||||||
<option value="eu">eu-west-1 (Europe)</option>
|
<option value="us2">Ohio (US)</option>
|
||||||
<option value="ap1">ap-southeast-1 (Singapore)</option>
|
<option value="us3">Oregon (US)</option>
|
||||||
<option value="ap2">ap-south-1 (Mumbai)</option>
|
<option value="eu">Ireland (Europe)</option>
|
||||||
|
<option value="ap1">Singapore (Asia)</option>
|
||||||
|
<option value="ap2">Mumbai (India)</option>
|
||||||
|
<option value="ap3">Tokyo (Asia)</option>
|
||||||
|
<option value="ap4">Sydney (Australia)</option>
|
||||||
|
<option value="sa1">São Paulo (Brazil)</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
@ -87,10 +92,15 @@
|
|||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-cluster"><i class="fa fa-server"></i> Cluster</label>
|
<label for="node-input-cluster"><i class="fa fa-server"></i> Cluster</label>
|
||||||
<select type="text" id="node-input-cluster">
|
<select type="text" id="node-input-cluster">
|
||||||
<option value="mt1">us-east-1 (US - default)</option>
|
<option value="mt1">N. Virginia (US - default)</option>
|
||||||
<option value="eu">eu-west-1 (Europe)</option>
|
<option value="us2">Ohio (US)</option>
|
||||||
<option value="ap1">ap-southeast-1 (Singapore)</option>
|
<option value="us3">Oregon (US)</option>
|
||||||
<option value="ap2">ap-south-1 (Mumbai)</option>
|
<option value="eu">Ireland (Europe)</option>
|
||||||
|
<option value="ap1">Singapore (Asia)</option>
|
||||||
|
<option value="ap2">Mumbai (India)</option>
|
||||||
|
<option value="ap3">Tokyo (Asia)</option>
|
||||||
|
<option value="ap4">Sydney (Australia)</option>
|
||||||
|
<option value="sa1">São Paulo (Brazil)</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
module.exports = function (RED) {
|
module.exports = function (RED) {
|
||||||
"use strict";
|
"use strict";
|
||||||
var Pusher = require('pusher');
|
const Pusher = require("pusher")
|
||||||
var PusherClient = require('pusher-client');
|
const PusherClient = require('pusher-js');
|
||||||
|
|
||||||
//node for subscribing to an event/channel
|
//node for subscribing to an event/channel
|
||||||
function PusherNode(n) {
|
function PusherNode(n) {
|
||||||
@ -19,19 +19,21 @@ module.exports = function(RED) {
|
|||||||
else { this.error("No Pusher app key set for input node"); }
|
else { this.error("No Pusher app key set for input node"); }
|
||||||
|
|
||||||
//create a subscription to the channel and event defined by user
|
//create a subscription to the channel and event defined by user
|
||||||
var socket = new PusherClient(''+node.appkey, {cluster:node.cluster, encrypted:true});
|
// var socket = new PusherClient(''+node.appkey, {cluster:node.cluster, encrypted:true});
|
||||||
var chan = socket.subscribe(''+node.channel);
|
const pusher = new PusherClient('' + node.appkey, {
|
||||||
chan.bind(''+node.eventname,
|
cluster: node.cluster
|
||||||
function(data) {
|
});
|
||||||
|
const channel = pusher.subscribe('' + node.channel);
|
||||||
|
|
||||||
|
channel.bind('' + node.eventname, function (data) {
|
||||||
var msg = { topic: node.eventname, channel: node.channel };
|
var msg = { topic: node.eventname, channel: node.channel };
|
||||||
if (data.hasOwnProperty("payload")) { msg.payload = data.payload; }
|
if (data.hasOwnProperty("payload")) { msg.payload = data.payload; }
|
||||||
else { msg.payload = data; }
|
else { msg.payload = data; }
|
||||||
node.send(msg);
|
node.send(msg);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
node.on("close", function () {
|
node.on("close", function () {
|
||||||
socket.disconnect();
|
pusher.disconnect();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,15 +58,17 @@ module.exports = function(RED) {
|
|||||||
this.eventname = n.eventname;
|
this.eventname = n.eventname;
|
||||||
this.cluster = n.cluster || "mt1";
|
this.cluster = n.cluster || "mt1";
|
||||||
|
|
||||||
var pusherd = new Pusher({
|
var pusher = new Pusher({
|
||||||
appId: this.appid,
|
appId: this.appid,
|
||||||
key: this.appkey,
|
key: this.appkey,
|
||||||
secret: this.appsecret,
|
secret: this.appsecret,
|
||||||
cluster: this.cluster
|
cluster: this.cluster
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
node.on("input", function (msg) {
|
node.on("input", function (msg) {
|
||||||
pusherd.trigger(this.channel, this.eventname, {
|
pusher.trigger(this.channel, this.eventname, {
|
||||||
"payload": msg.payload
|
"payload": msg.payload
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user