]> source.dussan.org Git - nextcloud-server.git/commitdiff
implemented a heartbeat request which is calls the server every 15 minutes to prevent...
authorBernhard Posselt <nukeawhale@gmail.com>
Tue, 26 Feb 2013 18:34:46 +0000 (19:34 +0100)
committerBernhard Posselt <nukeawhale@gmail.com>
Tue, 26 Feb 2013 18:34:46 +0000 (19:34 +0100)
core/js/js.js
core/routes.php

index e373fca88658a72947007bf8960591af01000548..597ca2af9af7c10d1527a7cfb304547da4e77f36 100644 (file)
@@ -584,6 +584,7 @@ function fillWindow(selector) {
 }
 
 $(document).ready(function(){
+       sessionHeartBeat();
 
        if(!SVGSupport()){ //replace all svg images with png images for browser that dont support svg
                replaceSVG();
@@ -815,3 +816,17 @@ OC.set=function(name, value) {
        }
        context[tail]=value;
 };
+
+
+/**
+ * Calls the server periodically every 15 mins to ensure that session doesnt
+ * time out
+ */
+function sessionHeartBeat(){
+       OC.Router.registerLoadedCallback(function(){
+               setInterval(function(){
+                       var url = OC.Router.generate('heartbeat');
+                       $.post(url);
+               }, 15000);
+       });
+}
\ No newline at end of file
index 2527816b662c13e65baa950e2dde498162aaea28..be19b66bf72baaf76e5f5aa138905622a4075b02 100644 (file)
@@ -69,3 +69,8 @@ $this->create('app_script', '/apps/{app}/{file}')
        ->defaults(array('file' => 'index.php'))
        ->requirements(array('file' => '.*.php'))
        ->action('OC', 'loadAppScriptFile');
+
+// used for heartbeat
+$this->create('heartbeat', '/heartbeat')->action(function(){
+       // do nothing
+});
\ No newline at end of file