Added sim check timer
parent
e985e05a5a
commit
fc3213e188
|
@ -30,7 +30,11 @@ Copyright (c) OpenSim project, http://osgrid.org/
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Timers;
|
||||||
|
using System.Net;
|
||||||
using libsecondlife;
|
using libsecondlife;
|
||||||
|
using OpenSim.Framework;
|
||||||
|
using OpenSim.Framework.Sims;
|
||||||
using OpenSim.Framework.Console;
|
using OpenSim.Framework.Console;
|
||||||
|
|
||||||
namespace OpenGridServices.GridServer
|
namespace OpenGridServices.GridServer
|
||||||
|
@ -56,6 +60,7 @@ namespace OpenGridServices.GridServer
|
||||||
public SimProfileManager _regionmanager;
|
public SimProfileManager _regionmanager;
|
||||||
|
|
||||||
private ConsoleBase m_console;
|
private ConsoleBase m_console;
|
||||||
|
private Timer SimCheckTimer;
|
||||||
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
|
@ -109,9 +114,40 @@ namespace OpenGridServices.GridServer
|
||||||
m_console.WriteLine("Main.cs:Startup() - Starting HTTP process");
|
m_console.WriteLine("Main.cs:Startup() - Starting HTTP process");
|
||||||
_httpd = new GridHTTPServer();
|
_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 RunCmd(string cmd, string[] cmdparams)
|
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;
|
||||||
|
|
||||||
|
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)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,6 +17,7 @@ namespace OpenSim.Framework.Sims
|
||||||
public uint RegionLocY;
|
public uint RegionLocY;
|
||||||
public string sendkey;
|
public string sendkey;
|
||||||
public string recvkey;
|
public string recvkey;
|
||||||
|
public bool online;
|
||||||
|
|
||||||
public SimProfileBase()
|
public SimProfileBase()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue