diff --git a/OpenGridServices.GridServer/Main.cs b/OpenGridServices.GridServer/Main.cs index 46041d9141..ce24d72027 100644 --- a/OpenGridServices.GridServer/Main.cs +++ b/OpenGridServices.GridServer/Main.cs @@ -30,7 +30,11 @@ Copyright (c) OpenSim project, http://osgrid.org/ using System; using System.IO; using System.Text; +using System.Timers; +using System.Net; using libsecondlife; +using OpenSim.Framework; +using OpenSim.Framework.Sims; using OpenSim.Framework.Console; namespace OpenGridServices.GridServer @@ -56,6 +60,7 @@ namespace OpenGridServices.GridServer public SimProfileManager _regionmanager; private ConsoleBase m_console; + private Timer SimCheckTimer; [STAThread] public static void Main(string[] args) @@ -109,9 +114,40 @@ namespace OpenGridServices.GridServer m_console.WriteLine("Main.cs:Startup() - Starting HTTP process"); _httpd = new GridHTTPServer(); + m_console.WriteLine("Main.cs:Startup() - Starting sim status checker"); + SimCheckTimer = new Timer(); + SimCheckTimer.Interval = 300000; // 5 minutes + SimCheckTimer.Elapsed+=new ElapsedEventHandler(CheckSims); + SimCheckTimer.Enabled=true; } + + public void CheckSims(object sender, ElapsedEventArgs e) { + foreach(SimProfileBase sim in _regionmanager.SimProfiles.Values) { + string SimResponse=""; + try { + WebRequest CheckSim = WebRequest.Create("http://" + sim.sim_ip + ":" + sim.sim_port.ToString() + "/checkstatus"); + CheckSim.Method = "GET"; + CheckSim.ContentType = "text/plaintext"; + CheckSim.ContentLength = 0; - public void RunCmd(string cmd, string[] cmdparams) + StreamWriter stOut = new StreamWriter(CheckSim.GetRequestStream(), System.Text.Encoding.ASCII); + stOut.Write(""); + stOut.Close(); + + StreamReader stIn = new StreamReader(CheckSim.GetResponse().GetResponseStream()); + SimResponse = stIn.ReadToEnd(); + stIn.Close(); + } catch(Exception exception) { + } + if(SimResponse=="OK") { + _regionmanager.SimProfiles[sim.UUID].online=true; + } else { + _regionmanager.SimProfiles[sim.UUID].online=false; + } + } + } + + public void RunCmd(string cmd, string[] cmdparams) { switch (cmd) { diff --git a/OpenSim.Framework/SimProfileBase.cs b/OpenSim.Framework/SimProfileBase.cs index 5fe2734650..0ee5e75052 100644 --- a/OpenSim.Framework/SimProfileBase.cs +++ b/OpenSim.Framework/SimProfileBase.cs @@ -17,6 +17,7 @@ namespace OpenSim.Framework.Sims public uint RegionLocY; public string sendkey; public string recvkey; + public bool online; public SimProfileBase() {