Show More
@@ -20,4 +20,4 b' ARCHIVE_THREADS = True' | |||
|
20 | 20 | # Limit posting speed |
|
21 | 21 | LIMIT_POSTING_SPEED = False |
|
22 | 22 | # Thread update |
|
23 |
WEBSOCKETS_ENABLED = |
|
|
23 | WEBSOCKETS_ENABLED = False |
@@ -50,36 +50,39 b' function connectWebsocket() {' | |||
|
50 | 50 | var wsHost = metapanel.getAttribute('data-ws-host'); |
|
51 | 51 | var wsPort = metapanel.getAttribute('data-ws-port'); |
|
52 | 52 | |
|
53 | if (wsHost.length > 0 && wsPort.length > 0) | |
|
54 | var centrifuge = new Centrifuge({ | |
|
55 | "url": 'ws://' + wsHost + ':' + wsPort + "/connection/websocket", | |
|
56 | "project": metapanel.getAttribute('data-ws-project'), | |
|
57 | "user": wsUser, | |
|
58 | "timestamp": metapanel.getAttribute('data-ws-token-time'), | |
|
59 | "token": metapanel.getAttribute('data-ws-token'), | |
|
60 | "debug": false | |
|
61 | }); | |
|
53 | if (wsHost.length > 0 && wsPort.length > 0) { | |
|
54 | var centrifuge = new Centrifuge({ | |
|
55 | "url": 'ws://' + wsHost + ':' + wsPort + "/connection/websocket", | |
|
56 | "project": metapanel.getAttribute('data-ws-project'), | |
|
57 | "user": wsUser, | |
|
58 | "timestamp": metapanel.getAttribute('data-ws-token-time'), | |
|
59 | "token": metapanel.getAttribute('data-ws-token'), | |
|
60 | "debug": false | |
|
61 | }); | |
|
62 | 62 | |
|
63 | centrifuge.on('error', function(error_message) { | |
|
64 | console.log("Error connecting to websocket server."); | |
|
65 | console.log(error_message); | |
|
66 | return false; | |
|
67 | }); | |
|
68 | ||
|
69 | centrifuge.on('connect', function() { | |
|
70 | var channelName = 'thread:' + threadId; | |
|
71 | centrifuge.subscribe(channelName, function(message) { | |
|
72 | getThreadDiff(); | |
|
63 | centrifuge.on('error', function(error_message) { | |
|
64 | console.log("Error connecting to websocket server."); | |
|
65 | console.log(error_message); | |
|
66 | return false; | |
|
73 | 67 | }); |
|
74 | 68 | |
|
75 | // For the case we closed the browser and missed some updates | |
|
76 | getThreadDiff(); | |
|
77 | $('#autoupdate').hide(); | |
|
78 | }); | |
|
69 | centrifuge.on('connect', function() { | |
|
70 | var channelName = 'thread:' + threadId; | |
|
71 | centrifuge.subscribe(channelName, function(message) { | |
|
72 | getThreadDiff(); | |
|
73 | }); | |
|
79 | 74 | |
|
80 | centrifuge.connect(); | |
|
75 | // For the case we closed the browser and missed some updates | |
|
76 | getThreadDiff(); | |
|
77 | $('#autoupdate').hide(); | |
|
78 | }); | |
|
81 | 79 | |
|
82 | return true; | |
|
80 | centrifuge.connect(); | |
|
81 | ||
|
82 | return true; | |
|
83 | } else { | |
|
84 | return false; | |
|
85 | } | |
|
83 | 86 | } |
|
84 | 87 | |
|
85 | 88 | /** |
@@ -204,7 +207,11 b' function initAutoupdate() {' | |||
|
204 | 207 | if (location.protocol === 'https:') { |
|
205 | 208 | return enableJsUpdate(); |
|
206 | 209 | } else { |
|
207 |
|
|
|
210 | if (connectWebsocket()) { | |
|
211 | return true; | |
|
212 | } else { | |
|
213 | return enableJsUpdate(); | |
|
214 | } | |
|
208 | 215 | } |
|
209 | 216 | } |
|
210 | 217 |
General Comments 0
You need to be logged in to leave comments.
Login now