Index: lams_admin/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r4583983b64efe1d91fbb47cdde6a759a6a30e859 -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 --- lams_admin/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 4583983b64efe1d91fbb47cdde6a759a6a30e859) +++ lams_admin/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) @@ -95,9 +95,11 @@ LEARNING_URL = LAMS_URL + 'learning/', // it gets initialised along with progress bar + commandWebsocketInitTime = null, commandWebsocket = null, commandWebsocketPingTimeout = null, commandWebsocketPingFunc = null, + commandWebsocketReconnectAttempts = 0, bars = { 'learnerMainBar' : { @@ -108,7 +110,9 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - initCommandWebsocket(); + if (Date.now() - commandWebsocketInitTime > 1000) { + initCommandWebsocket(); + } return; } @@ -165,17 +169,23 @@ } 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); // set up timer for the first time commandWebsocketPingFunc(true); 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); } }; // when the server pushes new commands Index: lams_central/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r4583983b64efe1d91fbb47cdde6a759a6a30e859 -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 --- lams_central/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 4583983b64efe1d91fbb47cdde6a759a6a30e859) +++ lams_central/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) @@ -95,9 +95,11 @@ LEARNING_URL = LAMS_URL + 'learning/', // it gets initialised along with progress bar + commandWebsocketInitTime = null, commandWebsocket = null, commandWebsocketPingTimeout = null, commandWebsocketPingFunc = null, + commandWebsocketReconnectAttempts = 0, bars = { 'learnerMainBar' : { @@ -108,7 +110,9 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - initCommandWebsocket(); + if (Date.now() - commandWebsocketInitTime > 1000) { + initCommandWebsocket(); + } return; } @@ -165,17 +169,23 @@ } 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); // set up timer for the first time commandWebsocketPingFunc(true); 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); } }; // when the server pushes new commands Index: lams_gradebook/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r4583983b64efe1d91fbb47cdde6a759a6a30e859 -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 --- lams_gradebook/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 4583983b64efe1d91fbb47cdde6a759a6a30e859) +++ lams_gradebook/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) @@ -95,9 +95,11 @@ LEARNING_URL = LAMS_URL + 'learning/', // it gets initialised along with progress bar + commandWebsocketInitTime = null, commandWebsocket = null, commandWebsocketPingTimeout = null, commandWebsocketPingFunc = null, + commandWebsocketReconnectAttempts = 0, bars = { 'learnerMainBar' : { @@ -108,7 +110,9 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - initCommandWebsocket(); + if (Date.now() - commandWebsocketInitTime > 1000) { + initCommandWebsocket(); + } return; } @@ -165,17 +169,23 @@ } 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); // set up timer for the first time commandWebsocketPingFunc(true); 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); } }; // when the server pushes new commands Index: lams_learning/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r4583983b64efe1d91fbb47cdde6a759a6a30e859 -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 --- lams_learning/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 4583983b64efe1d91fbb47cdde6a759a6a30e859) +++ lams_learning/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) @@ -95,9 +95,11 @@ LEARNING_URL = LAMS_URL + 'learning/', // it gets initialised along with progress bar + commandWebsocketInitTime = null, commandWebsocket = null, commandWebsocketPingTimeout = null, commandWebsocketPingFunc = null, + commandWebsocketReconnectAttempts = 0, bars = { 'learnerMainBar' : { @@ -108,7 +110,9 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - initCommandWebsocket(); + if (Date.now() - commandWebsocketInitTime > 1000) { + initCommandWebsocket(); + } return; } @@ -165,17 +169,23 @@ } 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); // set up timer for the first time commandWebsocketPingFunc(true); 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); } }; // when the server pushes new commands Index: lams_learning/web/includes/javascript/presence.js =================================================================== diff -u -r4583983b64efe1d91fbb47cdde6a759a6a30e859 -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 --- lams_learning/web/includes/javascript/presence.js (.../presence.js) (revision 4583983b64efe1d91fbb47cdde6a759a6a30e859) +++ lams_learning/web/includes/javascript/presence.js (.../presence.js) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) @@ -90,16 +90,19 @@ } }, + presenceWebsocketInitTime = Date.now(), // init the connection with server using server URL but with different protocol presenceWebsocket = new WebSocket(APP_URL.replace('http', 'ws') + 'presenceChatWebsocket?lessonID=' + lessonId - + '&imEnabled=' + presenceImEnabled - + '&nickname=' + encodeURIComponent(nickname)), + + '&imEnabled=' + presenceImEnabled + + '&nickname=' + encodeURIComponent(nickname)), presenceWebsocketPingTimeout = null, presenceWebsocketPingFunc = null; presenceWebsocketPingFunc = function(skipPing){ - if (presenceWebsocket.readyState == presenceWebsocket.CLOSING - || presenceWebsocket.readyState == presenceWebsocket.CLOSED){ + if (presenceWebsocket.readyState == presenceWebsocket.CLOSING || presenceWebsocket.readyState == presenceWebsocket.CLOSED) { + if (Date.now() - presenceWebsocketInitTime < 1000) { + return; + } location.reload(); } @@ -115,7 +118,8 @@ presenceWebsocket.onclose = function(e){ // react only on abnormal close - if (e.code === 1006) { + if (e.code === 1006 && + Date.now() - presenceWebsocketInitTime > 1000) { location.reload(); } }; Index: lams_monitoring/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r4583983b64efe1d91fbb47cdde6a759a6a30e859 -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 --- lams_monitoring/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 4583983b64efe1d91fbb47cdde6a759a6a30e859) +++ lams_monitoring/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) @@ -95,9 +95,11 @@ LEARNING_URL = LAMS_URL + 'learning/', // it gets initialised along with progress bar + commandWebsocketInitTime = null, commandWebsocket = null, commandWebsocketPingTimeout = null, commandWebsocketPingFunc = null, + commandWebsocketReconnectAttempts = 0, bars = { 'learnerMainBar' : { @@ -108,7 +110,9 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - initCommandWebsocket(); + if (Date.now() - commandWebsocketInitTime > 1000) { + initCommandWebsocket(); + } return; } @@ -165,17 +169,23 @@ } 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); // set up timer for the first time commandWebsocketPingFunc(true); 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); } }; // when the server pushes new commands Index: lams_tool_assessment/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r4583983b64efe1d91fbb47cdde6a759a6a30e859 -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 --- lams_tool_assessment/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 4583983b64efe1d91fbb47cdde6a759a6a30e859) +++ lams_tool_assessment/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) @@ -95,9 +95,11 @@ LEARNING_URL = LAMS_URL + 'learning/', // it gets initialised along with progress bar + commandWebsocketInitTime = null, commandWebsocket = null, commandWebsocketPingTimeout = null, commandWebsocketPingFunc = null, + commandWebsocketReconnectAttempts = 0, bars = { 'learnerMainBar' : { @@ -108,7 +110,9 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - initCommandWebsocket(); + if (Date.now() - commandWebsocketInitTime > 1000) { + initCommandWebsocket(); + } return; } @@ -165,17 +169,23 @@ } 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); // set up timer for the first time commandWebsocketPingFunc(true); 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); } }; // when the server pushes new commands Index: lams_tool_bbb/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r4583983b64efe1d91fbb47cdde6a759a6a30e859 -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 --- lams_tool_bbb/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 4583983b64efe1d91fbb47cdde6a759a6a30e859) +++ lams_tool_bbb/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) @@ -95,9 +95,11 @@ LEARNING_URL = LAMS_URL + 'learning/', // it gets initialised along with progress bar + commandWebsocketInitTime = null, commandWebsocket = null, commandWebsocketPingTimeout = null, commandWebsocketPingFunc = null, + commandWebsocketReconnectAttempts = 0, bars = { 'learnerMainBar' : { @@ -108,7 +110,9 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - initCommandWebsocket(); + if (Date.now() - commandWebsocketInitTime > 1000) { + initCommandWebsocket(); + } return; } @@ -165,17 +169,23 @@ } 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); // set up timer for the first time commandWebsocketPingFunc(true); 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); } }; // when the server pushes new commands Index: lams_tool_chat/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r4583983b64efe1d91fbb47cdde6a759a6a30e859 -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 --- lams_tool_chat/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 4583983b64efe1d91fbb47cdde6a759a6a30e859) +++ lams_tool_chat/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) @@ -95,9 +95,11 @@ LEARNING_URL = LAMS_URL + 'learning/', // it gets initialised along with progress bar + commandWebsocketInitTime = null, commandWebsocket = null, commandWebsocketPingTimeout = null, commandWebsocketPingFunc = null, + commandWebsocketReconnectAttempts = 0, bars = { 'learnerMainBar' : { @@ -108,7 +110,9 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - initCommandWebsocket(); + if (Date.now() - commandWebsocketInitTime > 1000) { + initCommandWebsocket(); + } return; } @@ -165,17 +169,23 @@ } 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); // set up timer for the first time commandWebsocketPingFunc(true); 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); } }; // when the server pushes new commands Index: lams_tool_chat/web/includes/javascript/learning.js =================================================================== diff -u -r7cb18d1521c69062337439737a624a60a27013d4 -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 --- lams_tool_chat/web/includes/javascript/learning.js (.../learning.js) (revision 7cb18d1521c69062337439737a624a60a27013d4) +++ lams_tool_chat/web/includes/javascript/learning.js (.../learning.js) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) @@ -21,6 +21,7 @@ // only Monitor can send a personal message var selectedUser = null, + chatWebsocketInitTime = Date.now(), // init the connection with server using server URL but with different protocol chatWebsocket = new WebSocket(APP_URL.replace('http', 'ws') + 'learningWebsocket?toolSessionID=' + TOOL_SESSION_ID), @@ -30,6 +31,9 @@ chatWebsocketPingFunc = function(skipPing){ if (chatWebsocket.readyState == chatWebsocket.CLOSING || chatWebsocket.readyState == chatWebsocket.CLOSED){ + if (Date.now() - chatWebsocketInitTime < 1000) { + return; + } location.reload(); } @@ -45,7 +49,8 @@ chatWebsocket.onclose = function(e){ // react only on abnormal close - if (e.code === 1006) { + if (e.code === 1006 && + Date.now() - chatWebsocketInitTime > 1000) { location.reload(); } }; Index: lams_tool_daco/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r4583983b64efe1d91fbb47cdde6a759a6a30e859 -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 --- lams_tool_daco/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 4583983b64efe1d91fbb47cdde6a759a6a30e859) +++ lams_tool_daco/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) @@ -95,9 +95,11 @@ LEARNING_URL = LAMS_URL + 'learning/', // it gets initialised along with progress bar + commandWebsocketInitTime = null, commandWebsocket = null, commandWebsocketPingTimeout = null, commandWebsocketPingFunc = null, + commandWebsocketReconnectAttempts = 0, bars = { 'learnerMainBar' : { @@ -108,7 +110,9 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - initCommandWebsocket(); + if (Date.now() - commandWebsocketInitTime > 1000) { + initCommandWebsocket(); + } return; } @@ -165,17 +169,23 @@ } 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); // set up timer for the first time commandWebsocketPingFunc(true); 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); } }; // when the server pushes new commands Index: lams_tool_doku/web/pages/learning/learning.jsp =================================================================== diff -u -r2364f530b04afc47ac32f6d4966a0a40d052410c -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 --- lams_tool_doku/web/pages/learning/learning.jsp (.../learning.jsp) (revision 2364f530b04afc47ac32f6d4966a0a40d052410c) +++ lams_tool_doku/web/pages/learning/learning.jsp (.../learning.jsp) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) @@ -95,14 +95,18 @@ //init the connection with server using server URL but with different protocol - var dokuWebsocket = new WebSocket(''.replace('http', 'ws') + var dokuWebsocketInitTime = Date.now(), + dokuWebsocket = new WebSocket(''.replace('http', 'ws') + 'learningWebsocket?toolContentID=' + ${toolContentID}), dokuWebsocketPingTimeout = null, dokuWebsocketPingFunc = null; dokuWebsocketPingFunc = function(skipPing){ if (dokuWebsocket.readyState == dokuWebsocket.CLOSING || dokuWebsocket.readyState == dokuWebsocket.CLOSED){ + if (Date.now() - dokuWebsocketInitTime < 1000) { + return; + } location.reload(); } @@ -118,7 +122,8 @@ dokuWebsocket.onclose = function(){ // react only on abnormal close - if (e.code === 1006) { + if (e.code === 1006 && + Date.now() - dokuWebsocketInitTime > 1000) { location.reload(); } }; Index: lams_tool_forum/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r4583983b64efe1d91fbb47cdde6a759a6a30e859 -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 --- lams_tool_forum/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 4583983b64efe1d91fbb47cdde6a759a6a30e859) +++ lams_tool_forum/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) @@ -95,9 +95,11 @@ LEARNING_URL = LAMS_URL + 'learning/', // it gets initialised along with progress bar + commandWebsocketInitTime = null, commandWebsocket = null, commandWebsocketPingTimeout = null, commandWebsocketPingFunc = null, + commandWebsocketReconnectAttempts = 0, bars = { 'learnerMainBar' : { @@ -108,7 +110,9 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - initCommandWebsocket(); + if (Date.now() - commandWebsocketInitTime > 1000) { + initCommandWebsocket(); + } return; } @@ -165,17 +169,23 @@ } 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); // set up timer for the first time commandWebsocketPingFunc(true); 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); } }; // when the server pushes new commands Index: lams_tool_gmap/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r4583983b64efe1d91fbb47cdde6a759a6a30e859 -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 --- lams_tool_gmap/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 4583983b64efe1d91fbb47cdde6a759a6a30e859) +++ lams_tool_gmap/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) @@ -95,9 +95,11 @@ LEARNING_URL = LAMS_URL + 'learning/', // it gets initialised along with progress bar + commandWebsocketInitTime = null, commandWebsocket = null, commandWebsocketPingTimeout = null, commandWebsocketPingFunc = null, + commandWebsocketReconnectAttempts = 0, bars = { 'learnerMainBar' : { @@ -108,7 +110,9 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - initCommandWebsocket(); + if (Date.now() - commandWebsocketInitTime > 1000) { + initCommandWebsocket(); + } return; } @@ -165,17 +169,23 @@ } 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); // set up timer for the first time commandWebsocketPingFunc(true); 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); } }; // when the server pushes new commands Index: lams_tool_images/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r7cb18d1521c69062337439737a624a60a27013d4 -r6d721a0e00cff50aeec869b5399b5d2a49c54fa4 --- lams_tool_images/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 7cb18d1521c69062337439737a624a60a27013d4) +++ lams_tool_images/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 6d721a0e00cff50aeec869b5399b5d2a49c54fa4) @@ -46,7 +46,7 @@ <%-- Links placed in body instead of head. Ugly, but it works. --%> - + @@ -95,9 +95,11 @@ LEARNING_URL = LAMS_URL + 'learning/', // it gets initialised along with progress bar + commandWebsocketInitTime = null, commandWebsocket = null, commandWebsocketPingTimeout = null, commandWebsocketPingFunc = null, + commandWebsocketReconnectAttempts = 0, bars = { 'learnerMainBar' : { @@ -108,7 +110,9 @@ commandWebsocketPingFunc = function(skipPing){ if (commandWebsocket.readyState == commandWebsocket.CLOSING || commandWebsocket.readyState == commandWebsocket.CLOSED){ - initCommandWebsocket(); + if (Date.now() - commandWebsocketInitTime > 1000) { + initCommandWebsocket(); + } return; } @@ -165,17 +169,23 @@ } 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); // set up timer for the first time commandWebsocketPingFunc(true); 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); } }; // when the server pushes new commands @@ -277,7 +287,7 @@