parent
1b78cd9fee
commit
dcea0ce37d
1 changed files with 6 additions and 3 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue