diff --git a/OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs b/OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs index 5651a175a7..dedf8768b1 100644 --- a/OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs +++ b/OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs @@ -39,6 +39,10 @@ using OpenSim.Data; using OpenSim.Framework; using OpenSim.Grid.Framework; using Timer = System.Timers.Timer; +using OpenSim.Services.Interfaces; +using OpenSim.Services.Connectors; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + namespace OpenSim.Grid.MessagingServer.Modules { @@ -52,6 +56,8 @@ namespace OpenSim.Grid.MessagingServer.Modules private IGridServiceCore m_messageCore; + private IGridService m_GridService; + // a dictionary of all current regions this server knows about private Dictionary m_regionInfoCache = new Dictionary(); @@ -59,6 +65,8 @@ namespace OpenSim.Grid.MessagingServer.Modules { m_cfg = config; m_messageCore = messageCore; + + m_GridService = new GridServicesConnector(m_cfg.GridServerURL); } public void Initialise() @@ -134,51 +142,30 @@ namespace OpenSim.Grid.MessagingServer.Modules /// public RegionProfileData RequestRegionInfo(ulong regionHandle) { - RegionProfileData regionProfile = null; - try - { - Hashtable requestData = new Hashtable(); - requestData["region_handle"] = regionHandle.ToString(); - requestData["authkey"] = m_cfg.GridSendKey; + uint x = 0, y = 0; + Utils.LongToUInts(regionHandle, out x, out y); + GridRegion region = m_GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); - ArrayList SendParams = new ArrayList(); - SendParams.Add(requestData); + if (region != null) + return GridRegionToRegionProfile(region); - XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); + else + return null; + } - XmlRpcResponse GridResp = GridReq.Send(m_cfg.GridServerURL, 3000); - - Hashtable responseData = (Hashtable)GridResp.Value; - - if (responseData.ContainsKey("error")) - { - m_log.Error("[GRID]: error received from grid server" + responseData["error"]); - return null; - } - - uint regX = Convert.ToUInt32((string)responseData["region_locx"]); - uint regY = Convert.ToUInt32((string)responseData["region_locy"]); - string internalIpStr = (string)responseData["sim_ip"]; - - regionProfile = new RegionProfileData(); - regionProfile.httpPort = (uint)Convert.ToInt32((string)responseData["http_port"]); - regionProfile.httpServerURI = "http://" + internalIpStr + ":" + regionProfile.httpPort + "/"; - regionProfile.regionHandle = Utils.UIntsToLong((regX * Constants.RegionSize), (regY * Constants.RegionSize)); - regionProfile.regionLocX = regX; - regionProfile.regionLocY = regY; - - regionProfile.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); - regionProfile.UUID = new UUID((string)responseData["region_UUID"]); - regionProfile.regionName = (string)responseData["region_name"]; - } - catch (WebException) - { - m_log.Error("[GRID]: " + - "Region lookup failed for: " + regionHandle.ToString() + - " - Is the GridServer down?"); - } - - return regionProfile; + private RegionProfileData GridRegionToRegionProfile(GridRegion region) + { + RegionProfileData rprofile = new RegionProfileData(); + rprofile.httpPort = region.HttpPort; + rprofile.httpServerURI = region.ServerURI; + rprofile.regionLocX = (uint)(region.RegionLocX / Constants.RegionSize); + rprofile.regionLocY = (uint)(region.RegionLocY / Constants.RegionSize); + rprofile.RegionName = region.RegionName; + rprofile.ServerHttpPort = region.HttpPort; + rprofile.ServerIP = region.ExternalHostName; + rprofile.ServerPort = (uint)region.ExternalEndPoint.Port; + rprofile.Uuid = region.RegionID; + return rprofile; } public XmlRpcResponse RegionStartup(XmlRpcRequest request, IPEndPoint remoteClient) diff --git a/prebuild.xml b/prebuild.xml index 22ff3d7845..ccc79dee9f 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -980,10 +980,13 @@ + + +