webpnp/static/renderer.js
2020-04-17 02:18:24 +02:00

13 lines
371 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('session')) {
document.getElementById('current_session').innerText = msg.session;
}
};