[mapguide-commits] r5666 - trunk/Tools/Maestro/Maestro.Base/Events

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Mar 29 07:34:50 EDT 2011


Author: jng
Date: 2011-03-29 04:34:50 -0700 (Tue, 29 Mar 2011)
New Revision: 5666

Modified:
   trunk/Tools/Maestro/Maestro.Base/Events/EventWatcher.cs
Log:
#1645: Add a keep alive timer to prevent session expiry. This interval is set at 60s


Modified: trunk/Tools/Maestro/Maestro.Base/Events/EventWatcher.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Events/EventWatcher.cs	2011-03-28 13:40:36 UTC (rev 5665)
+++ trunk/Tools/Maestro/Maestro.Base/Events/EventWatcher.cs	2011-03-29 11:34:50 UTC (rev 5666)
@@ -25,20 +25,45 @@
 using Maestro.Base.UI;
 using Maestro.Editors.Diagnostics;
 using OSGeo.MapGuide.MaestroAPI.Services;
+using ICSharpCode.Core;
+using System.Windows.Forms;
 
 namespace Maestro.Base.Events
 {
     public static class EventWatcher
     {
+        private static Timer _keepAliveTimer;
+
         internal static void Initialize()
         {
+            _keepAliveTimer = new Timer();
+            _keepAliveTimer.Interval = 60000;
+            _keepAliveTimer.Tick += OnKeepAliveTimerElapsed;
             var svc = ServiceRegistry.GetService<ServerConnectionManager>();
             Debug.Assert(svc != null);
 
             svc.ConnectionAdded += new ServerConnectionEventHandler(OnConnectionAdded);
             svc.ConnectionRemoved += new ServerConnectionEventHandler(OnConnectionRemoved);
+
+            LoggingService.Info("Starting session keep-alive timer");
+            _keepAliveTimer.Start();
         }
 
+        static void OnKeepAliveTimerElapsed(object sender, EventArgs e)
+        {
+            var svc = ServiceRegistry.GetService<ServerConnectionManager>();
+            foreach (var name in svc.GetConnectionNames())
+            {
+                var conn = svc.GetConnection(name);
+                string sessionId = conn.SessionID;
+                if (!string.IsNullOrEmpty(sessionId))
+                {
+                    conn.FeatureService.GetProviderCapabilities("OSGeo.SDF");
+                    LoggingService.Info("Session kept alive: " + sessionId);
+                }
+            }
+        }
+
         static void OnConnectionRemoved(object sender, string name)
         {
             Workbench wb = Workbench.Instance;



More information about the mapguide-commits mailing list