diff options
Diffstat (limited to '')
-rw-r--r-- | OpenGridServices.GridServer/Main.cs | 7 | ||||
-rw-r--r-- | OpenGridServices.GridServer/SimProfiles.cs | 128 | ||||
-rw-r--r-- | OpenSim.RegionServer/RegionInfo.cs | 14 |
3 files changed, 71 insertions, 78 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; |
diff --git a/OpenSim.RegionServer/RegionInfo.cs b/OpenSim.RegionServer/RegionInfo.cs index 1256b50..9958f1a 100644 --- a/OpenSim.RegionServer/RegionInfo.cs +++ b/OpenSim.RegionServer/RegionInfo.cs | |||
@@ -54,19 +54,23 @@ namespace OpenSim | |||
54 | reqtext += "<region_locy>" + this.RegionLocY.ToString() + "</region_locy>"; | 54 | reqtext += "<region_locy>" + this.RegionLocY.ToString() + "</region_locy>"; |
55 | reqtext += "<estate_id>1</estate_id>"; | 55 | reqtext += "<estate_id>1</estate_id>"; |
56 | reqtext += "</sim>"; | 56 | reqtext += "</sim>"; |
57 | |||
58 | byte[] reqdata = (new System.Text.ASCIIEncoding()).GetBytes(reqtext); | ||
57 | 59 | ||
58 | WebRequest GridSaveReq = WebRequest.Create(this.GridURL + "sims/" + this.SimUUID.ToString()); | 60 | WebRequest GridSaveReq = WebRequest.Create(this.GridURL + "sims/" + this.SimUUID.ToString()); |
59 | GridSaveReq.Method = "POST"; | 61 | GridSaveReq.Method = "POST"; |
60 | GridSaveReq.ContentType = "text/plaintext"; | 62 | GridSaveReq.ContentType = "application/x-www-form-urlencoded"; |
61 | GridSaveReq.ContentLength = reqtext.Length; | 63 | GridSaveReq.ContentLength = reqdata.Length; |
62 | 64 | ||
63 | StreamWriter stOut = new StreamWriter(GridSaveReq.GetRequestStream(), System.Text.Encoding.ASCII); | 65 | Stream stOut = GridSaveReq.GetRequestStream(); |
64 | stOut.Write(reqtext); | 66 | stOut.Write(reqdata,0,reqdata.Length); |
65 | stOut.Close(); | 67 | stOut.Close(); |
66 | 68 | ||
67 | StreamReader stIn = new StreamReader(GridSaveReq.GetResponse().GetResponseStream()); | 69 | WebResponse gridresp = GridSaveReq.GetResponse(); |
70 | StreamReader stIn = new StreamReader(gridresp.GetResponseStream()); | ||
68 | string GridResponse = stIn.ReadToEnd(); | 71 | string GridResponse = stIn.ReadToEnd(); |
69 | stIn.Close(); | 72 | stIn.Close(); |
73 | gridresp.Close(); | ||
70 | 74 | ||
71 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("RegionInfo.CS:SaveToGrid() - Grid said: " + GridResponse); | 75 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("RegionInfo.CS:SaveToGrid() - Grid said: " + GridResponse); |
72 | } | 76 | } |