UNPKG

node-red-contrib-pubnub

Version:

PubNub input (subscribe) and output (publish) nodes for Node-RED

135 lines (124 loc) 5.09 kB
<script type="text/x-red" data-template-name="pubnub in"> <div class="form-row"> <label for="node-input-keys"><i class="fa fa-globe"></i> Keys</label> <input type="text" id="node-input-keys"> </div> <div class="form-row"> <label for="node-input-channel"><i class="fa fa-tasks"></i> Channel</label> <input type="text" id="node-input-channel" placeholder="node-red"> </div> <div class="form-row"> <label for="node-input-auth_token"><i class="fa fa-tasks"></i> Auth Token</label> <input type="text" id="node-input-auth_token"> </div> <div class="form-row"> <label for="node-input-cipher_key"><i class="fa fa-tasks"></i> Cipher Key</label> <input type="text" id="node-input-cipher_key"> </div> <div class="form-row"> <label for="node-input-ssl"><i class="fa fa-tasks"></i> SSL</label> <input type="checkbox" id="node-input-ssl" checked> </div> <div class="form-tips">You may listen to a list of comma-separated channels - ch1,ch2,etc.</div> </script> <script type="text/x-red" data-help-name="pubnub in"> <p>Subscribes to the PubNub channel (or comma-separated list of channels) specified by the edit window and outputs the received content to <b>msg.payload</b></p> <p>You may listen to a list of comma-separated channels - ch1,ch2,etc.</p> <p>Messages published on that channel will appear on the <code>msg.payload</code> at the output, while <code>msg.channel</code> will contain the name of the channel the message was published on. </script> <script type="text/javascript"> RED.nodes.registerType('pubnub in',{ category: 'input', color:"Silver", inputs:0, outputs:1, icon: "pnTiny.png", label: function() { return this.channel||"pubnub"; }, labelStyle: function() { return this.channel?"node_label_italic":""; }, defaults: { keys: {type:"pubnub-keys", required:true}, channel: {value:"node-red", required:true}, auth_token: { required: false }, cipher_key: { required: false }, ssl: { value: true, required: false }, verbose_logging: { value: false, required: false }, } }); </script> <script type="text/x-red" data-template-name="pubnub out"> <div class="form-row"> <label for="node-input-keys"><i class="fa fa-globe"></i> Keys</label> <input type="text" id="node-input-keys"> </div> <div class="form-row"> <label for="node-input-channel"><i class="fa fa-tasks"></i> Channel</label> <input type="text" id="node-input-channel" placeholder="node-red"> </div> <div class="form-row"> <label for="node-input-auth_token"><i class="fa fa-tasks"></i> Auth Token</label> <input type="text" id="node-input-auth_token"> </div> <div class="form-row"> <label for="node-input-cipher_key"><i class="fa fa-tasks"></i> Cipher Key</label> <input type="text" id="node-input-cipher_key"> </div> <div class="form-row"> <label for="node-input-ssl"><i class="fa fa-tasks"></i> SSL</label> <input type="checkbox" id="node-input-ssl" checked> </div> </script> <script type="text/x-red" data-help-name="pubnub out"> <p>Publishes <b>msg.payload</b> to the PubNub channel specified by the edit window.</p> <p>The <code>msg.payload</code> input may be a string or a JSON object</p> </script> <script type="text/javascript"> RED.nodes.registerType('pubnub out',{ category: 'output', color:"Silver", inputs:1, outputs:0, icon: "pnTiny.png", align: "right", label: function() { return this.channel||"pubnub"; }, labelStyle: function() { return this.channel?"node_label_italic":""; }, defaults: { keys: {type:"pubnub-keys",required:true}, channel: {value:"node-red",required:true}, auth_token: { required: false }, cipher_key: { required: false }, ssl: { value: true, required: false }, verbose_logging: { value: false, required: false }, } }); </script> <script type="text/x-red" data-template-name="pubnub-keys"> <div class="form-row"> <label for="node-config-input-pub_key"><i class="fa fa-tag"></i> Publish Key</label> <input type="text" id="node-config-input-pub_key"> </div> <div class="form-row"> <label for="node-config-input-sub_key"><i class="fa fa-tag"></i> Subscribe Key</label> <input type="text" id="node-config-input-sub_key"> </div> </script> <script type="text/javascript"> RED.nodes.registerType('pubnub-keys',{ category: 'config', defaults: { pub_key: {value:"demo",required:true}, sub_key: {value:"demo",required:true}, }, label: function() { return this.pub_key+"/"+this.sub_key; } }); </script>