|
@@ -14,11 +14,14 @@ function get_url()
|
|
|
function do_websocket()
|
|
|
{
|
|
|
const socket = new WebSocket(get_url());
|
|
|
- socket.addEventListener('message', function(evt) {
|
|
|
- console.log('received', evt.data)
|
|
|
+ socket.onmessage = function(evt) {
|
|
|
var msg = JSON.parse(evt.data)
|
|
|
counter = document.getElementsByTagName('text')[0];
|
|
|
counter.textContent = msg.value.toString()
|
|
|
- })
|
|
|
+ }
|
|
|
+ socket.onclose = function() {
|
|
|
+ setTimeout(do_websocket, 3000)
|
|
|
+ }
|
|
|
+ socket.onerror = socket.onclose
|
|
|
}
|
|
|
do_websocket()
|