diff options
author | lbsa71 | 2007-04-11 20:07:58 +0000 |
---|---|---|
committer | lbsa71 | 2007-04-11 20:07:58 +0000 |
commit | 1a28ef6292a152a69d0f53803daacc7dad522cea (patch) | |
tree | 3d4e2eed288b208f1d0db7d37e8f1d9a1dfca1c5 /OpenGridServices.GridServer/Main.cs | |
parent | * cleaning (diff) | |
download | opensim-SC_OLD-1a28ef6292a152a69d0f53803daacc7dad522cea.zip opensim-SC_OLD-1a28ef6292a152a69d0f53803daacc7dad522cea.tar.gz opensim-SC_OLD-1a28ef6292a152a69d0f53803daacc7dad522cea.tar.bz2 opensim-SC_OLD-1a28ef6292a152a69d0f53803daacc7dad522cea.tar.xz |
* Replaced GridHTTPServer and UserHTTPServer with BaseHttpServer
* Now dumping default value in config.
*
Diffstat (limited to '')
-rw-r--r-- | OpenGridServices.GridServer/Main.cs | 132 |
1 files changed, 81 insertions, 51 deletions
diff --git a/OpenGridServices.GridServer/Main.cs b/OpenGridServices.GridServer/Main.cs index 8c83bbf..5827227 100644 --- a/OpenGridServices.GridServer/Main.cs +++ b/OpenGridServices.GridServer/Main.cs | |||
@@ -38,16 +38,19 @@ using OpenSim.Framework; | |||
38 | using OpenSim.Framework.Sims; | 38 | using OpenSim.Framework.Sims; |
39 | using OpenSim.Framework.Console; | 39 | using OpenSim.Framework.Console; |
40 | using OpenSim.Framework.Interfaces; | 40 | using OpenSim.Framework.Interfaces; |
41 | using OpenSim.Servers; | ||
41 | 42 | ||
42 | namespace OpenGridServices.GridServer | 43 | namespace OpenGridServices.GridServer |
43 | { | 44 | { |
44 | /// <summary> | 45 | /// <summary> |
45 | /// </summary> | 46 | /// </summary> |
46 | public class OpenGrid_Main : conscmd_callback | 47 | public class OpenGrid_Main : BaseServer, conscmd_callback |
47 | { | 48 | { |
48 | private string ConfigDll = "OpenGrid.Config.GridConfigDb4o.dll"; | 49 | private string ConfigDll = "OpenGrid.Config.GridConfigDb4o.dll"; |
49 | private GridConfig Cfg; | 50 | private GridConfig Cfg; |
51 | |||
50 | public static OpenGrid_Main thegrid; | 52 | public static OpenGrid_Main thegrid; |
53 | |||
51 | public string GridOwner; | 54 | public string GridOwner; |
52 | public string DefaultStartupMsg; | 55 | public string DefaultStartupMsg; |
53 | public string DefaultAssetServer; | 56 | public string DefaultAssetServer; |
@@ -56,16 +59,14 @@ namespace OpenGridServices.GridServer | |||
56 | public string DefaultUserServer; | 59 | public string DefaultUserServer; |
57 | public string UserSendKey; | 60 | public string UserSendKey; |
58 | public string UserRecvKey; | 61 | public string UserRecvKey; |
59 | public string SimSendKey; | 62 | public string SimSendKey; |
60 | public string SimRecvKey; | 63 | public string SimRecvKey; |
61 | public LLUUID highestUUID; | 64 | //public LLUUID highestUUID; |
62 | 65 | ||
63 | public GridHTTPServer _httpd; | 66 | private SimProfileManager m_simProfileManager; |
64 | public SimProfileManager _regionmanager; | ||
65 | 67 | ||
66 | private ConsoleBase m_console; | 68 | private ConsoleBase m_console; |
67 | private Timer SimCheckTimer; | 69 | |
68 | |||
69 | [STAThread] | 70 | [STAThread] |
70 | public static void Main(string[] args) | 71 | public static void Main(string[] args) |
71 | { | 72 | { |
@@ -92,29 +93,49 @@ namespace OpenGridServices.GridServer | |||
92 | m_console = new ConsoleBase("opengrid-gridserver-console.log", "OpenGrid", this); | 93 | m_console = new ConsoleBase("opengrid-gridserver-console.log", "OpenGrid", this); |
93 | MainConsole.Instance = m_console; | 94 | MainConsole.Instance = m_console; |
94 | } | 95 | } |
95 | 96 | ||
96 | public void Startup() | 97 | public void Startup() |
97 | { | 98 | { |
98 | m_console.WriteLine("Main.cs:Startup() - Loading configuration"); | 99 | m_console.WriteLine("Main.cs:Startup() - Loading configuration"); |
99 | Cfg = this.LoadConfigDll(this.ConfigDll); | 100 | Cfg = this.LoadConfigDll(this.ConfigDll); |
100 | Cfg.InitConfig(); | 101 | Cfg.InitConfig(); |
101 | 102 | ||
102 | m_console.WriteLine("Main.cs:Startup() - Loading sim profiles from database"); | 103 | m_console.WriteLine("Main.cs:Startup() - Loading sim profiles from database"); |
103 | this._regionmanager = new SimProfileManager(); | 104 | m_simProfileManager = new SimProfileManager( this ); |
104 | _regionmanager.LoadProfiles(); | 105 | m_simProfileManager.LoadProfiles(); |
106 | |||
107 | m_console.WriteLine("Main.cs:Startup() - Starting HTTP process"); | ||
108 | BaseHttpServer httpServer = new BaseHttpServer(8001); | ||
105 | 109 | ||
106 | m_console.WriteLine("Main.cs:Startup() - Starting HTTP process"); | 110 | httpServer.AddXmlRPCHandler("simulator_login", m_simProfileManager.XmlRpcLoginToSimulatorMethod); |
107 | _httpd = new GridHTTPServer(); | ||
108 | _httpd.Start(); | ||
109 | 111 | ||
110 | m_console.WriteLine("Main.cs:Startup() - Starting sim status checker"); | 112 | httpServer.AddRestHandler("GET", "/sims/", m_simProfileManager.RestGetSimMethod); |
111 | SimCheckTimer = new Timer(); | 113 | httpServer.AddRestHandler("POST", "/sims/", m_simProfileManager.RestSetSimMethod); |
112 | SimCheckTimer.Interval = 300000; // 5 minutes | 114 | |
113 | SimCheckTimer.Elapsed+=new ElapsedEventHandler(CheckSims); | 115 | // lbsa71 : This code snippet taken from old http server. |
114 | SimCheckTimer.Enabled=true; | 116 | // I have no idea what this was supposed to do - looks like an infinite recursion to me. |
117 | // case "regions": | ||
118 | //// DIRTY HACK ALERT | ||
119 | //Console.WriteLine("/regions/ accessed"); | ||
120 | //TheSim = OpenGrid_Main.thegrid._regionmanager.GetProfileByHandle((ulong)Convert.ToUInt64(rest_params[1])); | ||
121 | //respstring = ParseREST("/regions/" + rest_params[1], requestBody, HTTPmethod); | ||
122 | //break; | ||
123 | |||
124 | // lbsa71 : I guess these were never used? | ||
125 | //Listener.Prefixes.Add("http://+:8001/gods/"); | ||
126 | //Listener.Prefixes.Add("http://+:8001/highestuuid/"); | ||
127 | //Listener.Prefixes.Add("http://+:8001/uuidblocks/"); | ||
128 | |||
129 | httpServer.Start(); | ||
130 | |||
131 | m_console.WriteLine("Main.cs:Startup() - Starting sim status checker"); | ||
132 | |||
133 | Timer simCheckTimer = new Timer( 300000 ); // 5 minutes | ||
134 | simCheckTimer.Elapsed += new ElapsedEventHandler(CheckSims); | ||
135 | simCheckTimer.Enabled = true; | ||
115 | } | 136 | } |
116 | 137 | ||
117 | private GridConfig LoadConfigDll(string dllName) | 138 | private GridConfig LoadConfigDll(string dllName) |
118 | { | 139 | { |
119 | Assembly pluginAssembly = Assembly.LoadFrom(dllName); | 140 | Assembly pluginAssembly = Assembly.LoadFrom(dllName); |
120 | GridConfig config = null; | 141 | GridConfig config = null; |
@@ -142,33 +163,42 @@ namespace OpenGridServices.GridServer | |||
142 | return config; | 163 | return config; |
143 | } | 164 | } |
144 | 165 | ||
145 | public void CheckSims(object sender, ElapsedEventArgs e) { | 166 | public void CheckSims(object sender, ElapsedEventArgs e) |
146 | foreach(SimProfileBase sim in _regionmanager.SimProfiles.Values) { | 167 | { |
147 | string SimResponse=""; | 168 | foreach (SimProfileBase sim in m_simProfileManager.SimProfiles.Values) |
148 | try { | 169 | { |
149 | WebRequest CheckSim = WebRequest.Create("http://" + sim.sim_ip + ":" + sim.sim_port.ToString() + "/checkstatus/"); | 170 | string SimResponse = ""; |
150 | CheckSim.Method = "GET"; | 171 | try |
151 | CheckSim.ContentType = "text/plaintext"; | 172 | { |
152 | CheckSim.ContentLength = 0; | 173 | WebRequest CheckSim = WebRequest.Create("http://" + sim.sim_ip + ":" + sim.sim_port.ToString() + "/checkstatus/"); |
153 | 174 | CheckSim.Method = "GET"; | |
154 | StreamWriter stOut = new StreamWriter(CheckSim.GetRequestStream(), System.Text.Encoding.ASCII); | 175 | CheckSim.ContentType = "text/plaintext"; |
155 | stOut.Write(""); | 176 | CheckSim.ContentLength = 0; |
156 | stOut.Close(); | 177 | |
157 | 178 | StreamWriter stOut = new StreamWriter(CheckSim.GetRequestStream(), System.Text.Encoding.ASCII); | |
158 | StreamReader stIn = new StreamReader(CheckSim.GetResponse().GetResponseStream()); | 179 | stOut.Write(""); |
159 | SimResponse = stIn.ReadToEnd(); | 180 | stOut.Close(); |
160 | stIn.Close(); | 181 | |
161 | } catch(Exception exception) { | 182 | StreamReader stIn = new StreamReader(CheckSim.GetResponse().GetResponseStream()); |
162 | } | 183 | SimResponse = stIn.ReadToEnd(); |
163 | if(SimResponse=="OK") { | 184 | stIn.Close(); |
164 | _regionmanager.SimProfiles[sim.UUID].online=true; | 185 | } |
165 | } else { | 186 | catch |
166 | _regionmanager.SimProfiles[sim.UUID].online=false; | 187 | { |
167 | } | 188 | } |
168 | } | 189 | |
169 | } | 190 | if (SimResponse == "OK") |
170 | 191 | { | |
171 | public void RunCmd(string cmd, string[] cmdparams) | 192 | m_simProfileManager.SimProfiles[sim.UUID].online = true; |
193 | } | ||
194 | else | ||
195 | { | ||
196 | m_simProfileManager.SimProfiles[sim.UUID].online = false; | ||
197 | } | ||
198 | } | ||
199 | } | ||
200 | |||
201 | public void RunCmd(string cmd, string[] cmdparams) | ||
172 | { | 202 | { |
173 | switch (cmd) | 203 | switch (cmd) |
174 | { | 204 | { |