aboutsummaryrefslogtreecommitdiff
path: root/web/client.html
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-06-30 19:13:59 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2023-06-30 19:13:59 +0200
commitdb21d2ec6980e31a2e9a0db60eb2fdad83b33671 (patch)
treef1c963ccb419b2d7ddff6cfe1a66aec1fb365c8b /web/client.html
parent6c81e0dcaf5905c6fac3fe4b62dffaf67027d785 (diff)
downloadWRMS-db21d2ec6980e31a2e9a0db60eb2fdad83b33671.tar.gz
WRMS-db21d2ec6980e31a2e9a0db60eb2fdad83b33671.zip
switch from websockets to SSE
Diffstat (limited to 'web/client.html')
-rw-r--r--web/client.html20
1 files changed, 3 insertions, 17 deletions
diff --git a/web/client.html b/web/client.html
index 41e224f..a95bbb7 100644
--- a/web/client.html
+++ b/web/client.html
@@ -225,20 +225,10 @@
playing.appendChild(songLabel);
}
- let socket_url = "ws://"+location.hostname + (location.port ? ":" + location.port: "") + "/ws";
- let socket = new WebSocket(socket_url);
- console.log("Attempting Connection...");
+ let events = new EventSource("/events");
- socket.onopen = () => {
- console.log("Successfully Connected");
- };
-
- socket.onclose = event => {
- console.log("Socket Closed Connection: ", event);
- };
-
- socket.onmessage = message => {
- console.log("Socket Received Message: ", message);
+ events.onmessage = message => {
+ console.log("Received Event: ", message);
const cmd = JSON.parse(message.data);
switch (cmd.cmd) {
case "add":
@@ -277,10 +267,6 @@
}
};
- socket.onerror = error => {
- console.log("Socket Error: ", error);
- };
-
function submitSearch() {
resetSearch();