13 lines
371 B
JavaScript
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;
|
|
}
|
|
}; |