2 Copyright 2013 IBM Corp.
\r
4 Licensed under the Apache License, Version 2.0 (the "License");
\r
5 you may not use this file except in compliance with the License.
\r
6 You may obtain a copy of the License at
\r
8 http://www.apache.org/licenses/LICENSE-2.0
\r
10 Unless required by applicable law or agreed to in writing, software
\r
11 distributed under the License is distributed on an "AS IS" BASIS,
\r
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 See the License for the specific language governing permissions and
\r
14 limitations under the License.
\r
17 <!-- WebSocket Input Node -->
\r
18 <script type="text/x-red" data-template-name="websocket in">
\r
19 <div class="form-row">
\r
20 <label for="node-input-server"><i class="fa fa-bookmark"></i> Path</label>
\r
21 <input type="text" id="node-input-server">
\r
23 <div class="form-row">
\r
24 <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
\r
25 <input type="text" id="node-input-name" placeholder="Name">
\r
29 <script type="text/x-red" data-help-name="websocket in">
\r
30 <p>WebSocket input node.</p>
\r
31 <p>By default, the data received from the WebSocket will be in <b>msg.payload</b>.
\r
32 The listener can be configured to expect a properly formed JSON string, in which
\r
33 case it will parse the JSON and send on the resulting object as the entire message.</p>
\r
36 <script type="text/javascript">
\r
37 RED.nodes.registerType('websocket in',{
\r
41 server: {type:"websocket-listener"}
\r
43 color:"rgb(215, 215, 160)",
\r
46 icon: "white-globe.png",
\r
48 var wsNode = RED.nodes.node(this.server);
\r
49 return this.name||(wsNode?"[ws] "+wsNode.label():"websocket");
\r
51 labelStyle: function() {
\r
52 return this.name?"node_label_italic":"";
\r
57 <!-- WebSocket out Node -->
\r
58 <script type="text/x-red" data-template-name="websocket out">
\r
59 <div class="form-row">
\r
60 <label for="node-input-server"><i class="fa fa-bookmark"></i> Path</label>
\r
61 <input type="text" id="node-input-server">
\r
63 <div class="form-row">
\r
64 <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
\r
65 <input type="text" id="node-input-name" placeholder="Name">
\r
69 <script type="text/x-red" data-help-name="websocket out">
\r
70 <p>WebSocket out node.</p>
\r
71 <p>By default, <b>msg.payload</b> will be sent over the WebSocket. The listener
\r
72 can be configured to encode the entire message object as a JSON string and send that
\r
73 over the WebSocket.</p>
\r
75 <p>If the message arriving at this node started at a WebSocket In node, the message
\r
76 will be sent back to the client that triggered the flow. Otherwise, the message
\r
77 will be broadcast to all connected clients.</p>
\r
78 <p>If you want to broadcast a message that started at a WebSocket In node, you
\r
79 should delete the <b>msg._session</b> property within the flow</p>.
\r
82 <script type="text/javascript">
\r
83 RED.nodes.registerType('websocket out',{
\r
87 server: {type:"websocket-listener", required:true}
\r
89 color:"rgb(215, 215, 160)",
\r
92 icon: "white-globe.png",
\r
95 var wsNode = RED.nodes.node(this.server);
\r
96 return this.name||(wsNode?"[ws] "+wsNode.label():"websocket");
\r
98 labelStyle: function() {
\r
99 return this.name?"node_label_italic":"";
\r
104 <!-- WebSocket Server configuration node -->
\r
105 <script type="text/x-red" data-template-name="websocket-listener">
\r
106 <div class="form-row">
\r
107 <label for="node-config-input-path"><i class="fa fa-bookmark"></i> Path</label>
\r
108 <input type="text" id="node-config-input-path" placeholder="/ws/example">
\r
110 <div class="form-row">
\r
111 <label for="node-config-input-wholemsg"> </label>
\r
112 <select type="text" id="node-config-input-wholemsg" style="width: 70%;">
\r
113 <option value="false">Send/Receive payload</option>
\r
114 <option value="true">Send/Receive entire message</option>
\r
117 <div class="form-tips">
\r
118 Be default, <code>payload</code> will contain the data to be sent over, or received from a websocket.
\r
119 The listener can be configured to send or receive the entire message object as a JSON formatted string.
\r
120 <p id="node-config-ws-tip">This path will be relative to <code><span id="node-config-ws-path"></span></code>.</p>
\r
124 <script type="text/x-red" data-help-name="websocket-listener">
\r
125 <p>This configuration node creates a WebSocket Server using the specified path</p>
\r
128 <script type="text/javascript">
\r
129 RED.nodes.registerType('websocket-listener',{
\r
130 category: 'config',
\r
132 path: {value:"",required:true,validate:RED.validators.regex(/^((?!\/debug\/ws).)*$/) },
\r
133 wholemsg: {value:"false"}
\r
137 label: function() {
\r
138 var root = RED.settings.httpNodeRoot;
\r
139 if (root.slice(-1) != "/") {
\r
142 if (this.path.charAt(0) == "/") {
\r
143 root += this.path.slice(1);
\r
149 oneditprepare: function() {
\r
150 var root = RED.settings.httpNodeRoot;
\r
151 if (root.slice(-1) == "/") {
\r
152 root = root.slice(0,-1);
\r
155 $("#node-config-ws-tip").hide();
\r
157 $("#node-config-ws-path").html(root);
\r
158 $("#node-config-ws-tip").show();
\r
160 //document.getElementById("node-config-wsdocpath").innerHTML=
\r