[fusion-commits] r2205 - in trunk/layers/MapGuide: . php

svn_fusion at osgeo.org svn_fusion at osgeo.org
Tue Aug 17 15:41:04 EDT 2010


Author: madair
Date: 2010-08-17 19:41:04 +0000 (Tue, 17 Aug 2010)
New Revision: 2205

Modified:
   trunk/layers/MapGuide/MapGuide.js
   trunk/layers/MapGuide/php/Common.php
Log:
closes #162: add a callback function and error response when the session expires or the MG server goes down

Modified: trunk/layers/MapGuide/MapGuide.js
===================================================================
--- trunk/layers/MapGuide/MapGuide.js	2010-08-17 17:19:31 UTC (rev 2204)
+++ trunk/layers/MapGuide/MapGuide.js	2010-08-17 19:41:04 UTC (rev 2205)
@@ -165,7 +165,7 @@
         }
           this.loadMap(this.sMapResourceId, options);
         }
-        window.setInterval(OpenLayers.Function.bind(this.pingServer, this), this.keepAliveInterval * 1000);
+        this.keepAliveTimer = window.setInterval(OpenLayers.Function.bind(this.pingServer, this), this.keepAliveInterval * 1000);
     },
 
     sessionReady: function() {
@@ -1127,10 +1127,21 @@
 
     pingServer: function() {
         var s = 'layers/' + this.arch + '/' + Fusion.getScriptLanguage() + "/Common." + Fusion.getScriptLanguage() ;
-        var params = {};
+        var params = {onSuccess: OpenLayers.Function.bind(this.checkPingResponse, this)};
         params.parameters = {'session': this.getSessionID()};
         Fusion.ajaxRequest(s, params);
     },
+    
+    checkPingResponse: function(xhr) {
+      if (xhr.responseText) {
+        var o;
+        eval("o="+xhr.responseText);
+        if (!o.success) {
+          Fusion.reportError(o.message);
+          clearInterval(this.keepAliveTimer);
+        }
+      }
+    },
 
     getLinkParams: function() {
       var queryParams = {};

Modified: trunk/layers/MapGuide/php/Common.php
===================================================================
--- trunk/layers/MapGuide/php/Common.php	2010-08-17 17:19:31 UTC (rev 2204)
+++ trunk/layers/MapGuide/php/Common.php	2010-08-17 19:41:04 UTC (rev 2205)
@@ -138,6 +138,8 @@
     $initializationErrorDetail = $e->GetDetails();
     $initializationErrorStackTrace = $e->GetStackTrace();
     $initializationErrorOccurred = true;
+    echo "{success: false, message:'".$initializationErrorMessage."'}";
+    //DisplayInitializationErrorHTML();
 }
 
 function InitializationErrorOccurred()



More information about the fusion-commits mailing list