diff options
author | cbdev <cb@cbcdn.com> | 2019-05-18 19:20:21 +0200 |
---|---|---|
committer | cbdev <cb@cbcdn.com> | 2019-05-18 19:20:21 +0200 |
commit | 49ce320f17729a0cf0df0bd1322639ddf55e2402 (patch) | |
tree | ab378ab9e21ff1d514e5264a219a39b6d72c75fc /index.html | |
parent | ff94e4518d417d88f2fabdfca7025e68ce21849b (diff) | |
download | websocksy-49ce320f17729a0cf0df0bd1322639ddf55e2402.tar.gz websocksy-49ce320f17729a0cf0df0bd1322639ddf55e2402.tar.bz2 websocksy-49ce320f17729a0cf0df0bd1322639ddf55e2402.zip |
Basic websocket framing
Diffstat (limited to 'index.html')
-rw-r--r-- | index.html | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -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> |