diff options
author | gareth | 2007-04-02 01:35:22 +0000 |
---|---|---|
committer | gareth | 2007-04-02 01:35:22 +0000 |
commit | fc3213e188823d3a628ca607bdb34815fc56a0f6 (patch) | |
tree | a5820685ab703e47b7f359b34afdbcefcf26efbb /OpenGridServices.GridServer/Main.cs | |
parent | Added new REST protocol (partially complete) (diff) | |
download | opensim-SC_OLD-fc3213e188823d3a628ca607bdb34815fc56a0f6.zip opensim-SC_OLD-fc3213e188823d3a628ca607bdb34815fc56a0f6.tar.gz opensim-SC_OLD-fc3213e188823d3a628ca607bdb34815fc56a0f6.tar.bz2 opensim-SC_OLD-fc3213e188823d3a628ca607bdb34815fc56a0f6.tar.xz |
Added sim check timer
Diffstat (limited to 'OpenGridServices.GridServer/Main.cs')
-rw-r--r-- | OpenGridServices.GridServer/Main.cs | 40 |
1 files changed, 38 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 | { |