diff options
author | Diva Canto | 2009-09-24 15:30:00 -0700 |
---|---|---|
committer | Diva Canto | 2009-09-24 15:30:00 -0700 |
commit | 1faaa0a43a851c44af40336336ddbe3a7dbe83af (patch) | |
tree | ab1ec0d0238fc64b9538c9ecd6d55c71c665de5b /OpenSim/Server/Handlers/Grid | |
parent | Added test GridClient, which allowed me to remove a few bugs out of the new c... (diff) | |
download | opensim-SC-1faaa0a43a851c44af40336336ddbe3a7dbe83af.zip opensim-SC-1faaa0a43a851c44af40336336ddbe3a7dbe83af.tar.gz opensim-SC-1faaa0a43a851c44af40336336ddbe3a7dbe83af.tar.bz2 opensim-SC-1faaa0a43a851c44af40336336ddbe3a7dbe83af.tar.xz |
GridServerPostHandler finished. GridClient tests all work. More guards on getting parameters and replies over the wire.
Diffstat (limited to 'OpenSim/Server/Handlers/Grid')
-rw-r--r-- | OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs | 187 |
1 files changed, 172 insertions, 15 deletions
diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs index eaeed6f..f50e6a2 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs | |||
@@ -164,12 +164,17 @@ namespace OpenSim.Server.Handlers.Grid | |||
164 | //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); | 164 | //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); |
165 | 165 | ||
166 | Dictionary<string, object> result = new Dictionary<string, object>(); | 166 | Dictionary<string, object> result = new Dictionary<string, object>(); |
167 | int i = 0; | 167 | if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0))) |
168 | foreach (GridRegion rinfo in rinfos) | 168 | result["result"] = "null"; |
169 | else | ||
169 | { | 170 | { |
170 | Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs(); | 171 | int i = 0; |
171 | result["region" + i] = rinfoDict; | 172 | foreach (GridRegion rinfo in rinfos) |
172 | i++; | 173 | { |
174 | Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs(); | ||
175 | result["region" + i] = rinfoDict; | ||
176 | i++; | ||
177 | } | ||
173 | } | 178 | } |
174 | 179 | ||
175 | string xmlString = ServerUtils.BuildXmlResponse(result); | 180 | string xmlString = ServerUtils.BuildXmlResponse(result); |
@@ -181,32 +186,184 @@ namespace OpenSim.Server.Handlers.Grid | |||
181 | 186 | ||
182 | byte[] GetRegionByUUID(Dictionary<string, string> request) | 187 | byte[] GetRegionByUUID(Dictionary<string, string> request) |
183 | { | 188 | { |
184 | // TODO | 189 | UUID scopeID = UUID.Zero; |
185 | return new byte[0]; | 190 | if (request["SCOPEID"] != null) |
191 | UUID.TryParse(request["SCOPEID"], out scopeID); | ||
192 | else | ||
193 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours"); | ||
194 | |||
195 | UUID regionID = UUID.Zero; | ||
196 | if (request["REGIONID"] != null) | ||
197 | UUID.TryParse(request["REGIONID"], out regionID); | ||
198 | else | ||
199 | m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours"); | ||
200 | |||
201 | GridRegion rinfo = m_GridService.GetRegionByUUID(scopeID, regionID); | ||
202 | //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); | ||
203 | |||
204 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
205 | if (rinfo == null) | ||
206 | result["result"] = "null"; | ||
207 | else | ||
208 | result["result"] = rinfo.ToKeyValuePairs(); | ||
209 | |||
210 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
211 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | ||
212 | UTF8Encoding encoding = new UTF8Encoding(); | ||
213 | return encoding.GetBytes(xmlString); | ||
186 | } | 214 | } |
187 | 215 | ||
188 | byte[] GetRegionByPosition(Dictionary<string, string> request) | 216 | byte[] GetRegionByPosition(Dictionary<string, string> request) |
189 | { | 217 | { |
190 | // TODO | 218 | UUID scopeID = UUID.Zero; |
191 | return new byte[0]; | 219 | if (request["SCOPEID"] != null) |
220 | UUID.TryParse(request["SCOPEID"], out scopeID); | ||
221 | else | ||
222 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by position"); | ||
223 | |||
224 | int x = 0, y = 0; | ||
225 | if (request["X"] != null) | ||
226 | Int32.TryParse(request["X"], out x); | ||
227 | else | ||
228 | m_log.WarnFormat("[GRID HANDLER]: no X in request to get region by position"); | ||
229 | if (request["Y"] != null) | ||
230 | Int32.TryParse(request["Y"], out y); | ||
231 | else | ||
232 | m_log.WarnFormat("[GRID HANDLER]: no Y in request to get region by position"); | ||
233 | |||
234 | GridRegion rinfo = m_GridService.GetRegionByPosition(scopeID, x, y); | ||
235 | //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); | ||
236 | |||
237 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
238 | if (rinfo == null) | ||
239 | result["result"] = "null"; | ||
240 | else | ||
241 | result["result"] = rinfo.ToKeyValuePairs(); | ||
242 | |||
243 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
244 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | ||
245 | UTF8Encoding encoding = new UTF8Encoding(); | ||
246 | return encoding.GetBytes(xmlString); | ||
192 | } | 247 | } |
193 | 248 | ||
194 | byte[] GetRegionByName(Dictionary<string, string> request) | 249 | byte[] GetRegionByName(Dictionary<string, string> request) |
195 | { | 250 | { |
196 | // TODO | 251 | UUID scopeID = UUID.Zero; |
197 | return new byte[0]; | 252 | if (request["SCOPEID"] != null) |
253 | UUID.TryParse(request["SCOPEID"], out scopeID); | ||
254 | else | ||
255 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by name"); | ||
256 | |||
257 | string regionName = string.Empty; | ||
258 | if (request["NAME"] != null) | ||
259 | regionName = request["NAME"]; | ||
260 | else | ||
261 | m_log.WarnFormat("[GRID HANDLER]: no name in request to get region by name"); | ||
262 | |||
263 | GridRegion rinfo = m_GridService.GetRegionByName(scopeID, regionName); | ||
264 | //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); | ||
265 | |||
266 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
267 | if (rinfo == null) | ||
268 | result["result"] = "null"; | ||
269 | else | ||
270 | result["result"] = rinfo.ToKeyValuePairs(); | ||
271 | |||
272 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
273 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | ||
274 | UTF8Encoding encoding = new UTF8Encoding(); | ||
275 | return encoding.GetBytes(xmlString); | ||
198 | } | 276 | } |
199 | 277 | ||
200 | byte[] GetRegionsByName(Dictionary<string, string> request) | 278 | byte[] GetRegionsByName(Dictionary<string, string> request) |
201 | { | 279 | { |
202 | // TODO | 280 | UUID scopeID = UUID.Zero; |
203 | return new byte[0]; | 281 | if (request["SCOPEID"] != null) |
282 | UUID.TryParse(request["SCOPEID"], out scopeID); | ||
283 | else | ||
284 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get regions by name"); | ||
285 | |||
286 | string regionName = string.Empty; | ||
287 | if (request["NAME"] != null) | ||
288 | regionName = request["NAME"]; | ||
289 | else | ||
290 | m_log.WarnFormat("[GRID HANDLER]: no NAME in request to get regions by name"); | ||
291 | |||
292 | int max = 0; | ||
293 | if (request["MAX"] != null) | ||
294 | Int32.TryParse(request["MAX"], out max); | ||
295 | else | ||
296 | m_log.WarnFormat("[GRID HANDLER]: no MAX in request to get regions by name"); | ||
297 | |||
298 | List<GridRegion> rinfos = m_GridService.GetRegionsByName(scopeID, regionName, max); | ||
299 | //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); | ||
300 | |||
301 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
302 | if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0))) | ||
303 | result["result"] = "null"; | ||
304 | else | ||
305 | { | ||
306 | int i = 0; | ||
307 | foreach (GridRegion rinfo in rinfos) | ||
308 | { | ||
309 | Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs(); | ||
310 | result["region" + i] = rinfoDict; | ||
311 | i++; | ||
312 | } | ||
313 | } | ||
314 | |||
315 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
316 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | ||
317 | UTF8Encoding encoding = new UTF8Encoding(); | ||
318 | return encoding.GetBytes(xmlString); | ||
204 | } | 319 | } |
205 | 320 | ||
206 | byte[] GetRegionRange(Dictionary<string, string> request) | 321 | byte[] GetRegionRange(Dictionary<string, string> request) |
207 | { | 322 | { |
208 | // TODO | 323 | UUID scopeID = UUID.Zero; |
209 | return new byte[0]; | 324 | if (request["SCOPEID"] != null) |
325 | UUID.TryParse(request["SCOPEID"], out scopeID); | ||
326 | else | ||
327 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region range"); | ||
328 | |||
329 | int xmin = 0, xmax = 0, ymin = 0, ymax = 0; | ||
330 | if (request["XMIN"] != null) | ||
331 | Int32.TryParse(request["XMIN"], out xmin); | ||
332 | else | ||
333 | m_log.WarnFormat("[GRID HANDLER]: no XMIN in request to get region range"); | ||
334 | if (request["XMAX"] != null) | ||
335 | Int32.TryParse(request["XMAX"], out xmax); | ||
336 | else | ||
337 | m_log.WarnFormat("[GRID HANDLER]: no XMAX in request to get region range"); | ||
338 | if (request["YMIN"] != null) | ||
339 | Int32.TryParse(request["YMIN"], out ymin); | ||
340 | else | ||
341 | m_log.WarnFormat("[GRID HANDLER]: no YMIN in request to get region range"); | ||
342 | if (request["YMAX"] != null) | ||
343 | Int32.TryParse(request["YMAX"], out ymax); | ||
344 | else | ||
345 | m_log.WarnFormat("[GRID HANDLER]: no YMAX in request to get region range"); | ||
346 | |||
347 | |||
348 | List<GridRegion> rinfos = m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax); | ||
349 | |||
350 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
351 | if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0))) | ||
352 | result["result"] = "null"; | ||
353 | else | ||
354 | { | ||
355 | int i = 0; | ||
356 | foreach (GridRegion rinfo in rinfos) | ||
357 | { | ||
358 | Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs(); | ||
359 | result["region" + i] = rinfoDict; | ||
360 | i++; | ||
361 | } | ||
362 | } | ||
363 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
364 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | ||
365 | UTF8Encoding encoding = new UTF8Encoding(); | ||
366 | return encoding.GetBytes(xmlString); | ||
210 | } | 367 | } |
211 | 368 | ||
212 | #endregion | 369 | #endregion |