if we disable websocket in single process mode, there's no need for the JS

This commit is contained in:
MrZYX 2011-05-17 19:26:28 +02:00
parent 0a8ce3b9f2
commit 1746f610b6
2 changed files with 19 additions and 13 deletions

View file

@ -2,9 +2,13 @@
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
:javascript
WebSocket.__swfLocation = "#{javascript_path 'vendor/WebSocketMain.swf'}";
$(document).ready(function(){
WSR.initialize("#{(AppConfig[:socket_secure])?'wss':'ws'}://#{request.host}:#{AppConfig[:socket_port]}/");
});
-if AppConfig[:single_process_mode]
:javascript
var websocket_enabled = false
- else
:javascript
var websocket_enabled = true
WebSocket.__swfLocation = "#{javascript_path 'vendor/WebSocketMain.swf'}";
$(document).ready(function(){
WSR.initialize("#{(AppConfig[:socket_secure])?'wss':'ws'}://#{request.host}:#{AppConfig[:socket_port]}/");
});

View file

@ -6,14 +6,16 @@ var WebSocketReceiver = {
//Attach onmessage to websocket
ws.onmessage = WSR.onMessage;
ws.onclose = function() {
Diaspora.widgets.notifications.showNotification({
html: '<div class="notification">' +
Diaspora.widgets.i18n.t("web_sockets.disconnected") +
'</div>',
incrementCount: false
});
if (websocket_enabled) {
Diaspora.widgets.notifications.showNotification({
html: '<div class="notification">' +
Diaspora.widgets.i18n.t("web_sockets.disconnected") +
'</div>',
incrementCount: false
});
WSR.debug("socket closed");
WSR.debug("socket closed");
}
};
ws.onopen = function() {
ws.send(location.pathname);