From 421a25eb56128a4a70675a8c6cb755c6da2f512d Mon Sep 17 00:00:00 2001 From: barisusakli Date: Thu, 3 Apr 2014 17:36:27 -0400 Subject: [PATCH] closes #1288 --- public/src/app.js | 13 +++++-------- src/controllers/api.js | 2 ++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/public/src/app.js b/public/src/app.js index f9a352a1a9..8393dfec2a 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -9,10 +9,7 @@ var socket, 'isFocused': true, 'currentRoom': null, 'widgets': {} - }, - - MAX_RECONNECTION_ATTEMPTS = 5, - RECONNECTION_DELAY = 200; + }; (function () { var showWelcomeMessage = false; @@ -32,8 +29,8 @@ var socket, }, 200); } else { socket = io.connect('', { - 'max reconnection attempts': MAX_RECONNECTION_ATTEMPTS, - 'reconnection delay': RECONNECTION_DELAY, + 'max reconnection attempts': config.maxReconnectionAttempts, + 'reconnection delay': config.reconnectionDelay, resource: RELATIVE_PATH.length ? RELATIVE_PATH.slice(1) + '/socket.io' : 'socket.io' }); @@ -112,9 +109,9 @@ var socket, }); socket.on('reconnecting', function (data, attempt) { - if(attempt === MAX_RECONNECTION_ATTEMPTS) { + if(attempt === config.maxReconnectionAttempts) { socket.socket.reconnectionAttempts = 0; - socket.socket.reconnectionDelay = RECONNECTION_DELAY; + socket.socket.reconnectionDelay = config.reconnectionDelay; return; } diff --git a/src/controllers/api.js b/src/controllers/api.js index c5ce4872a2..d3aef0b3fe 100644 --- a/src/controllers/api.js +++ b/src/controllers/api.js @@ -30,6 +30,8 @@ apiController.getConfig = function(req, res, next) { config.privateUserInfo = parseInt(meta.config.privateUserInfo, 10) === 1; config.usePagination = parseInt(meta.config.usePagination, 10) === 1; config.disableSocialButtons = parseInt(meta.config.disableSocialButtons, 10) === 1; + config.maxReconnectionAttempts = meta.config.maxReconnectionAttempts || 5; + config.reconnectionDelay = meta.config.reconnectionDelay || 200; config.topicsPerPage = meta.config.topicsPerPage || 20; config.postsPerPage = meta.config.postsPerPage || 20; config.maximumFileSize = meta.config.maximumFileSize;