--- /dev/null
+<!--\r
+ Copyright 2013 IBM Corp.\r
+\r
+ Licensed under the Apache License, Version 2.0 (the "License");\r
+ you may not use this file except in compliance with the License.\r
+ You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+-->\r
+\r
+<!-- WebSocket Input Node -->\r
+<script type="text/x-red" data-template-name="websocket in">\r
+ <div class="form-row">\r
+ <label for="node-input-server"><i class="fa fa-bookmark"></i> Path</label>\r
+ <input type="text" id="node-input-server">\r
+ </div>\r
+ <div class="form-row">\r
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>\r
+ <input type="text" id="node-input-name" placeholder="Name">\r
+ </div>\r
+</script>\r
+\r
+<script type="text/x-red" data-help-name="websocket in">\r
+ <p>WebSocket input node.</p>\r
+ <p>By default, the data received from the WebSocket will be in <b>msg.payload</b>.\r
+ The listener can be configured to expect a properly formed JSON string, in which\r
+ case it will parse the JSON and send on the resulting object as the entire message.</p>\r
+</script>\r
+\r
+<script type="text/javascript">\r
+ RED.nodes.registerType('websocket in',{\r
+ category: 'input',\r
+ defaults: {\r
+ name: {value:""},\r
+ server: {type:"websocket-listener"}\r
+ },\r
+ color:"rgb(215, 215, 160)",\r
+ inputs:0,\r
+ outputs:1,\r
+ icon: "white-globe.png",\r
+ label: function() {\r
+ var wsNode = RED.nodes.node(this.server);\r
+ return this.name||(wsNode?"[ws] "+wsNode.label():"websocket");\r
+ },\r
+ labelStyle: function() {\r
+ return this.name?"node_label_italic":"";\r
+ }\r
+ });\r
+</script>\r
+\r
+<!-- WebSocket out Node -->\r
+<script type="text/x-red" data-template-name="websocket out">\r
+ <div class="form-row">\r
+ <label for="node-input-server"><i class="fa fa-bookmark"></i> Path</label>\r
+ <input type="text" id="node-input-server">\r
+ </div>\r
+ <div class="form-row">\r
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>\r
+ <input type="text" id="node-input-name" placeholder="Name">\r
+ </div>\r
+</script>\r
+\r
+<script type="text/x-red" data-help-name="websocket out">\r
+ <p>WebSocket out node.</p>\r
+ <p>By default, <b>msg.payload</b> will be sent over the WebSocket. The listener\r
+ can be configured to encode the entire message object as a JSON string and send that\r
+ over the WebSocket.</p>\r
+\r
+ <p>If the message arriving at this node started at a WebSocket In node, the message\r
+ will be sent back to the client that triggered the flow. Otherwise, the message\r
+ will be broadcast to all connected clients.</p>\r
+ <p>If you want to broadcast a message that started at a WebSocket In node, you\r
+ should delete the <b>msg._session</b> property within the flow</p>.\r
+</script>\r
+\r
+<script type="text/javascript">\r
+ RED.nodes.registerType('websocket out',{\r
+ category: 'output',\r
+ defaults: {\r
+ name: {value:""},\r
+ server: {type:"websocket-listener", required:true}\r
+ },\r
+ color:"rgb(215, 215, 160)",\r
+ inputs:1,\r
+ outputs:0,\r
+ icon: "white-globe.png",\r
+ align: "right",\r
+ label: function() {\r
+ var wsNode = RED.nodes.node(this.server);\r
+ return this.name||(wsNode?"[ws] "+wsNode.label():"websocket");\r
+ },\r
+ labelStyle: function() {\r
+ return this.name?"node_label_italic":"";\r
+ }\r
+ });\r
+</script>\r
+\r
+<!-- WebSocket Server configuration node -->\r
+<script type="text/x-red" data-template-name="websocket-listener">\r
+ <div class="form-row">\r
+ <label for="node-config-input-path"><i class="fa fa-bookmark"></i> Path</label>\r
+ <input type="text" id="node-config-input-path" placeholder="/ws/example">\r
+ </div>\r
+ <div class="form-row">\r
+ <label for="node-config-input-wholemsg"> </label>\r
+ <select type="text" id="node-config-input-wholemsg" style="width: 70%;">\r
+ <option value="false">Send/Receive payload</option>\r
+ <option value="true">Send/Receive entire message</option>\r
+ </select>\r
+ </div>\r
+ <div class="form-tips">\r
+ Be default, <code>payload</code> will contain the data to be sent over, or received from a websocket.\r
+ The listener can be configured to send or receive the entire message object as a JSON formatted string.\r
+ <p id="node-config-ws-tip">This path will be relative to <code><span id="node-config-ws-path"></span></code>.</p>\r
+ </div>\r
+</script>\r
+\r
+<script type="text/x-red" data-help-name="websocket-listener">\r
+ <p>This configuration node creates a WebSocket Server using the specified path</p>\r
+</script>\r
+\r
+<script type="text/javascript">\r
+ RED.nodes.registerType('websocket-listener',{\r
+ category: 'config',\r
+ defaults: {\r
+ path: {value:"",required:true,validate:RED.validators.regex(/^((?!\/debug\/ws).)*$/) },\r
+ wholemsg: {value:"false"}\r
+ },\r
+ inputs:0,\r
+ outputs:0,\r
+ label: function() {\r
+ var root = RED.settings.httpNodeRoot;\r
+ if (root.slice(-1) != "/") { \r
+ root = root+"/";\r
+ }\r
+ if (this.path.charAt(0) == "/") {\r
+ root += this.path.slice(1);\r
+ } else {\r
+ root += this.path;\r
+ }\r
+ return root;\r
+ },\r
+ oneditprepare: function() {\r
+ var root = RED.settings.httpNodeRoot;\r
+ if (root.slice(-1) == "/") { \r
+ root = root.slice(0,-1);\r
+ }\r
+ if (root == "") {\r
+ $("#node-config-ws-tip").hide();\r
+ } else {\r
+ $("#node-config-ws-path").html(root);\r
+ $("#node-config-ws-tip").show();\r
+ }\r
+ //document.getElementById("node-config-wsdocpath").innerHTML=\r
+ }\r
+ });\r
+</script>\r