// *** *** Client side DbJsBasket functions - Keep Alive // *** Copyright Roy Henderson(henderson.roy@gmail.com) 2015, All Rights Reserved. $(document).ready(function () { KeepSessionAlive_TickStart(300000); }); var bitKeepSessionAlive_Started = false; var bitKeepSessionAlive_ForceStop = false; var intKeepSessionAlive_IntervalMillisecond = 10000; var intKeepSessionAlive_RefreshIntervalId = 0; function KeepSessionAlive_TickStart(intIntervilMilliseconds) { if (bitKeepSessionAlive_Started == false) { bitKeepSessionAlive_Started = true; intKeepSessionAlive_IntervalMillisecond = intIntervilMilliseconds; // Run the first tick intKeepSessionAlive_RefreshIntervalId = setInterval(function () { KeepSessionAlive_Handler(); }, intKeepSessionAlive_IntervalMillisecond); // 5 mins * 60 * 1000 } return true; } function KeepSessionAlive_TickForceStop() { if (bitKeepSessionAlive_Started == true) { bitKeepSessionAlive_ForceStop = true; } return true; } function KeepSessionAlive_Handler() { if (bitKeepSessionAlive_ForceStop == false) { try { $.get("/KeepSessionAlive", function (data) { //alert(data); }); } catch (e) { // Do nothing } } else { bitKeepSessionAlive_Started = false; bitKeepSessionAlive_ForceStop = false; clearInterval(intKeepSessionAlive_RefreshIntervalId); } return true; }