From 5ccae10d9415e3dc31aa41e5f43a8833b4ed72dd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andrej=20Rama=C5=A1euski?= <andrej@x2.cz>
Date: Thu, 3 Dec 2020 19:50:26 +0100
Subject: [PATCH] Websocket misto refresh

---
 templates/live.html.ep | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/templates/live.html.ep b/templates/live.html.ep
index d090b35..4336d8e 100644
--- a/templates/live.html.ep
+++ b/templates/live.html.ep
@@ -58,11 +58,11 @@ function rowStyle(row, index) {
     }
 }
 
-setInterval(
-    function() {
-        $('#Streams').bootstrapTable('refresh', {silent: true})
-    },
-    5000
-);
+var ws = new WebSocket('<%= $c->config->{ws_url} %>');
+
+ws.onmessage = function (event) {
+  console.log(event.data);
+  $('#Streams').bootstrapTable('refresh', {silent: true})
+};
 
 </script>
-- 
GitLab