aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGridServices.GridServer
diff options
context:
space:
mode:
authorgareth2007-04-02 01:35:22 +0000
committergareth2007-04-02 01:35:22 +0000
commitfc3213e188823d3a628ca607bdb34815fc56a0f6 (patch)
treea5820685ab703e47b7f359b34afdbcefcf26efbb /OpenGridServices.GridServer
parentAdded new REST protocol (partially complete) (diff)
downloadopensim-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 '')
-rw-r--r--OpenGridServices.GridServer/Main.cs40
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/
30using System; 30using System;
31using System.IO; 31using System.IO;
32using System.Text; 32using System.Text;
33using System.Timers;
34using System.Net;
33using libsecondlife; 35using libsecondlife;
36using OpenSim.Framework;
37using OpenSim.Framework.Sims;
34using OpenSim.Framework.Console; 38using OpenSim.Framework.Console;
35 39
36namespace OpenGridServices.GridServer 40namespace 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 {