mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
70 lines
2.7 KiB
HTML
70 lines
2.7 KiB
HTML
|
<!--
|
||
|
Copyright 2013 IBM Corp.
|
||
|
|
||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
you may not use this file except in compliance with the License.
|
||
|
You may obtain a copy of the License at
|
||
|
|
||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||
|
|
||
|
Unless required by applicable law or agreed to in writing, software
|
||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
See the License for the specific language governing permissions and
|
||
|
limitations under the License.
|
||
|
-->
|
||
|
|
||
|
<script type="text/x-red" data-template-name="socket in">
|
||
|
<div class="form-row">
|
||
|
<label for="node-input-transport"><i class="icon-tasks"></i> Type</label>
|
||
|
<select type="text" id="node-input-transport" style="width: 150px;">
|
||
|
<option value="http">http listen</option>
|
||
|
<option value="tcp">tcp server</option>
|
||
|
<!-- <option value="tcpc">tcp client</option> -->
|
||
|
<option value="udp">udp socket</option>
|
||
|
</select>
|
||
|
</div>
|
||
|
<div class="form-row">
|
||
|
<label for="node-input-port"><i class="icon-random"></i> Port</label>
|
||
|
<input type="text" id="node-input-port" placeholder="Port">
|
||
|
</div>
|
||
|
<div class="form-row">
|
||
|
<label for="node-input-topic"><i class="icon-tasks"></i> Topic</label>
|
||
|
<input type="text" id="node-input-topic" placeholder="Topic">
|
||
|
</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">
|
||
|
</div>
|
||
|
<div class="form-tips">Tip: sends the received data as a Buffer object.</div>
|
||
|
</script>
|
||
|
|
||
|
<script type="text/x-red" data-help-name="socket in">
|
||
|
<p>Provides a input node for http, tcp or udp sockets. Topic is optional. These are server like sockets.</p>
|
||
|
<p>The TCP and UDP sockets produce a <i>BUFFER</i> object msg.payload and NOT a String. If you need a String then use .toString() on msg.payload in your next function block.</p>
|
||
|
<p>TCP and UDP sockets also provide <b>msg.fromip</b> of the form ipaddress:port</p>
|
||
|
</script>
|
||
|
|
||
|
<script type="text/javascript">
|
||
|
RED.nodes.registerType('socket in',{
|
||
|
category: 'input',
|
||
|
color:"Silver",
|
||
|
defaults: {
|
||
|
name: {value:""},
|
||
|
topic: {value:""},
|
||
|
port: {value:"",required:true},
|
||
|
transport: {value:"tcp",required:true}
|
||
|
},
|
||
|
inputs:0,
|
||
|
outputs:1,
|
||
|
icon: "bridge-dash.png",
|
||
|
label: function() {
|
||
|
return this.name||this.topic||(this.transport+":"+this.port);
|
||
|
},
|
||
|
labelStyle: function() {
|
||
|
return this.name?"node_label_italic":"";
|
||
|
}
|
||
|
});
|
||
|
|
||
|
</script>
|