Index: lams_admin/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_admin/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_admin/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_central/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_central/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_central/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_gradebook/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_gradebook/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_gradebook/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_learning/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_learning/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_learning/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_learning/web/includes/javascript/presence.js =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_learning/web/includes/javascript/presence.js (.../presence.js) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_learning/web/includes/javascript/presence.js (.../presence.js) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -98,12 +98,17 @@ presenceWebsocketPingTimeout = null, presenceWebsocketPingFunc = null; + presenceWebsocket.onclose = function(e){ + // react only on abnormal close + if (e.code === 1006 && + Date.now() - presenceWebsocketInitTime > 1000) { + location.reload(); + } + }; + presenceWebsocketPingFunc = function(skipPing){ if (presenceWebsocket.readyState == presenceWebsocket.CLOSING || presenceWebsocket.readyState == presenceWebsocket.CLOSED) { - if (Date.now() - presenceWebsocketInitTime < 1000) { return; - } - location.reload(); } // check and ping every 3 minutes @@ -116,13 +121,7 @@ // set up timer for the first time presenceWebsocketPingFunc(true); - presenceWebsocket.onclose = function(e){ - // react only on abnormal close - if (e.code === 1006 && - Date.now() - presenceWebsocketInitTime > 1000) { - location.reload(); - } - }; + // when the server pushes new messages and roster to the learner's browser presenceWebsocket.onmessage = function(e){ // reset ping timer Index: lams_monitoring/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_monitoring/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_monitoring/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_tool_assessment/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_assessment/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_assessment/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_tool_bbb/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_bbb/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_bbb/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_tool_chat/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_chat/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_chat/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_tool_chat/web/includes/javascript/learning.js =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_chat/web/includes/javascript/learning.js (.../learning.js) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_chat/web/includes/javascript/learning.js (.../learning.js) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -28,13 +28,18 @@ chatWebsocketPingTimeout = null, chatWebsocketPingFunc = null; + chatWebsocket.onclose = function(e){ + // react only on abnormal close + if (e.code === 1006 && + Date.now() - chatWebsocketInitTime > 1000) { + location.reload(); + } + }; + chatWebsocketPingFunc = function(skipPing){ if (chatWebsocket.readyState == chatWebsocket.CLOSING || chatWebsocket.readyState == chatWebsocket.CLOSED){ - if (Date.now() - chatWebsocketInitTime < 1000) { - return; - } - location.reload(); + return; } // check and ping every 3 minutes @@ -46,15 +51,8 @@ }; // set up timer for the first time chatWebsocketPingFunc(true); - - chatWebsocket.onclose = function(e){ - // react only on abnormal close - if (e.code === 1006 && - Date.now() - chatWebsocketInitTime > 1000) { - location.reload(); - } - }; + chatWebsocket.onmessage = function(e){ // reset ping timer clearTimeout(chatWebsocketPingTimeout); Index: lams_tool_daco/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_daco/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_daco/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_tool_doku/web/WEB-INF/tags/Page.tag =================================================================== diff -u -ra9de30ffb55528730675199b378c0a9a3221160a -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_doku/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a9de30ffb55528730675199b378c0a9a3221160a) +++ lams_tool_doku/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -46,7 +46,7 @@ <%-- Links placed in body instead of head. Ugly, but it works. --%> - + @@ -95,14 +95,32 @@ LEARNING_URL = LAMS_URL + 'learning/', // it gets initialised along with progress bar + commandWebsocketInitTime = null, commandWebsocket = null, - + commandWebsocketPingTimeout = null, + commandWebsocketPingFunc = null, + commandWebsocketReconnectAttempts = 0, + bars = { 'learnerMainBar' : { 'containerId' : 'progressBarDiv' } }; - + + commandWebsocketPingFunc = function(skipPing){ + if (commandWebsocket.readyState == commandWebsocket.CLOSING + || commandWebsocket.readyState == commandWebsocket.CLOSED){ + return; + } + + // check and ping every 3 minutes + commandWebsocketPingTimeout = setTimeout(commandWebsocketPingFunc, 3*60*1000); + // initial set up does not send ping + if (!skipPing) { + commandWebsocket.send("ping"); + } + }; + function restartLesson(){ if (confirm(restartLessonConfirmation)) { window.location.href = LEARNING_URL + 'learner.do?method=restartLesson&lessonID=' + lessonId; @@ -146,18 +164,28 @@ } $('#sidebar').show(); } - + function initCommandWebsocket(){ + commandWebsocketInitTime = Date.now(); // it is not an obvious place to init the websocket, but we need lesson ID - commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); + commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + + 'commandWebsocket?lessonID=' + lessonId); commandWebsocket.onclose = function(e){ - if (e.code === 1006) { + // check reason and whether the close did not happen immediately after websocket creation + // (possible access denied, user logged out?) + if (e.code === 1006 && + Date.now() - commandWebsocketInitTime > 1000 && + commandWebsocketReconnectAttempts < 20) { + commandWebsocketReconnectAttempts++; // maybe iPad went into sleep mode? - // we need this websocket working, so init it again - initCommandWebsocket(); + // we need this websocket working, so init it again after delay + setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); // when the server pushes new commands commandWebsocket.onmessage = function(e){ @@ -169,6 +197,10 @@ if (command.redirectURL) { window.location.href = command.redirectURL; } + + // reset ping timer + clearTimeout(commandWebsocketPingTimeout); + commandWebsocketPingFunc(true); }; } @@ -254,11 +286,11 @@ - - - - Index: lams_tool_forum/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_forum/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_forum/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_tool_gmap/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_gmap/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_gmap/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_tool_images/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_images/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_images/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_tool_imscc/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_imscc/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_imscc/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_tool_kaltura/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_kaltura/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_kaltura/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_tool_lamc/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_lamc/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_lamc/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_tool_laqa/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_laqa/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_laqa/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_tool_larsrc/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_larsrc/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_larsrc/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_tool_leader/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_leader/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_leader/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_tool_leader/web/pages/learning/leaderselection.jsp =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_leader/web/pages/learning/leaderselection.jsp (.../leaderselection.jsp) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_leader/web/pages/learning/leaderselection.jsp (.../leaderselection.jsp) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -32,14 +32,19 @@ + 'learningWebsocket?toolSessionID=' + ${toolSessionID}), leaderWebsocketPingTimeout = null, leaderWebsocketPingFunc = null; - + + leaderWebsocket.onclose = function(e){ + // react only on abnormal close + if (e.code === 1006 && + Date.now() - leaderWebsocketInitTime > 1000) { + location.reload(); + } + }; + leaderWebsocketPingFunc = function(skipPing){ if (leaderWebsocket.readyState == leaderWebsocket.CLOSING || leaderWebsocket.readyState == leaderWebsocket.CLOSED){ - if (Date.now() - leaderWebsocketInitTime < 1000) { - return; - } - location.reload(); + return; } // check and ping every 3 minutes @@ -49,17 +54,11 @@ leaderWebsocket.send("ping"); } }; + // set up timer for the first time leaderWebsocketPingFunc(true); + - leaderWebsocket.onclose = function(e){ - // react only on abnormal close - if (e.code === 1006 && - Date.now() - leaderWebsocketInitTime > 1000) { - location.reload(); - } - }; - // run when the leader has just been selected leaderWebsocket.onmessage = function(e) { // no need to reset ping timer as the only possible message is page refresh Index: lams_tool_mindmap/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_mindmap/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_mindmap/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_tool_nb/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_nb/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_nb/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_tool_notebook/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_notebook/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_notebook/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_tool_pixlr/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_pixlr/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_pixlr/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_tool_preview/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_preview/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_preview/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_tool_sbmt/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_sbmt/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_sbmt/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_tool_scratchie/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_scratchie/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_scratchie/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_tool_scratchie/web/pages/learning/questionlist.jsp =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_scratchie/web/pages/learning/questionlist.jsp (.../questionlist.jsp) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_scratchie/web/pages/learning/questionlist.jsp (.../questionlist.jsp) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -34,13 +34,18 @@ scratchieWebsocketPingTimeout = null, scratchieWebsocketPingFunc = null; + scratchieWebsocket.onclose = function(e) { + // react only on abnormal close + if (e.code === 1006 && + Date.now() - scratchieWebsocketInitTime > 1000) { + location.reload(); + } + }; + scratchieWebsocketPingFunc = function(skipPing){ if (scratchieWebsocket.readyState == scratchieWebsocket.CLOSING || scratchieWebsocket.readyState == scratchieWebsocket.CLOSED){ - if (Date.now() - scratchieWebsocketInitTime < 1000) { - return; - } - location.reload(); + return; } // check and ping every 3 minutes @@ -50,17 +55,11 @@ scratchieWebsocket.send("ping"); } }; + // set up timer for the first time scratchieWebsocketPingFunc(true); + - scratchieWebsocket.onclose = function(e) { - // react only on abnormal close - if (e.code === 1006 && - Date.now() - scratchieWebsocketInitTime > 1000) { - location.reload(); - } - }; - // run when the server pushes new reports and vote statistics scratchieWebsocket.onmessage = function(e) { // create JSON object Index: lams_tool_scribe/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_scribe/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_scribe/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_tool_scribe/web/pages/learning/learning.jsp =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_scribe/web/pages/learning/learning.jsp (.../learning.jsp) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_scribe/web/pages/learning/learning.jsp (.../learning.jsp) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -18,7 +18,14 @@ scribeWebsocketPingFunc = null, agreementPercentageLabel = '', reportSubmitted = ${scribeSessionDTO.reportSubmitted}; - + + scribeWebsocket.onclose = function(e){ + if (e.code === 1006 && + Date.now() - scribeWebsocketInitTime > 1000) { + location.reload(); + } + }; + scribeWebsocketPingFunc = function(skipPing){ if (scribeWebsocket.readyState == scribeWebsocket.CLOSING || scribeWebsocket.readyState == scribeWebsocket.CLOSED){ @@ -35,16 +42,10 @@ scribeWebsocket.send("ping"); } }; + // set up timer for the first time scribeWebsocketPingFunc(true); - scribeWebsocket.onclose = function(e){ - if (e.code === 1006 && - Date.now() - scribeWebsocketInitTime > 1000) { - location.reload(); - } - }; - // run when the server pushes new reports and vote statistics scribeWebsocket.onmessage = function(e) { // create JSON object Index: lams_tool_spreadsheet/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_spreadsheet/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_spreadsheet/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_tool_survey/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_survey/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_survey/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_tool_task/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_task/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_task/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_tool_vote/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_vote/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_vote/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_tool_wiki/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_tool_wiki/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_tool_wiki/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object Index: lams_www/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 -ra7abd606c1cbadff976b75ab062f1466358f8c96 --- lams_www/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) +++ lams_www/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision a7abd606c1cbadff976b75ab062f1466358f8c96) @@ -110,9 +110,6 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - if (Date.now() - commandWebsocketInitTime > 1000) { - initCommandWebsocket(); - } return; } @@ -173,9 +170,7 @@ // it is not an obvious place to init the websocket, but we need lesson ID commandWebsocket = new WebSocket(LEARNING_URL.replace('http', 'ws') + 'commandWebsocket?lessonID=' + lessonId); - // set up timer for the first time - commandWebsocketPingFunc(true); - + commandWebsocket.onclose = function(e){ // check reason and whether the close did not happen immediately after websocket creation // (possible access denied, user logged out?) @@ -188,6 +183,10 @@ setTimeout(initCommandWebsocket, 3000); } }; + + // set up timer for the first time + commandWebsocketPingFunc(true); + // when the server pushes new commands commandWebsocket.onmessage = function(e){ // read JSON object