aboutsummaryrefslogtreecommitdiffstats
path: root/view/js/sse_worker.js
diff options
context:
space:
mode:
Diffstat (limited to 'view/js/sse_worker.js')
-rwxr-xr-xview/js/sse_worker.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/view/js/sse_worker.js b/view/js/sse_worker.js
new file mode 100755
index 000000000..78e4aa51b
--- /dev/null
+++ b/view/js/sse_worker.js
@@ -0,0 +1,14 @@
+var evtSource = new EventSource('/sse');
+
+onconnect = function(e) {
+
+ var port = e.ports[0];
+
+ port.start();
+
+ evtSource.addEventListener('notifications', function(e) {
+ var obj = JSON.parse(e.data);
+ port.postMessage(obj);
+ }, false);
+
+}