diff --git a/amadeus/routing.py b/amadeus/routing.py
index 4512d74..9b8f5c2 100644
--- a/amadeus/routing.py
+++ b/amadeus/routing.py
@@ -1,6 +1,7 @@
from channels.routing import route
-from mural.consumers import ws_message
+from mural.consumers import ws_add, ws_message
channel_routing = [
+ route("websocket.connect", ws_add),
route("websocket.receive", ws_message),
]
\ No newline at end of file
diff --git a/amadeus/settings.py b/amadeus/settings.py
index 0167493..33b1493 100644
--- a/amadeus/settings.py
+++ b/amadeus/settings.py
@@ -54,7 +54,7 @@ INSTALLED_APPS = [
'session_security',
'django_crontab',
'django_cron',
- #'channels',
+ 'channels',
'amadeus',
'users',
diff --git a/amadeus/static/js/socket.js b/amadeus/static/js/socket.js
new file mode 100644
index 0000000..9395c7c
--- /dev/null
+++ b/amadeus/static/js/socket.js
@@ -0,0 +1,37 @@
+socket = new WebSocket("ws://" + window.location.host + "/");
+
+socket.onmessage = function(e) {
+ content = JSON.parse(e.data);
+
+ if (content.type == "mural") {
+ if (window.location.pathname == content.pathname) {
+ $('.posts').prepend(content.complete);
+
+ $('.no-subjects').attr('style', 'display:none');
+ }
+
+ if (("Notification" in window)) {
+ var options = {
+ icon: content.user_icon,
+ body: content.simple
+ }
+
+ if (Notification.permission === "granted") {
+ var notification = new Notification("", options);
+
+ setTimeout(notification.close.bind(notification), 3000);
+ } else if (Notification.permission !== 'denied') {
+ Notification.requestPermission(function (permission) {
+ // If the user accepts, let's create a notification
+ if (permission === "granted") {
+ var notification = new Notification("", options);
+
+ setTimeout(notification.close.bind(notification), 3000);
+ }
+ });
+ }
+ }
+ }
+}
+// Call onopen directly if socket is already open
+if (socket.readyState == WebSocket.OPEN) socket.onopen();
\ No newline at end of file
diff --git a/amadeus/templates/base.html b/amadeus/templates/base.html
index adb84e2..039dcdf 100644
--- a/amadeus/templates/base.html
+++ b/amadeus/templates/base.html
@@ -260,6 +260,7 @@
+