javascript_client_example.html 414 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>WebSocket Test</title>
</head>
<body>
<script>
var ws;
window.onload=function(){
  ws=new WebSocket("ws://localhost:8080/echo");
  ws.onmessage=function(evt){console.log(evt.data);};
  ws.onopen=function(evt){
    ws.send("Hello");
  }
}
window.onclose=function(){
  ws.close();
}
</script>
</body>
</html>