Add ws_test.html for websocket testing
This commit is contained in:
parent
74a79ef3cc
commit
40dc13f0bd
|
@ -0,0 +1,23 @@
|
|||
<!DOCTYPE html>
|
||||
<pre id="log"></pre>
|
||||
<script>
|
||||
// helper function: log message to screen
|
||||
function log(msg) {
|
||||
document.getElementById('log').textContent += msg + '\n';
|
||||
}
|
||||
|
||||
// setup websocket with callbacks
|
||||
var ws = new WebSocket("ws://127.0.0.1:8848/chat");
|
||||
ws.onopen = function() {
|
||||
log('CONNECT');
|
||||
ws.send("hello!!!");
|
||||
};
|
||||
ws.onclose = function() {
|
||||
log('DISCONNECT');
|
||||
};
|
||||
ws.onmessage = function(event) {
|
||||
log('MESSAGE: ' + event.data);
|
||||
ws.send(event.data);
|
||||
ws.send(event.data);
|
||||
};
|
||||
</script>
|
Loading…
Reference in New Issue