aboutsummaryrefslogtreecommitdiff
path: root/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'index.html')
-rw-r--r--index.html13
1 files changed, 10 insertions, 3 deletions
diff --git a/index.html b/index.html
index 8a9ae9c..845744b 100644
--- a/index.html
+++ b/index.html
@@ -4,13 +4,20 @@
var webSocket = null;
function openSocket(){
- webSocket = new WebSocket("ws://localhost:8001/foo/bar");
- webSocket.onclose = openSocket;
+ setTimeout(function(){
+ webSocket = new WebSocket("ws://localhost:8001/foo/bar");
+ webSocket.onclose = openSocket;
+ webSocket.onmessage = function(event){
+ console.log(event.data);
+ };
+ }, 1000);
}
function init(){
openSocket();
- setInterval(function(){webSocket.send("foo");}, 1000);
+ setInterval(function(){
+ webSocket.send("foo");
+ }, 1000);
}
</script>
</head>