| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 | 2 |
| 3 <html lang="en"> | 3 <html lang="en"> |
| 4 <head> | 4 <head> |
| 5 <meta charset="utf-8" /> | 5 <meta charset="utf-8" /> |
| 6 <title>Spy WS test</title> | 6 <title>Spy WS test</title> |
| 7 <style> | 7 <style> |
| 8 hr {color:sienna;} | 8 hr {color:sienna;} |
| 9 body { | 9 body { |
| 10 background-color:#b0c4de; | 10 background-color:#b0c4de; |
| 11 font:normal 16px/20px "Helvetica Neue", Helvetica, sans-serif; | 11 font:normal 16px/20px "Helvetica Neue", Helvetica, sans-serif; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 29 <p id="log">...</p> | 29 <p id="log">...</p> |
| 30 <script> | 30 <script> |
| 31 function openConnection() { | 31 function openConnection() { |
| 32 if (conn.readyState === undefined || conn.readyState > 1) { | 32 if (conn.readyState === undefined || conn.readyState > 1) { |
| 33 conn = new WebSocket('ws://127.0.0.1:42424'); | 33 conn = new WebSocket('ws://127.0.0.1:42424'); |
| 34 conn.onopen = function () { | 34 conn.onopen = function () { |
| 35 state.innerHTML = 'connected @port 42424'; | 35 state.innerHTML = 'connected @port 42424'; |
| 36 }; | 36 }; |
| 37 conn.onmessage = function (event) { | 37 conn.onmessage = function (event) { |
| 38 var message = event.data; | 38 var message = event.data; |
| 39 log.innerHTML = message; | 39 log.innerHTML += "<br/>" + message; |
| 40 }; | 40 }; |
| 41 conn.onclose = function (event) { | 41 conn.onclose = function (event) { |
| 42 state.innerHTML = 'connection closed'; | 42 state.innerHTML = 'connection closed'; |
| 43 }; | 43 }; |
| 44 conn.onerror = function (event) { | 44 conn.onerror = function (event) { |
| 45 state.innerHTML = 'got error'; | 45 state.innerHTML = 'got error'; |
| 46 }; | 46 }; |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 | 49 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 log.innerHTML = 'data sent'; | 87 log.innerHTML = 'data sent'; |
| 88 cmd.value = ''; | 88 cmd.value = ''; |
| 89 } | 89 } |
| 90 }); | 90 }); |
| 91 | 91 |
| 92 openConnection(); | 92 openConnection(); |
| 93 } | 93 } |
| 94 </script> | 94 </script> |
| 95 </body> | 95 </body> |
| 96 </html> | 96 </html> |
| OLD | NEW |