enebularでnode-red その11

# 概要
enebularでnode-redやってみる。
練習問題やってみた。

# 練習問題
http getが来たら、websocketに流れるデータを返せ。

# フロー

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/18104/e10d0f66-3cdc-d0cf-2d8d-58544e5dbbc4.png)


```
[{"id":"a3cc8311.624988","type":"websocket in","z":"51e5f3dfc3ba1f13","name":"","server":"862118c716ba3fa6","client":"","x":160,"y":80,"wires":[["54493aa8.591264"]]},{"id":"54493aa8.591264","type":"function","z":"51e5f3dfc3ba1f13","name":"","func":"delete msg._session;\n\nvar flowContext = context.flow;\nflowContext.set('pub', msg.payload);\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":80,"wires":[["bd61bb46.61a2d8","8b1b936ba9496384"]]},{"id":"bd61bb46.61a2d8","type":"websocket out","z":"51e5f3dfc3ba1f13","name":"","server":"862118c716ba3fa6","client":"","x":540,"y":100,"wires":[]},{"id":"940713f0.af888","type":"http in","z":"51e5f3dfc3ba1f13","name":"","url":"/chat","method":"get","upload":false,"swaggerDoc":"","x":180,"y":220,"wires":[["930606f8.e42ed8"]]},{"id":"930606f8.e42ed8","type":"template","z":"51e5f3dfc3ba1f13","name":"chat html","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<!doctype html>\n<html>\n\t<head>\n\t</head>\n\t<body>\n\t<h1>chat</h1>\n\t<form name=\"publish\">\n\t\t<input type=\"text\" name=\"message\" maxlength=\"50\"/>\n\t\t<input type=\"submit\" value=\"Send\"/>\n\t</form>\n\t<div id=\"messages\"></div>\n\t<script>\nlet url = 'wss://{{req.headers.host}}/pub';\nlet socket = new WebSocket(url);\ndocument.forms.publish.onsubmit = function() {\n\tlet outgoingMessage = this.message.value;\n\tsocket.send(outgoingMessage);\n\tthis.message.value = '';\n\treturn false;\n};\nsocket.onmessage = function(event) {\n\tlet incomingMessage = event.data;\n\tshowMessage(incomingMessage);\n};\nsocket.onclose = event => alert(`Closed ${event.code}`);\nsocket.onopen = event => alert(`open`);\nsocket.onerror = event => alert(`err`);\nfunction showMessage(message) {\n\tlet messageElem = document.createElement('div');\n\tmessageElem.textContent = message;\n\tdocument.getElementById('messages').appendChild(messageElem);\n}\nshowMessage(\"incomingMessage\");\n</script>\n\t</body>\n</html>\n\n","x":360,"y":220,"wires":[["6074165e.fc8278"]]},{"id":"6074165e.fc8278","type":"http response","z":"51e5f3dfc3ba1f13","name":"","x":530,"y":220,"wires":[]},{"id":"8b1b936ba9496384","type":"debug","z":"51e5f3dfc3ba1f13","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":570,"y":40,"wires":[]},{"id":"221232ab34a7cdbf","type":"http in","z":"51e5f3dfc3ba1f13","name":"","url":"/pub","method":"get","upload":false,"swaggerDoc":"","x":180,"y":160,"wires":[["a4c1fe51833010ef"]]},{"id":"d1698459e9ebfe9c","type":"http response","z":"51e5f3dfc3ba1f13","name":"","statusCode":"","headers":{},"x":530,"y":160,"wires":[]},{"id":"a4c1fe51833010ef","type":"function","z":"51e5f3dfc3ba1f13","name":"","func":"var flowContext = context.flow;\nmsg.payload = flowContext.get('pub');\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":160,"wires":[["d1698459e9ebfe9c"]]},{"id":"862118c716ba3fa6","type":"websocket-listener","path":"/pub","wholemsg":"false"}]
```



以上。