Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to ping server when the 'stay logged in' button is clicked #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions jquery-idleTimeout-for-testing.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@
errorAlertMessage: 'Please disable "Private Mode", or upgrade to a modern browser. Or perhaps a dependent file missing. Please see: https://github.com/marcuswestin/store.js',

// server-side session keep-alive timer
sessionKeepAliveTimer: 600, // ping the server at this interval in seconds. 600 = 10 Minutes. Set to false to disable pings
sessionKeepAliveUrl: window.location.href // set URL to ping - does not apply if sessionKeepAliveTimer: false
sessionKeepAliveTimer: 600, // ping the server at this interval in seconds. 600 = 10 Minutes. Set to false to disable timed pings
sessionKeepAliveOnStayLoggedIn: false, // set to true to ping the server when the dialogStayLoggedInButton is clicked
sessionKeepAliveUrl: window.location.href // set URL to ping - does not apply if sessionKeepAliveTimer: false and sessionKeepAliveOnStayLoggedIn: false
},

//##############################
Expand All @@ -70,7 +71,7 @@
origTitle = document.title, // save original browser title
storeConfiguration, // public function support, store private configuration variables
activityDetector,
startKeepSessionAlive, stopKeepSessionAlive, keepSession, keepAlivePing, // session keep alive
pingServer, startKeepSessionAlive, stopKeepSessionAlive, keepSession, keepAlivePing, // session keep alive
idleTimer, remainingTimer, checkIdleTimeout, checkIdleTimeoutLoop, startIdleTimer, stopIdleTimer, // idle timer
openWarningDialog, dialogTimer, checkDialogTimeout, startDialogTimer, stopDialogTimer, isDialogOpen, destroyWarningDialog, countdownDisplay, // warning dialog
logoutUser,
Expand Down Expand Up @@ -104,12 +105,16 @@
};

//----------- KEEP SESSION ALIVE FUNCTIONS --------------//
pingServer = function() {
$.get(currentConfig.sessionKeepAliveUrl);
};

startKeepSessionAlive = function () {
console.log('start startKeepSessionAlive');

keepSession = function () {
console.log('startKeepSessionAlive - send ping to sessionKeepAliveUrl');
$.get(currentConfig.sessionKeepAliveUrl);
pingServer();
startKeepSessionAlive();
};

Expand Down Expand Up @@ -194,6 +199,7 @@
text: currentConfig.dialogStayLoggedInButton,
click: function () {
console.log('Stay Logged In button clicked');
if (currentConfig.sessionKeepAliveOnStayLoggedIn) { pingServer(); }
destroyWarningDialog();
stopDialogTimer();
startIdleTimer();
Expand Down
14 changes: 10 additions & 4 deletions jquery-idleTimeout-iframes.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@
errorAlertMessage: 'Please disable "Private Mode", or upgrade to a modern browser. Or perhaps a dependent file missing. Please see: https://github.com/marcuswestin/store.js',

// server-side session keep-alive timer
sessionKeepAliveTimer: 600, // ping the server at this interval in seconds. 600 = 10 Minutes. Set to false to disable pings
sessionKeepAliveUrl: window.location.href // set URL to ping - does not apply if sessionKeepAliveTimer: false
sessionKeepAliveTimer: 600, // ping the server at this interval in seconds. 600 = 10 Minutes. Set to false to disable timed pings
sessionKeepAliveOnStayLoggedIn: false, // set to true to ping the server when the dialogStayLoggedInButton is clicked
sessionKeepAliveUrl: window.location.href // set URL to ping - does not apply if sessionKeepAliveTimer: false and sessionKeepAliveOnStayLoggedIn: false
},

//##############################
Expand All @@ -67,7 +68,7 @@
origTitle = document.title, // save original browser title
storeConfiguration, // public function support, store private configuration variables
activityDetector,
startKeepSessionAlive, stopKeepSessionAlive, keepSession, keepAlivePing, // session keep alive
pingServer, startKeepSessionAlive, stopKeepSessionAlive, keepSession, keepAlivePing, // session keep alive
idleTimer, remainingTimer, checkIdleTimeout, checkIdleTimeoutLoop, startIdleTimer, stopIdleTimer, // idle timer
openWarningDialog, dialogTimer, checkDialogTimeout, startDialogTimer, stopDialogTimer, isDialogOpen, destroyWarningDialog, countdownDisplay, // warning dialog
logoutUser,
Expand Down Expand Up @@ -98,10 +99,14 @@
};

//----------- KEEP SESSION ALIVE FUNCTIONS --------------//
pingServer = function() {
$.get(currentConfig.sessionKeepAliveUrl);
};

startKeepSessionAlive = function () {

keepSession = function () {
$.get(currentConfig.sessionKeepAliveUrl);
pingServer();
startKeepSessionAlive();
};

Expand Down Expand Up @@ -171,6 +176,7 @@
buttons: [{
text: currentConfig.dialogStayLoggedInButton,
click: function () {
if (currentConfig.sessionKeepAliveOnStayLoggedIn) { pingServer(); }
destroyWarningDialog();
stopDialogTimer();
startIdleTimer();
Expand Down
14 changes: 10 additions & 4 deletions jquery-idleTimeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@
errorAlertMessage: 'Please disable "Private Mode", or upgrade to a modern browser. Or perhaps a dependent file missing. Please see: https://github.com/marcuswestin/store.js',

// server-side session keep-alive timer
sessionKeepAliveTimer: 600, // ping the server at this interval in seconds. 600 = 10 Minutes. Set to false to disable pings
sessionKeepAliveUrl: window.location.href // set URL to ping - does not apply if sessionKeepAliveTimer: false
sessionKeepAliveTimer: 600, // ping the server at this interval in seconds. 600 = 10 Minutes. Set to false to disable timed pings
sessionKeepAliveOnStayLoggedIn: false, // set to true to ping the server when the dialogStayLoggedInButton is clicked
sessionKeepAliveUrl: window.location.href // set URL to ping - does not apply if sessionKeepAliveTimer: false and sessionKeepAliveOnStayLoggedIn: false
},

//##############################
Expand All @@ -66,7 +67,7 @@
currentConfig = $.extend(defaultConfig, userRuntimeConfig), // merge default and user runtime configuration
origTitle = document.title, // save original browser title
activityDetector,
startKeepSessionAlive, stopKeepSessionAlive, keepSession, keepAlivePing, // session keep alive
pingServer, startKeepSessionAlive, stopKeepSessionAlive, keepSession, keepAlivePing, // session keep alive
idleTimer, remainingTimer, checkIdleTimeout, checkIdleTimeoutLoop, startIdleTimer, stopIdleTimer, // idle timer
openWarningDialog, dialogTimer, checkDialogTimeout, startDialogTimer, stopDialogTimer, isDialogOpen, destroyWarningDialog, countdownDisplay, // warning dialog
logoutUser;
Expand All @@ -85,10 +86,14 @@
//##############################

//----------- KEEP SESSION ALIVE FUNCTIONS --------------//
pingServer = function() {
$.get(currentConfig.sessionKeepAliveUrl);
};

startKeepSessionAlive = function () {

keepSession = function () {
$.get(currentConfig.sessionKeepAliveUrl);
pingServer();
startKeepSessionAlive();
};

Expand Down Expand Up @@ -158,6 +163,7 @@
buttons: [{
text: currentConfig.dialogStayLoggedInButton,
click: function () {
if (currentConfig.sessionKeepAliveOnStayLoggedIn) { pingServer(); }
destroyWarningDialog();
stopDialogTimer();
startIdleTimer();
Expand Down