Buzzer/src/main/resources/js/adminClient.js

22 lines
532 B
JavaScript

'use strict';
let adminSocket;
$.when($.ready).then(function () {
let protocolPrefix = (window.location.protocol === 'https:') ? 'wss:' : 'ws:';
adminSocket = new WebSocket(`${protocolPrefix}//${location.host}/socket/master`);
adminSocket.addEventListener('message', (ev) => {
console.log(`Received: ${ev.data}`)
appendUsername(ev.data)
});
});
function appendUsername(username) {
$('ol#usernames').append(`<li>${username}</li>`)
}
function resetReceived() {
$('ol#usernames').empty()
}