1 <script type=
"text/javascript">
2 function connectWebsocket() {
3 console.log(
"Attempting to create websocket connection for radio status sync")
4 const cookieValue = document.cookie
6 .find((row) =
> row.startsWith(
"broadcast_session="))
8 const socket = new WebSocket(
"/web-ws");
9 socket.addEventListener(
"open", (event) =
> {
10 socket.send(cookieValue);
12 socket.addEventListener(
"message", (event) =
> {
13 console.log(
"Received a status update from server")
14 const connected = document.getElementById('connected-radios');
15 connected.innerHTML = event.data;
17 socket.addEventListener(
"close", (event) =
> {
18 console.log(
"Websocket closed. Will retry in 10 seconds.")
19 setTimeout(connectWebsocket,
10000);
22 // initial connection on page load
25 <h1>Connected Radios
</h1>
26 <div id=
"connected-radios">