From 49ce320f17729a0cf0df0bd1322639ddf55e2402 Mon Sep 17 00:00:00 2001 From: cbdev Date: Sat, 18 May 2019 19:20:21 +0200 Subject: Basic websocket framing --- index.html | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'index.html') 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); } -- cgit v1.2.3