blob: 59ad43f37d0ed333b18815a8efb6fa07c1c8f611 [file] [log] [blame]
Andy Green775c0dd2010-10-29 14:15:22 +01001<!DOCTYPE html>
2<html lang="en">
3<head>
4 <meta charset=utf-8 />
5 <title>Minimal Websocket message sender</title>
6</head>
7
8<body>
9<script>
10 var pos = 0;
11
12 var socket = new WebSocket("ws://127.0.0.1:7681");
13
14 try {
15// alert('<p class="event">Socket Status: '+socket.readyState);
16
17 socket.onopen = function(){
Andy Green4ea60062010-10-30 12:15:07 +010018 // alert('<p class="event">Socket Status: '+socket.readyState+' (open)');
Andy Green775c0dd2010-10-29 14:15:22 +010019 }
20
21 socket.onmessage = got_packet;
22
23 socket.onclose = function(){
24 alert('<p class="event">Socket Status: (Closed)');
25 }
26 } catch(exception){
27 alert('<p>Error'+exception);
28 }
29
30function got_packet(msg){
Andy Green775c0dd2010-10-29 14:15:22 +010031
Andy Green4ea60062010-10-30 12:15:07 +010032// alert('got packet' + msg.data);
Andy Green775c0dd2010-10-29 14:15:22 +010033 document.write(msg.data + "\n");
34
35}
36</script>
37
38</body>
39</html>