mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Allow TCP node option to break connections per message (and auto
reconnect) - eg for file trnasfer to indicate EOF. Change to FA icons.
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
|
||||
<script type="text/x-red" data-template-name="tcp in">
|
||||
<div class="form-row">
|
||||
<label for="node-input-server"><i class="icon-resize-small"></i> Type</label>
|
||||
<label for="node-input-server"><i class="fa fa-dot-circle-o"></i> Type</label>
|
||||
<select id="node-input-server" style="width:120px; margin-right:5px;">
|
||||
<option value="server">Listen on</option>
|
||||
<option value="client">Connect to</option>
|
||||
@@ -28,7 +28,7 @@
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label><i class="icon-th"></i> Output</label>
|
||||
<label><i class="fa fa-th"></i> Output</label>
|
||||
a
|
||||
<select id="node-input-datamode" style="width:110px;">
|
||||
<option value="stream">stream of</option>
|
||||
@@ -47,11 +47,11 @@
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="node-input-topic"><i class="icon-tasks"></i> Topic</label>
|
||||
<label for="node-input-topic"><i class="fa fa-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>
|
||||
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
</script>
|
||||
@@ -118,7 +118,7 @@
|
||||
|
||||
<script type="text/x-red" data-template-name="tcp out">
|
||||
<div class="form-row">
|
||||
<label for="node-input-beserver"><i class="icon-resize-small"></i> Type</label>
|
||||
<label for="node-input-beserver"><i class="fa fa-dot-circle-o"></i> Type</label>
|
||||
<select id="node-input-beserver" style="width:150px; margin-right:5px;">
|
||||
<option value="server">Listen on</option>
|
||||
<option value="client">Connect to</option>
|
||||
@@ -128,7 +128,13 @@
|
||||
</div>
|
||||
|
||||
<div class="form-row hidden" id="node-input-host-row" style="padding-left: 110px;">
|
||||
at host <input type="text" id="node-input-host" placeholder="localhost" style="width: 40%;">
|
||||
at host <input type="text" id="node-input-host" placeholder="localhost" style="width: 60%;">
|
||||
</div>
|
||||
|
||||
<div class="form-row hidden" id="node-input-end-row">
|
||||
<label> </label>
|
||||
<input type="checkbox" id="node-input-end" style="display: inline-block; width: auto; vertical-align: top;">
|
||||
<label for="node-input-end" style="width: 70%;">Close connection after each message is sent ?</label>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
@@ -138,16 +144,23 @@
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
|
||||
<div class="form-tips hidden" id="fin-tip">
|
||||
<b>Note:</b> Closing the connection after each message is generally not a good thing - but is useful to indicate an end-of-file for example.
|
||||
</div>
|
||||
<div class="form-tips hidden" id="fin-tip2">
|
||||
<b>Note:</b> Closing the connection after each message is generally not a good thing - but is useful to indicate an end-of-file for example. The receiving client will need to reconnect.
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/x-red" data-help-name="tcp out">
|
||||
<p>Provides a choice of tcp outputs. Can either connect to a remote tcp port,
|
||||
accept incoming connections, or reply to messages received from a TCP In node.</p>
|
||||
<p>Only <b>msg.payload</b> is sent.</p>
|
||||
<p>If <b>msg.payload</b> is a string containing a base64 encoding of binary
|
||||
<p>If <b>msg.payload</b> is a string containing a Base64 encoding of binary
|
||||
data, the Base64 decoding option will cause it to be converted back to binary
|
||||
before being sent.</p>
|
||||
</script>
|
||||
@@ -161,6 +174,7 @@
|
||||
port: {value:"",validate:function(v) { return (this.beserver == "reply")||RED.validators.number()(v) } },
|
||||
beserver: {value:"client",required:true},
|
||||
base64: {value:false,required:true},
|
||||
end: {value:false,required:true},
|
||||
name: {value:""}
|
||||
},
|
||||
inputs:1,
|
||||
@@ -179,15 +193,27 @@
|
||||
if (sockettype == "reply") {
|
||||
$("#node-input-port-row").hide();
|
||||
$("#node-input-host-row").hide();
|
||||
$("#node-input-end-row").hide();
|
||||
} else {
|
||||
$("#node-input-port-row").show();
|
||||
$("#node-input-end-row").show();
|
||||
}
|
||||
|
||||
if (sockettype == "client") {
|
||||
$("#node-input-host-row").show();
|
||||
$("#fin-tip").show();
|
||||
} else {
|
||||
$("#node-input-host-row").hide();
|
||||
$("#fin-tip").hide();
|
||||
}
|
||||
|
||||
if (sockettype == "server") {
|
||||
$("#fin-tip2").show();
|
||||
}
|
||||
else {
|
||||
$("#fin-tip2").hide();
|
||||
}
|
||||
|
||||
};
|
||||
updateOptions();
|
||||
$("#node-input-beserver").change(updateOptions);
|
||||
@@ -208,12 +234,13 @@
|
||||
<option value="time">after a fixed timeout of</option>
|
||||
<option value="char">when character received is</option>
|
||||
<option value="count">a fixed number of characters</option>
|
||||
<option value="sit">never. Keep connection open</option>
|
||||
</select>
|
||||
<input type="text" id="node-input-splitc" style="width:50px;">
|
||||
<span id="node-units"></span>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
<div class="form-tips"><b>Tip:</b> outputs a binary <b>Buffer</b>, so you may want to .toString() it.</div>
|
||||
@@ -229,18 +256,22 @@
|
||||
if (previous != "time") $("#node-input-splitc").val("0");
|
||||
$("#node-units").text("ms");
|
||||
}
|
||||
else {
|
||||
else if ($("#node-input-out").val() == "count") {
|
||||
if (previous != "count") $("#node-input-splitc").val("12");
|
||||
$("#node-units").text("chars");
|
||||
}
|
||||
else {
|
||||
if (previous != "sit") $("#node-input-splitc").val("0");
|
||||
$("#node-units").text("");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<script type="text/x-red" data-help-name="tcp request">
|
||||
<p>A simple TCP request node - sends the <b>msg.payload</b> to a server tcp port and expects a response.</p>
|
||||
<p>Connects, sends the "request", reads the "response" and disconnects. It can either count a number of
|
||||
<p>Connects, sends the "request", reads the "response". It can either count a number of
|
||||
returned characters into a fixed buffer, match a specified character before returning,
|
||||
or wait a fixed timeout from first reply and then return.</p>
|
||||
wait a fixed timeout from first reply and then return, or just sit and wait for data.</p>
|
||||
<p>The response will be output in <b>msg.payload</b> as a buffer, so you may want to .toString() it.</p>
|
||||
</script>
|
||||
|
||||
|
Reference in New Issue
Block a user