settings: Add option to disable websockets.

This can be useful in scenarios where the network doesn't support
websockets.  We don't include it in prod_settings_template.py since
it's a very rare setting to need.

Fixes #1528.
This commit is contained in:
Zac Pullar-Strecker
2016-12-05 20:57:23 +00:00
committed by Tim Abbott
parent 84765e48a9
commit e6e11aefb3
5 changed files with 5 additions and 3 deletions

View File

@@ -442,7 +442,7 @@ function report_send_time(send_time, receive_time, display_time, locally_echoed,
} }
var socket; var socket;
if (feature_flags.use_socket) { if (page_params.use_socket) {
socket = new Socket("/sockjs"); socket = new Socket("/sockjs");
} }
// For debugging. The socket will eventually move out of this file anyway. // For debugging. The socket will eventually move out of this file anyway.
@@ -555,7 +555,7 @@ exports.send_message_success = function (local_id, message_id, start_time, local
exports.transmit_message = function (request, success, error) { exports.transmit_message = function (request, success, error) {
delete exports.send_times_data[request.id]; delete exports.send_times_data[request.id];
if (feature_flags.use_socket) { if (page_params.use_socket) {
send_message_socket(request, success, error); send_message_socket(request, success, error);
} else { } else {
send_message_ajax(request, success, error); send_message_ajax(request, success, error);

View File

@@ -5,7 +5,6 @@ var exports = {};
// Manually-flipped debugging flags // Manually-flipped debugging flags
exports.log_send_times = false; exports.log_send_times = false;
exports.collect_send_times = false; exports.collect_send_times = false;
exports.use_socket = true;
exports.local_echo = true; exports.local_echo = true;
// Experimental modification to support much wider message views. // Experimental modification to support much wider message views.

View File

@@ -1861,6 +1861,7 @@ class HomeTest(ZulipTestCase):
"twenty_four_hour_time", "twenty_four_hour_time",
"unread_count", "unread_count",
"unsubbed_info", "unsubbed_info",
"use_websockets",
"user_id", "user_id",
"zulip_version", "zulip_version",
] ]

View File

@@ -605,6 +605,7 @@ def home_real(request):
prompt_for_invites = prompt_for_invites, prompt_for_invites = prompt_for_invites,
notifications_stream = notifications_stream, notifications_stream = notifications_stream,
cross_realm_bots = list(get_cross_realm_dicts()), cross_realm_bots = list(get_cross_realm_dicts()),
use_websockets = settings.USE_WEBSOCKETS,
# Stream message notification settings: # Stream message notification settings:
stream_desktop_notifications_enabled = user_profile.enable_stream_desktop_notifications, stream_desktop_notifications_enabled = user_profile.enable_stream_desktop_notifications,

View File

@@ -181,6 +181,7 @@ DEFAULT_SETTINGS = {'TWITTER_CONSUMER_KEY': '',
'USING_PGROONGA': False, 'USING_PGROONGA': False,
'POST_MIGRATION_CACHE_FLUSHING': False, 'POST_MIGRATION_CACHE_FLUSHING': False,
'ENABLE_FILE_LINKS': False, 'ENABLE_FILE_LINKS': False,
'USE_WEBSOCKETS': True,
} }
for setting_name, setting_val in six.iteritems(DEFAULT_SETTINGS): for setting_name, setting_val in six.iteritems(DEFAULT_SETTINGS):