From 1faaa0a43a851c44af40336336ddbe3a7dbe83af Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 24 Sep 2009 15:30:00 -0700 Subject: GridServerPostHandler finished. GridClient tests all work. More guards on getting parameters and replies over the wire. --- .../Server/Handlers/Grid/GridServerPostHandler.cs | 187 +++++++++++++++++++-- 1 file changed, 172 insertions(+), 15 deletions(-) (limited to 'OpenSim/Server') 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 //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); Dictionary result = new Dictionary(); - int i = 0; - foreach (GridRegion rinfo in rinfos) + if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0))) + result["result"] = "null"; + else { - Dictionary rinfoDict = rinfo.ToKeyValuePairs(); - result["region" + i] = rinfoDict; - i++; + int i = 0; + foreach (GridRegion rinfo in rinfos) + { + Dictionary rinfoDict = rinfo.ToKeyValuePairs(); + result["region" + i] = rinfoDict; + i++; + } } string xmlString = ServerUtils.BuildXmlResponse(result); @@ -181,32 +186,184 @@ namespace OpenSim.Server.Handlers.Grid byte[] GetRegionByUUID(Dictionary request) { - // TODO - return new byte[0]; + UUID scopeID = UUID.Zero; + if (request["SCOPEID"] != null) + UUID.TryParse(request["SCOPEID"], out scopeID); + else + m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours"); + + UUID regionID = UUID.Zero; + if (request["REGIONID"] != null) + UUID.TryParse(request["REGIONID"], out regionID); + else + m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours"); + + GridRegion rinfo = m_GridService.GetRegionByUUID(scopeID, regionID); + //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); + + Dictionary result = new Dictionary(); + if (rinfo == null) + result["result"] = "null"; + else + result["result"] = rinfo.ToKeyValuePairs(); + + string xmlString = ServerUtils.BuildXmlResponse(result); + //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); + UTF8Encoding encoding = new UTF8Encoding(); + return encoding.GetBytes(xmlString); } byte[] GetRegionByPosition(Dictionary request) { - // TODO - return new byte[0]; + UUID scopeID = UUID.Zero; + if (request["SCOPEID"] != null) + UUID.TryParse(request["SCOPEID"], out scopeID); + else + m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by position"); + + int x = 0, y = 0; + if (request["X"] != null) + Int32.TryParse(request["X"], out x); + else + m_log.WarnFormat("[GRID HANDLER]: no X in request to get region by position"); + if (request["Y"] != null) + Int32.TryParse(request["Y"], out y); + else + m_log.WarnFormat("[GRID HANDLER]: no Y in request to get region by position"); + + GridRegion rinfo = m_GridService.GetRegionByPosition(scopeID, x, y); + //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); + + Dictionary result = new Dictionary(); + if (rinfo == null) + result["result"] = "null"; + else + result["result"] = rinfo.ToKeyValuePairs(); + + string xmlString = ServerUtils.BuildXmlResponse(result); + //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); + UTF8Encoding encoding = new UTF8Encoding(); + return encoding.GetBytes(xmlString); } byte[] GetRegionByName(Dictionary request) { - // TODO - return new byte[0]; + UUID scopeID = UUID.Zero; + if (request["SCOPEID"] != null) + UUID.TryParse(request["SCOPEID"], out scopeID); + else + m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by name"); + + string regionName = string.Empty; + if (request["NAME"] != null) + regionName = request["NAME"]; + else + m_log.WarnFormat("[GRID HANDLER]: no name in request to get region by name"); + + GridRegion rinfo = m_GridService.GetRegionByName(scopeID, regionName); + //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); + + Dictionary result = new Dictionary(); + if (rinfo == null) + result["result"] = "null"; + else + result["result"] = rinfo.ToKeyValuePairs(); + + string xmlString = ServerUtils.BuildXmlResponse(result); + //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); + UTF8Encoding encoding = new UTF8Encoding(); + return encoding.GetBytes(xmlString); } byte[] GetRegionsByName(Dictionary request) { - // TODO - return new byte[0]; + UUID scopeID = UUID.Zero; + if (request["SCOPEID"] != null) + UUID.TryParse(request["SCOPEID"], out scopeID); + else + m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get regions by name"); + + string regionName = string.Empty; + if (request["NAME"] != null) + regionName = request["NAME"]; + else + m_log.WarnFormat("[GRID HANDLER]: no NAME in request to get regions by name"); + + int max = 0; + if (request["MAX"] != null) + Int32.TryParse(request["MAX"], out max); + else + m_log.WarnFormat("[GRID HANDLER]: no MAX in request to get regions by name"); + + List rinfos = m_GridService.GetRegionsByName(scopeID, regionName, max); + //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); + + Dictionary result = new Dictionary(); + if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0))) + result["result"] = "null"; + else + { + int i = 0; + foreach (GridRegion rinfo in rinfos) + { + Dictionary rinfoDict = rinfo.ToKeyValuePairs(); + result["region" + i] = rinfoDict; + i++; + } + } + + string xmlString = ServerUtils.BuildXmlResponse(result); + //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); + UTF8Encoding encoding = new UTF8Encoding(); + return encoding.GetBytes(xmlString); } byte[] GetRegionRange(Dictionary request) { - // TODO - return new byte[0]; + UUID scopeID = UUID.Zero; + if (request["SCOPEID"] != null) + UUID.TryParse(request["SCOPEID"], out scopeID); + else + m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region range"); + + int xmin = 0, xmax = 0, ymin = 0, ymax = 0; + if (request["XMIN"] != null) + Int32.TryParse(request["XMIN"], out xmin); + else + m_log.WarnFormat("[GRID HANDLER]: no XMIN in request to get region range"); + if (request["XMAX"] != null) + Int32.TryParse(request["XMAX"], out xmax); + else + m_log.WarnFormat("[GRID HANDLER]: no XMAX in request to get region range"); + if (request["YMIN"] != null) + Int32.TryParse(request["YMIN"], out ymin); + else + m_log.WarnFormat("[GRID HANDLER]: no YMIN in request to get region range"); + if (request["YMAX"] != null) + Int32.TryParse(request["YMAX"], out ymax); + else + m_log.WarnFormat("[GRID HANDLER]: no YMAX in request to get region range"); + + + List rinfos = m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax); + + Dictionary result = new Dictionary(); + if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0))) + result["result"] = "null"; + else + { + int i = 0; + foreach (GridRegion rinfo in rinfos) + { + Dictionary rinfoDict = rinfo.ToKeyValuePairs(); + result["region" + i] = rinfoDict; + i++; + } + } + string xmlString = ServerUtils.BuildXmlResponse(result); + //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); + UTF8Encoding encoding = new UTF8Encoding(); + return encoding.GetBytes(xmlString); } #endregion -- cgit v1.1