diff options
-rw-r--r-- | OpenGridServices.GridServer/Main.cs | 40 | ||||
-rw-r--r-- | OpenSim.Framework/SimProfileBase.cs | 1 |
2 files changed, 39 insertions, 2 deletions
diff --git a/OpenGridServices.GridServer/Main.cs b/OpenGridServices.GridServer/Main.cs index 46041d9..ce24d72 100644 --- a/OpenGridServices.GridServer/Main.cs +++ b/OpenGridServices.GridServer/Main.cs | |||
@@ -30,7 +30,11 @@ Copyright (c) OpenSim project, http://osgrid.org/ | |||
30 | using System; | 30 | using System; |
31 | using System.IO; | 31 | using System.IO; |
32 | using System.Text; | 32 | using System.Text; |
33 | using System.Timers; | ||
34 | using System.Net; | ||
33 | using libsecondlife; | 35 | using libsecondlife; |
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Sims; | ||
34 | using OpenSim.Framework.Console; | 38 | using OpenSim.Framework.Console; |
35 | 39 | ||
36 | namespace OpenGridServices.GridServer | 40 | namespace OpenGridServices.GridServer |
@@ -56,6 +60,7 @@ namespace OpenGridServices.GridServer | |||
56 | public SimProfileManager _regionmanager; | 60 | public SimProfileManager _regionmanager; |
57 | 61 | ||
58 | private ConsoleBase m_console; | 62 | private ConsoleBase m_console; |
63 | private Timer SimCheckTimer; | ||
59 | 64 | ||
60 | [STAThread] | 65 | [STAThread] |
61 | public static void Main(string[] args) | 66 | public static void Main(string[] args) |
@@ -109,9 +114,40 @@ namespace OpenGridServices.GridServer | |||
109 | m_console.WriteLine("Main.cs:Startup() - Starting HTTP process"); | 114 | m_console.WriteLine("Main.cs:Startup() - Starting HTTP process"); |
110 | _httpd = new GridHTTPServer(); | 115 | _httpd = new GridHTTPServer(); |
111 | 116 | ||
117 | m_console.WriteLine("Main.cs:Startup() - Starting sim status checker"); | ||
118 | SimCheckTimer = new Timer(); | ||
119 | SimCheckTimer.Interval = 300000; // 5 minutes | ||
120 | SimCheckTimer.Elapsed+=new ElapsedEventHandler(CheckSims); | ||
121 | SimCheckTimer.Enabled=true; | ||
112 | } | 122 | } |
113 | 123 | ||
114 | public void RunCmd(string cmd, string[] cmdparams) | 124 | public void CheckSims(object sender, ElapsedEventArgs e) { |
125 | foreach(SimProfileBase sim in _regionmanager.SimProfiles.Values) { | ||
126 | string SimResponse=""; | ||
127 | try { | ||
128 | WebRequest CheckSim = WebRequest.Create("http://" + sim.sim_ip + ":" + sim.sim_port.ToString() + "/checkstatus"); | ||
129 | CheckSim.Method = "GET"; | ||
130 | CheckSim.ContentType = "text/plaintext"; | ||
131 | CheckSim.ContentLength = 0; | ||
132 | |||
133 | StreamWriter stOut = new StreamWriter(CheckSim.GetRequestStream(), System.Text.Encoding.ASCII); | ||
134 | stOut.Write(""); | ||
135 | stOut.Close(); | ||
136 | |||
137 | StreamReader stIn = new StreamReader(CheckSim.GetResponse().GetResponseStream()); | ||
138 | SimResponse = stIn.ReadToEnd(); | ||
139 | stIn.Close(); | ||
140 | } catch(Exception exception) { | ||
141 | } | ||
142 | if(SimResponse=="OK") { | ||
143 | _regionmanager.SimProfiles[sim.UUID].online=true; | ||
144 | } else { | ||
145 | _regionmanager.SimProfiles[sim.UUID].online=false; | ||
146 | } | ||
147 | } | ||
148 | } | ||
149 | |||
150 | public void RunCmd(string cmd, string[] cmdparams) | ||
115 | { | 151 | { |
116 | switch (cmd) | 152 | switch (cmd) |
117 | { | 153 | { |
diff --git a/OpenSim.Framework/SimProfileBase.cs b/OpenSim.Framework/SimProfileBase.cs index 5fe2734..0ee5e75 100644 --- a/OpenSim.Framework/SimProfileBase.cs +++ b/OpenSim.Framework/SimProfileBase.cs | |||
@@ -17,6 +17,7 @@ namespace OpenSim.Framework.Sims | |||
17 | public uint RegionLocY; | 17 | public uint RegionLocY; |
18 | public string sendkey; | 18 | public string sendkey; |
19 | public string recvkey; | 19 | public string recvkey; |
20 | public bool online; | ||
20 | 21 | ||
21 | public SimProfileBase() | 22 | public SimProfileBase() |
22 | { | 23 | { |