diff options
author | gareth | 2007-04-12 18:34:17 +0000 |
---|---|---|
committer | gareth | 2007-04-12 18:34:17 +0000 |
commit | cc53580ba4bb688baf75159d728c03ccfc568aec (patch) | |
tree | 2a1d54583252d3a056e54cb4ed6bf33743aadb99 /OpenGridServices.GridServer | |
parent | * Replaced GridHTTPServer and UserHTTPServer with BaseHttpServer (diff) | |
download | opensim-SC-cc53580ba4bb688baf75159d728c03ccfc568aec.zip opensim-SC-cc53580ba4bb688baf75159d728c03ccfc568aec.tar.gz opensim-SC-cc53580ba4bb688baf75159d728c03ccfc568aec.tar.bz2 opensim-SC-cc53580ba4bb688baf75159d728c03ccfc568aec.tar.xz |
aaaaaaarrrrrrrrrggggghhhhhhhh why oh why?
Diffstat (limited to 'OpenGridServices.GridServer')
-rw-r--r-- | OpenGridServices.GridServer/Main.cs | 7 | ||||
-rw-r--r-- | OpenGridServices.GridServer/SimProfiles.cs | 128 |
2 files changed, 62 insertions, 73 deletions
diff --git a/OpenGridServices.GridServer/Main.cs b/OpenGridServices.GridServer/Main.cs index 5827227..c69b6dc 100644 --- a/OpenGridServices.GridServer/Main.cs +++ b/OpenGridServices.GridServer/Main.cs | |||
@@ -109,8 +109,11 @@ namespace OpenGridServices.GridServer | |||
109 | 109 | ||
110 | httpServer.AddXmlRPCHandler("simulator_login", m_simProfileManager.XmlRpcLoginToSimulatorMethod); | 110 | httpServer.AddXmlRPCHandler("simulator_login", m_simProfileManager.XmlRpcLoginToSimulatorMethod); |
111 | 111 | ||
112 | httpServer.AddRestHandler("GET", "/sims/", m_simProfileManager.RestGetSimMethod); | 112 | httpServer.AddRestHandler("GET", "/sims", m_simProfileManager.RestGetSimMethod); |
113 | httpServer.AddRestHandler("POST", "/sims/", m_simProfileManager.RestSetSimMethod); | 113 | httpServer.AddRestHandler("POST", "/sims", m_simProfileManager.RestSetSimMethod); |
114 | httpServer.AddRestHandler("GET", "/regions", m_simProfileManager.RestGetRegionMethod); | ||
115 | httpServer.AddRestHandler("POST", "/regions", m_simProfileManager.RestSetRegionMethod); | ||
116 | |||
114 | 117 | ||
115 | // lbsa71 : This code snippet taken from old http server. | 118 | // lbsa71 : This code snippet taken from old http server. |
116 | // I have no idea what this was supposed to do - looks like an infinite recursion to me. | 119 | // I have no idea what this was supposed to do - looks like an infinite recursion to me. |
diff --git a/OpenGridServices.GridServer/SimProfiles.cs b/OpenGridServices.GridServer/SimProfiles.cs index fd4ba99..9e93db0 100644 --- a/OpenGridServices.GridServer/SimProfiles.cs +++ b/OpenGridServices.GridServer/SimProfiles.cs | |||
@@ -186,85 +186,71 @@ namespace OpenGridServices.GridServer | |||
186 | 186 | ||
187 | public string RestSetSimMethod(string request, string path, string param) | 187 | public string RestSetSimMethod(string request, string path, string param) |
188 | { | 188 | { |
189 | string respstring = String.Empty; | 189 | Console.WriteLine("SimProfiles.cs:RestSetSimMethod() - processing request......"); |
190 | |||
191 | SimProfileBase TheSim; | 190 | SimProfileBase TheSim; |
192 | LLUUID UUID = new LLUUID(param); | 191 | LLUUID UUID = new LLUUID(param); |
193 | TheSim = GetProfileByLLUUID(UUID); | 192 | TheSim = GetProfileByLLUUID(UUID); |
194 | 193 | if ((TheSim) == null) TheSim = new SimProfileBase(); | |
195 | if (!(TheSim == null)) | 194 | |
196 | { | 195 | XmlDocument doc = new XmlDocument(); |
197 | Console.WriteLine("Updating sim details....."); | 196 | doc.LoadXml(request); |
198 | XmlDocument doc = new XmlDocument(); | 197 | XmlNode authkeynode = doc.FirstChild; |
199 | doc.LoadXml(request); | 198 | if (authkeynode.Name != "authkey") |
200 | XmlNode authkeynode = doc.FirstChild; | ||
201 | if (authkeynode.Name != "authkey") | ||
202 | { | 199 | { |
203 | respstring = "ERROR! bad XML - expected authkey tag"; | 200 | return "ERROR! bad XML - expected authkey tag"; |
204 | } | 201 | } |
205 | else | ||
206 | { | ||
207 | XmlNode simnode = doc.ChildNodes[1]; | ||
208 | if (simnode.Name != "sim") | ||
209 | { | ||
210 | respstring = "ERROR! bad XML - expected sim tag"; | ||
211 | } | ||
212 | else | ||
213 | { | ||
214 | if (authkeynode.Name != m_gridManager.SimRecvKey) | ||
215 | { | ||
216 | respstring = "ERROR! invalid key"; | ||
217 | } | ||
218 | else | ||
219 | { | ||
220 | if (TheSim == null) | ||
221 | { | ||
222 | respstring = "ERROR! sim not found"; | ||
223 | } | ||
224 | else | ||
225 | { | ||
226 | for (int i = 0; i <= simnode.ChildNodes.Count; i++) | ||
227 | { | ||
228 | switch (simnode.ChildNodes[i].Name) | ||
229 | { | ||
230 | case "uuid": | ||
231 | // should a sim be able to update it's own UUID? To be decided | ||
232 | // watch next week for the exciting conclusion in "the adventures of OpenGridServices.GridServer/GridHttp.cs:ParseREST() at line 190! | ||
233 | break; // and line 190's arch-enemy - THE BREAK STATEMENT! OH NOES!!!!! (this code written at 6:57AM, no sleep, lots of caffeine) | ||
234 | |||
235 | case "regionname": | ||
236 | TheSim.regionname = simnode.ChildNodes[i].InnerText; | ||
237 | break; | ||
238 | 202 | ||
239 | case "sim_ip": | 203 | XmlNode simnode = doc.ChildNodes[1]; |
240 | TheSim.sim_ip = simnode.ChildNodes[i].InnerText; | 204 | if (simnode.Name != "sim") |
241 | break; | 205 | { |
242 | 206 | return "ERROR! bad XML - expected sim tag"; | |
243 | case "sim_port": | ||
244 | TheSim.sim_port = Convert.ToUInt32(simnode.ChildNodes[i].InnerText); | ||
245 | break; | ||
246 | |||
247 | case "region_locx": | ||
248 | TheSim.RegionLocX = Convert.ToUInt32((string)simnode.ChildNodes[i].InnerText); | ||
249 | TheSim.regionhandle = Helpers.UIntsToLong((TheSim.RegionLocX * 256), (TheSim.RegionLocY * 256)); | ||
250 | break; | ||
251 | |||
252 | case "region_locy": | ||
253 | TheSim.RegionLocY = Convert.ToUInt32((string)simnode.ChildNodes[i].InnerText); | ||
254 | TheSim.regionhandle = Helpers.UIntsToLong((TheSim.RegionLocX * 256), (TheSim.RegionLocY * 256)); | ||
255 | break; | ||
256 | } | ||
257 | } | ||
258 | respstring = "OK"; | ||
259 | } | ||
260 | } | ||
261 | } | ||
262 | } | 207 | } |
263 | } | 208 | |
264 | 209 | if (authkeynode.InnerText != m_gridManager.SimRecvKey) | |
265 | return respstring; | 210 | { |
211 | return "ERROR! invalid key"; | ||
212 | } | ||
213 | |||
214 | for (int i = 0; i <= simnode.ChildNodes.Count; i++) { | ||
215 | switch (simnode.ChildNodes[i].Name) { | ||
216 | case "regionname": | ||
217 | TheSim.regionname = simnode.ChildNodes[i].InnerText; | ||
218 | break; | ||
219 | |||
220 | case "sim_ip": | ||
221 | TheSim.sim_ip = simnode.ChildNodes[i].InnerText; | ||
222 | break; | ||
223 | |||
224 | case "sim_port": | ||
225 | TheSim.sim_port = Convert.ToUInt32(simnode.ChildNodes[i].InnerText); | ||
226 | break; | ||
227 | |||
228 | case "region_locx": | ||
229 | TheSim.RegionLocX = Convert.ToUInt32((string)simnode.ChildNodes[i].InnerText); | ||
230 | TheSim.regionhandle = Helpers.UIntsToLong((TheSim.RegionLocX * 256), (TheSim.RegionLocY * 256)); | ||
231 | break; | ||
232 | |||
233 | case "region_locy": | ||
234 | TheSim.RegionLocY = Convert.ToUInt32((string)simnode.ChildNodes[i].InnerText); | ||
235 | TheSim.regionhandle = Helpers.UIntsToLong((TheSim.RegionLocX * 256), (TheSim.RegionLocY * 256)); | ||
236 | break; | ||
237 | } | ||
238 | } | ||
239 | return "OK"; | ||
266 | } | 240 | } |
267 | 241 | ||
242 | public string RestGetRegionMethod(string request, string path, string param ) | ||
243 | { | ||
244 | SimProfileBase TheSim = GetProfileByHandle((ulong)Convert.ToUInt64(param)); | ||
245 | return RestGetSimMethod("", "/sims/", param); | ||
246 | } | ||
247 | |||
248 | public string RestSetRegionMethod(string request, string path, string param ) | ||
249 | { | ||
250 | SimProfileBase TheSim = GetProfileByHandle((ulong)Convert.ToUInt64(param)); | ||
251 | return RestSetSimMethod("", "/sims/", param); | ||
252 | } | ||
253 | |||
268 | public string RestGetSimMethod(string request, string path, string param ) | 254 | public string RestGetSimMethod(string request, string path, string param ) |
269 | { | 255 | { |
270 | string respstring = String.Empty; | 256 | string respstring = String.Empty; |