Show More
@@ -20,4 +20,4 b' ARCHIVE_THREADS = True' | |||||
20 | # Limit posting speed |
|
20 | # Limit posting speed | |
21 | LIMIT_POSTING_SPEED = False |
|
21 | LIMIT_POSTING_SPEED = False | |
22 | # Thread update |
|
22 | # Thread update | |
23 |
WEBSOCKETS_ENABLED = |
|
23 | WEBSOCKETS_ENABLED = False |
@@ -50,36 +50,39 b' function connectWebsocket() {' | |||||
50 | var wsHost = metapanel.getAttribute('data-ws-host'); |
|
50 | var wsHost = metapanel.getAttribute('data-ws-host'); | |
51 | var wsPort = metapanel.getAttribute('data-ws-port'); |
|
51 | var wsPort = metapanel.getAttribute('data-ws-port'); | |
52 |
|
52 | |||
53 | if (wsHost.length > 0 && wsPort.length > 0) |
|
53 | if (wsHost.length > 0 && wsPort.length > 0) { | |
54 | var centrifuge = new Centrifuge({ |
|
54 | var centrifuge = new Centrifuge({ | |
55 | "url": 'ws://' + wsHost + ':' + wsPort + "/connection/websocket", |
|
55 | "url": 'ws://' + wsHost + ':' + wsPort + "/connection/websocket", | |
56 | "project": metapanel.getAttribute('data-ws-project'), |
|
56 | "project": metapanel.getAttribute('data-ws-project'), | |
57 | "user": wsUser, |
|
57 | "user": wsUser, | |
58 | "timestamp": metapanel.getAttribute('data-ws-token-time'), |
|
58 | "timestamp": metapanel.getAttribute('data-ws-token-time'), | |
59 | "token": metapanel.getAttribute('data-ws-token'), |
|
59 | "token": metapanel.getAttribute('data-ws-token'), | |
60 | "debug": false |
|
60 | "debug": false | |
61 | }); |
|
61 | }); | |
62 |
|
62 | |||
63 | centrifuge.on('error', function(error_message) { |
|
63 | centrifuge.on('error', function(error_message) { | |
64 | console.log("Error connecting to websocket server."); |
|
64 | console.log("Error connecting to websocket server."); | |
65 | console.log(error_message); |
|
65 | console.log(error_message); | |
66 | return false; |
|
66 | return false; | |
67 | }); |
|
|||
68 |
|
||||
69 | centrifuge.on('connect', function() { |
|
|||
70 | var channelName = 'thread:' + threadId; |
|
|||
71 | centrifuge.subscribe(channelName, function(message) { |
|
|||
72 | getThreadDiff(); |
|
|||
73 | }); |
|
67 | }); | |
74 |
|
68 | |||
75 | // For the case we closed the browser and missed some updates |
|
69 | centrifuge.on('connect', function() { | |
76 | getThreadDiff(); |
|
70 | var channelName = 'thread:' + threadId; | |
77 | $('#autoupdate').hide(); |
|
71 | centrifuge.subscribe(channelName, function(message) { | |
78 | }); |
|
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 | if (location.protocol === 'https:') { |
|
207 | if (location.protocol === 'https:') { | |
205 | return enableJsUpdate(); |
|
208 | return enableJsUpdate(); | |
206 | } else { |
|
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