diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs | 208 |
1 files changed, 186 insertions, 22 deletions
diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs index 39c0584..711639f 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs | |||
@@ -38,6 +38,7 @@ using System.Xml.Serialization; | |||
38 | using System.Collections.Generic; | 38 | using System.Collections.Generic; |
39 | using OpenSim.Server.Base; | 39 | using OpenSim.Server.Base; |
40 | using OpenSim.Services.Interfaces; | 40 | using OpenSim.Services.Interfaces; |
41 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
41 | using OpenSim.Framework; | 42 | using OpenSim.Framework; |
42 | using OpenSim.Framework.Servers.HttpServer; | 43 | using OpenSim.Framework.Servers.HttpServer; |
43 | using OpenMetaverse; | 44 | using OpenMetaverse; |
@@ -62,7 +63,10 @@ namespace OpenSim.Server.Handlers.Grid | |||
62 | StreamReader sr = new StreamReader(requestData); | 63 | StreamReader sr = new StreamReader(requestData); |
63 | string body = sr.ReadToEnd(); | 64 | string body = sr.ReadToEnd(); |
64 | sr.Close(); | 65 | sr.Close(); |
65 | 66 | body = body.Trim(); | |
67 | |||
68 | //m_log.DebugFormat("[XXX]: query String: {0}", body); | ||
69 | |||
66 | Dictionary<string, string> request = | 70 | Dictionary<string, string> request = |
67 | ServerUtils.ParseQueryString(body); | 71 | ServerUtils.ParseQueryString(body); |
68 | 72 | ||
@@ -97,11 +101,11 @@ namespace OpenSim.Server.Handlers.Grid | |||
97 | case "get_region_range": | 101 | case "get_region_range": |
98 | return GetRegionRange(request); | 102 | return GetRegionRange(request); |
99 | 103 | ||
100 | default: | ||
101 | m_log.DebugFormat("[GRID HANDLER]: unknown method request {0}", method); | ||
102 | return FailureResult(); | ||
103 | } | 104 | } |
104 | 105 | ||
106 | m_log.DebugFormat("[GRID HANDLER]: unknown method {0} request {1}", method.Length, method); | ||
107 | return FailureResult(); | ||
108 | |||
105 | } | 109 | } |
106 | 110 | ||
107 | #region Method-specific handlers | 111 | #region Method-specific handlers |
@@ -117,7 +121,7 @@ namespace OpenSim.Server.Handlers.Grid | |||
117 | Dictionary<string, object> rinfoData = new Dictionary<string, object>(); | 121 | Dictionary<string, object> rinfoData = new Dictionary<string, object>(); |
118 | foreach (KeyValuePair<string, string> kvp in request) | 122 | foreach (KeyValuePair<string, string> kvp in request) |
119 | rinfoData[kvp.Key] = kvp.Value; | 123 | rinfoData[kvp.Key] = kvp.Value; |
120 | SimpleRegionInfo rinfo = new SimpleRegionInfo(rinfoData); | 124 | GridRegion rinfo = new GridRegion(rinfoData); |
121 | 125 | ||
122 | bool result = m_GridService.RegisterRegion(scopeID, rinfo); | 126 | bool result = m_GridService.RegisterRegion(scopeID, rinfo); |
123 | 127 | ||
@@ -154,22 +158,29 @@ namespace OpenSim.Server.Handlers.Grid | |||
154 | 158 | ||
155 | UUID regionID = UUID.Zero; | 159 | UUID regionID = UUID.Zero; |
156 | if (request["REGIONID"] != null) | 160 | if (request["REGIONID"] != null) |
157 | UUID.TryParse(request["REGIONID"], out scopeID); | 161 | UUID.TryParse(request["REGIONID"], out regionID); |
158 | else | 162 | else |
159 | m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours"); | 163 | m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours"); |
160 | 164 | ||
161 | List<SimpleRegionInfo> rinfos = m_GridService.GetNeighbours(scopeID, regionID); | 165 | List<GridRegion> rinfos = m_GridService.GetNeighbours(scopeID, regionID); |
166 | //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); | ||
162 | 167 | ||
163 | Dictionary<string, object> result = new Dictionary<string, object>(); | 168 | Dictionary<string, object> result = new Dictionary<string, object>(); |
164 | int i = 0; | 169 | if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0))) |
165 | foreach (SimpleRegionInfo rinfo in rinfos) | 170 | result["result"] = "null"; |
171 | else | ||
166 | { | 172 | { |
167 | Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs(); | 173 | int i = 0; |
168 | result["region" + i] = rinfoDict; | 174 | foreach (GridRegion rinfo in rinfos) |
169 | i++; | 175 | { |
176 | Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs(); | ||
177 | result["region" + i] = rinfoDict; | ||
178 | i++; | ||
179 | } | ||
170 | } | 180 | } |
171 | 181 | ||
172 | string xmlString = ServerUtils.BuildXmlResponse(result); | 182 | string xmlString = ServerUtils.BuildXmlResponse(result); |
183 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | ||
173 | UTF8Encoding encoding = new UTF8Encoding(); | 184 | UTF8Encoding encoding = new UTF8Encoding(); |
174 | return encoding.GetBytes(xmlString); | 185 | return encoding.GetBytes(xmlString); |
175 | 186 | ||
@@ -177,32 +188,185 @@ namespace OpenSim.Server.Handlers.Grid | |||
177 | 188 | ||
178 | byte[] GetRegionByUUID(Dictionary<string, string> request) | 189 | byte[] GetRegionByUUID(Dictionary<string, string> request) |
179 | { | 190 | { |
180 | // TODO | 191 | UUID scopeID = UUID.Zero; |
181 | return new byte[0]; | 192 | if (request["SCOPEID"] != null) |
193 | UUID.TryParse(request["SCOPEID"], out scopeID); | ||
194 | else | ||
195 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours"); | ||
196 | |||
197 | UUID regionID = UUID.Zero; | ||
198 | if (request["REGIONID"] != null) | ||
199 | UUID.TryParse(request["REGIONID"], out regionID); | ||
200 | else | ||
201 | m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours"); | ||
202 | |||
203 | GridRegion rinfo = m_GridService.GetRegionByUUID(scopeID, regionID); | ||
204 | //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); | ||
205 | |||
206 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
207 | if (rinfo == null) | ||
208 | result["result"] = "null"; | ||
209 | else | ||
210 | result["result"] = rinfo.ToKeyValuePairs(); | ||
211 | |||
212 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
213 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | ||
214 | UTF8Encoding encoding = new UTF8Encoding(); | ||
215 | return encoding.GetBytes(xmlString); | ||
182 | } | 216 | } |
183 | 217 | ||
184 | byte[] GetRegionByPosition(Dictionary<string, string> request) | 218 | byte[] GetRegionByPosition(Dictionary<string, string> request) |
185 | { | 219 | { |
186 | // TODO | 220 | UUID scopeID = UUID.Zero; |
187 | return new byte[0]; | 221 | if (request["SCOPEID"] != null) |
222 | UUID.TryParse(request["SCOPEID"], out scopeID); | ||
223 | else | ||
224 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by position"); | ||
225 | |||
226 | int x = 0, y = 0; | ||
227 | if (request["X"] != null) | ||
228 | Int32.TryParse(request["X"], out x); | ||
229 | else | ||
230 | m_log.WarnFormat("[GRID HANDLER]: no X in request to get region by position"); | ||
231 | if (request["Y"] != null) | ||
232 | Int32.TryParse(request["Y"], out y); | ||
233 | else | ||
234 | m_log.WarnFormat("[GRID HANDLER]: no Y in request to get region by position"); | ||
235 | |||
236 | GridRegion rinfo = m_GridService.GetRegionByPosition(scopeID, x, y); | ||
237 | //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); | ||
238 | |||
239 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
240 | if (rinfo == null) | ||
241 | result["result"] = "null"; | ||
242 | else | ||
243 | result["result"] = rinfo.ToKeyValuePairs(); | ||
244 | |||
245 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
246 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | ||
247 | UTF8Encoding encoding = new UTF8Encoding(); | ||
248 | return encoding.GetBytes(xmlString); | ||
188 | } | 249 | } |
189 | 250 | ||
190 | byte[] GetRegionByName(Dictionary<string, string> request) | 251 | byte[] GetRegionByName(Dictionary<string, string> request) |
191 | { | 252 | { |
192 | // TODO | 253 | UUID scopeID = UUID.Zero; |
193 | return new byte[0]; | 254 | if (request["SCOPEID"] != null) |
255 | UUID.TryParse(request["SCOPEID"], out scopeID); | ||
256 | else | ||
257 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by name"); | ||
258 | |||
259 | string regionName = string.Empty; | ||
260 | if (request["NAME"] != null) | ||
261 | regionName = request["NAME"]; | ||
262 | else | ||
263 | m_log.WarnFormat("[GRID HANDLER]: no name in request to get region by name"); | ||
264 | |||
265 | GridRegion rinfo = m_GridService.GetRegionByName(scopeID, regionName); | ||
266 | //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); | ||
267 | |||
268 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
269 | if (rinfo == null) | ||
270 | result["result"] = "null"; | ||
271 | else | ||
272 | result["result"] = rinfo.ToKeyValuePairs(); | ||
273 | |||
274 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
275 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | ||
276 | UTF8Encoding encoding = new UTF8Encoding(); | ||
277 | return encoding.GetBytes(xmlString); | ||
194 | } | 278 | } |
195 | 279 | ||
196 | byte[] GetRegionsByName(Dictionary<string, string> request) | 280 | byte[] GetRegionsByName(Dictionary<string, string> request) |
197 | { | 281 | { |
198 | // TODO | 282 | UUID scopeID = UUID.Zero; |
199 | return new byte[0]; | 283 | if (request["SCOPEID"] != null) |
284 | UUID.TryParse(request["SCOPEID"], out scopeID); | ||
285 | else | ||
286 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get regions by name"); | ||
287 | |||
288 | string regionName = string.Empty; | ||
289 | if (request["NAME"] != null) | ||
290 | regionName = request["NAME"]; | ||
291 | else | ||
292 | m_log.WarnFormat("[GRID HANDLER]: no NAME in request to get regions by name"); | ||
293 | |||
294 | int max = 0; | ||
295 | if (request["MAX"] != null) | ||
296 | Int32.TryParse(request["MAX"], out max); | ||
297 | else | ||
298 | m_log.WarnFormat("[GRID HANDLER]: no MAX in request to get regions by name"); | ||
299 | |||
300 | List<GridRegion> rinfos = m_GridService.GetRegionsByName(scopeID, regionName, max); | ||
301 | //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); | ||
302 | |||
303 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
304 | if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0))) | ||
305 | result["result"] = "null"; | ||
306 | else | ||
307 | { | ||
308 | int i = 0; | ||
309 | foreach (GridRegion rinfo in rinfos) | ||
310 | { | ||
311 | Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs(); | ||
312 | result["region" + i] = rinfoDict; | ||
313 | i++; | ||
314 | } | ||
315 | } | ||
316 | |||
317 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
318 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | ||
319 | UTF8Encoding encoding = new UTF8Encoding(); | ||
320 | return encoding.GetBytes(xmlString); | ||
200 | } | 321 | } |
201 | 322 | ||
202 | byte[] GetRegionRange(Dictionary<string, string> request) | 323 | byte[] GetRegionRange(Dictionary<string, string> request) |
203 | { | 324 | { |
204 | // TODO | 325 | //m_log.DebugFormat("[GRID HANDLER]: GetRegionRange"); |
205 | return new byte[0]; | 326 | UUID scopeID = UUID.Zero; |
327 | if (request.ContainsKey("SCOPEID")) | ||
328 | UUID.TryParse(request["SCOPEID"], out scopeID); | ||
329 | else | ||
330 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region range"); | ||
331 | |||
332 | int xmin = 0, xmax = 0, ymin = 0, ymax = 0; | ||
333 | if (request.ContainsKey("XMIN")) | ||
334 | Int32.TryParse(request["XMIN"], out xmin); | ||
335 | else | ||
336 | m_log.WarnFormat("[GRID HANDLER]: no XMIN in request to get region range"); | ||
337 | if (request.ContainsKey("XMAX")) | ||
338 | Int32.TryParse(request["XMAX"], out xmax); | ||
339 | else | ||
340 | m_log.WarnFormat("[GRID HANDLER]: no XMAX in request to get region range"); | ||
341 | if (request.ContainsKey("YMIN")) | ||
342 | Int32.TryParse(request["YMIN"], out ymin); | ||
343 | else | ||
344 | m_log.WarnFormat("[GRID HANDLER]: no YMIN in request to get region range"); | ||
345 | if (request.ContainsKey("YMAX")) | ||
346 | Int32.TryParse(request["YMAX"], out ymax); | ||
347 | else | ||
348 | m_log.WarnFormat("[GRID HANDLER]: no YMAX in request to get region range"); | ||
349 | |||
350 | |||
351 | List<GridRegion> rinfos = m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax); | ||
352 | |||
353 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
354 | if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0))) | ||
355 | result["result"] = "null"; | ||
356 | else | ||
357 | { | ||
358 | int i = 0; | ||
359 | foreach (GridRegion rinfo in rinfos) | ||
360 | { | ||
361 | Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs(); | ||
362 | result["region" + i] = rinfoDict; | ||
363 | i++; | ||
364 | } | ||
365 | } | ||
366 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
367 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | ||
368 | UTF8Encoding encoding = new UTF8Encoding(); | ||
369 | return encoding.GetBytes(xmlString); | ||
206 | } | 370 | } |
207 | 371 | ||
208 | #endregion | 372 | #endregion |