webpnp/static/renderer.js
2020-04-17 02:25:12 +02:00

17 lines
525 B
JavaScript

const ws_url = new URL('ws', window.location.href);
ws_url.protocol = ws_url.protocol.replace('http', 'ws');
const ws = new WebSocket(ws_url.href);
ws.onmessage = function(event) {
const msg = JSON.parse(event.data);
console.log(msg);
if (msg.hasOwnProperty('currentsession')) {
document.getElementById('current_session').innerText = msg.currentsession;
}
if (msg.hasOwnProperty('allsessions')) {
document.getElementById('all_sessions').innerText = msg.allsessions.join(', ');
}
};