test.html
raw| 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <body> |
| 4 | <script type="text/javascript"> |
| 5 | var ws = new WebSocket("ws://localhost:9090"); |
| 6 | console.log("initialized websocket"); |
| 7 | ws.onmessage = function(evt) { |
| 8 | console.log("received message"); |
| 9 | console.log(evt.data); |
| 10 | }; |
| 11 | ws.onopen = function() { |
| 12 | console.log("connected"); |
| 13 | ws.send("Hello, there!"); |
| 14 | } |
| 15 | ws.onclose = function() { |
| 16 | console.log("closed websocket"); |
| 17 | } |
| 18 | </script> |
| 19 | </body> |
| 20 | </html> |