From 0856232f9f81aeca6186192f046331900bbb3d5b Mon Sep 17 00:00:00 2001 From: Seth Call Date: Tue, 17 Jun 2014 21:57:40 -0500 Subject: [PATCH] * VRFS-1798 - fixing 'backendguard' timer --- .../assets/javascripts/networkTestHelper.js | 37 ++++++++++++++----- web/app/assets/javascripts/utils.js | 4 +- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/web/app/assets/javascripts/networkTestHelper.js b/web/app/assets/javascripts/networkTestHelper.js index 2db8ed655..b61773924 100644 --- a/web/app/assets/javascripts/networkTestHelper.js +++ b/web/app/assets/javascripts/networkTestHelper.js @@ -137,7 +137,7 @@ context.jamClient.SetNetworkTestScore(0); renderStopTest('', "We're sorry, but your router and Internet service will not effectively support JamKazam sessions. Please click the HELP button for more information.") } - else if(reason == "unreachable") { + else if(reason == "unreachable" || reason == "no-transmit") { context.jamClient.SetNetworkTestScore(0); renderStopTest('', "We're sorry, but your router will not support JamKazam in its current configuration. Please click the HELP button for more information."); } @@ -149,12 +149,16 @@ context.JK.alertSupportedNeeded("The JamKazam service is experiencing technical difficulties."); renderStopTest('', ''); } + else if(reason == "server_comm_timeout") { + context.JK.alertSupportedNeeded("Communication with the JamKazam network service has timed out." + appendContextualStatement()); + renderStopTest('', ''); + } else if(reason == 'backend_gone') { context.JK.alertSupportedNeeded("The JamKazam client is experiencing technical difficulties."); renderStopTest('', ''); } else if(reason == "invalid_response") { - context.JK.alertSupportedNeeded("The JamKazam client software had an unexpected problem while scoring your Internet connection. Reason=" + attempt.backend_data.reason + '.'); + context.JK.alertSupportedNeeded("The JamKazam client software had an unexpected problem while scoring your Internet connection.

Reason: " + attempt.backend_data.reason + '.'); renderStopTest('', ''); } else if(reason == 'no_servers') { @@ -172,7 +176,7 @@ renderStopTest('', ''); } else if(reason == "timeout") { - context.JK.alertSupportedNeeded("Communication with a network test servers timed out." + appendContextualStatement()); + context.JK.alertSupportedNeeded("Communication with the JamKazam network service timed out." + appendContextualStatement()); testedSuccessfully = true; renderStopTest('', ''); } @@ -204,8 +208,9 @@ } function cancel() { - clearBackendGuard(); + } + function clearBackendGuard() { if(backendGuardTimeout) { clearTimeout(backendGuardTimeout); @@ -213,6 +218,11 @@ } } + function setBackendGuard() { + clearBackendGuard(); + backendGuardTimeout = setTimeout(function(){backendTimedOut()}, (gon.ftue_network_test_duration + 1) * 1000); + } + function attemptTestPass() { var attempt = {}; @@ -230,7 +240,7 @@ updateProgress(0, false); - backendGuardTimeout = setTimeout(function(){backendTimedOut()}, (gon.ftue_network_test_duration + 1) * 1000); + setBackendGuard(); context.jamClient.TestNetworkPktBwRate(serverClientId, createSuccessCallbackName(), createTimeoutCallbackName(), NETWORK_TEST_TYPES.PktTest400LowLatency, @@ -323,8 +333,6 @@ } function networkTestComplete(data) { - clearBackendGuard(); - var attempt = getCurrentAttempt(); function refineTest(up) { @@ -364,6 +372,8 @@ if(data.progress === true) { + setBackendGuard(); + var animate = true; if(data.downthroughput && data.upthroughput) { @@ -381,7 +391,7 @@ } } else { - + clearBackendGuard(); logger.debug("network test pass success. data: ", data); if(data.reason == "unreachable") { @@ -391,7 +401,9 @@ testFinished(); } else if(data.reason == "no-transmit") { - + logger.debug("network test: no-transmit (STUN issue or similar)"); + attempt.reason = data.reason; + testFinished(); } else if(data.reason == "internal_error") { // oops @@ -405,6 +417,11 @@ attempt.reason = data.reason; testFinished(); } + else if(data.reason == "server_comm_timeout") { + logger.debug("network test: server_comm_timeout (communication with server problem)") + attempt.reason = data.reason; + testFinished(); + } else { if(!data.downthroughput || !data.upthroughput) { // we have to assume this is bad. just not a reason we know about in code @@ -470,7 +487,7 @@ } function beforeHide() { - clearBackendGuard(); + } function initialize(_$step, _inGearWizard) { diff --git a/web/app/assets/javascripts/utils.js b/web/app/assets/javascripts/utils.js index 309547003..393ba7202 100644 --- a/web/app/assets/javascripts/utils.js +++ b/web/app/assets/javascripts/utils.js @@ -540,8 +540,8 @@ return ret; } - context.JK.alertSupportedNeeded = function(additionalContext) { - var $item = context.JK.Banner.showAlert(additionalContext + ' Please contact support'); + context.JK.alertSupportedNeeded = function(additionalContext) { + var $item = context.JK.Banner.showAlert(additionalContext + '

Please contact support.'); context.JK.popExternalLinks($item); return $item; }