From 8edab95bad417a4d82cdfb6e9ef3138e8c5f0ab1 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 29 Jul 2008 19:52:58 +0000 Subject: * Refactored some heavily duplicated RequestSimProfileData functions * Changed InventoryUrl and GridServerURL type to Uri instead of string - to address '/' issues. --- OpenSim/Data/RegionProfileData.cs | 127 +++++++-------------- OpenSim/Framework/UserConfig.cs | 25 +++- .../OGS1/OGS1InterServiceInventoryService.cs | 4 +- 3 files changed, 61 insertions(+), 95 deletions(-) diff --git a/OpenSim/Data/RegionProfileData.cs b/OpenSim/Data/RegionProfileData.cs index 12f3927..f6172b9 100644 --- a/OpenSim/Data/RegionProfileData.cs +++ b/OpenSim/Data/RegionProfileData.cs @@ -130,51 +130,60 @@ namespace OpenSim.Data /// public LLUUID originUUID; - /// - /// Request sim profile information from a grid server, by Region UUID + /// Request sim data based on arbitrary key/value /// - /// The region UUID to look for - /// - /// - /// - /// The sim profile. Null if there was a request failure - /// This method should be statics - public RegionProfileData RequestSimProfileData(LLUUID region_uuid, string gridserver_url, - string gridserver_sendkey, string gridserver_recvkey) + private static RegionProfileData RequestSimData(Uri gridserver_url, string gridserver_sendkey, string keyField, string keyValue) { Hashtable requestData = new Hashtable(); - requestData["region_uuid"] = region_uuid.UUID.ToString(); + requestData[keyField] = keyValue; requestData["authkey"] = gridserver_sendkey; ArrayList SendParams = new ArrayList(); SendParams.Add(requestData); XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); - XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000); + XmlRpcResponse GridResp = GridReq.Send(gridserver_url.ToString(), 3000); Hashtable responseData = (Hashtable) GridResp.Value; - if (responseData.ContainsKey("error")) + RegionProfileData simData = null; + + if (!responseData.ContainsKey("error")) { - return null; + simData = new RegionProfileData(); + simData.regionLocX = Convert.ToUInt32((string) responseData["region_locx"]); + simData.regionLocY = Convert.ToUInt32((string) responseData["region_locy"]); + simData.regionHandle = + Helpers.UIntsToLong((simData.regionLocX*Constants.RegionSize), + (simData.regionLocY*Constants.RegionSize)); + simData.serverIP = (string) responseData["sim_ip"]; + simData.serverPort = Convert.ToUInt32((string) responseData["sim_port"]); + simData.httpPort = Convert.ToUInt32((string) responseData["http_port"]); + simData.remotingPort = Convert.ToUInt32((string) responseData["remoting_port"]); + simData.serverURI = (string) responseData["server_uri"]; + simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/"; + simData.UUID = new LLUUID((string) responseData["region_UUID"]); + simData.regionName = (string) responseData["region_name"]; } - RegionProfileData simData = new RegionProfileData(); - simData.regionLocX = Convert.ToUInt32((string) responseData["region_locx"]); - simData.regionLocY = Convert.ToUInt32((string) responseData["region_locy"]); - simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * Constants.RegionSize), (simData.regionLocY * Constants.RegionSize)); - simData.serverIP = (string) responseData["sim_ip"]; - simData.serverPort = Convert.ToUInt32((string) responseData["sim_port"]); - simData.httpPort = Convert.ToUInt32((string) responseData["http_port"]); - simData.remotingPort = Convert.ToUInt32((string) responseData["remoting_port"]); - simData.serverURI = (string)responseData["server_uri"]; - simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/"; - simData.UUID = new LLUUID((string) responseData["region_UUID"]); - simData.regionName = (string) responseData["region_name"]; - return simData; } /// + /// Request sim profile information from a grid server, by Region UUID + /// + /// The region UUID to look for + /// + /// + /// + /// The sim profile. Null if there was a request failure + /// This method should be statics + public static RegionProfileData RequestSimProfileData(LLUUID region_uuid, Uri gridserver_url, + string gridserver_sendkey, string gridserver_recvkey) + { + return RequestSimData(gridserver_url, gridserver_sendkey, "region_uuid", region_uuid.UUID.ToString()); + } + + /// /// Request sim profile information from a grid server, by Region Handle /// /// the region handle to look for @@ -182,38 +191,10 @@ namespace OpenSim.Data /// /// /// The sim profile. Null if there was a request failure - public static RegionProfileData RequestSimProfileData(ulong region_handle, string gridserver_url, + public static RegionProfileData RequestSimProfileData(ulong region_handle, Uri gridserver_url, string gridserver_sendkey, string gridserver_recvkey) { - Hashtable requestData = new Hashtable(); - requestData["region_handle"] = region_handle.ToString(); - requestData["authkey"] = gridserver_sendkey; - ArrayList SendParams = new ArrayList(); - SendParams.Add(requestData); - XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); - XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000); - - Hashtable responseData = (Hashtable) GridResp.Value; - - if (responseData.ContainsKey("error")) - { - return null; - } - - RegionProfileData simData = new RegionProfileData(); - simData.regionLocX = Convert.ToUInt32((string) responseData["region_locx"]); - simData.regionLocY = Convert.ToUInt32((string) responseData["region_locy"]); - simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * Constants.RegionSize), (simData.regionLocY * Constants.RegionSize)); - simData.serverIP = (string) responseData["sim_ip"]; - simData.serverPort = Convert.ToUInt32((string) responseData["sim_port"]); - simData.httpPort = Convert.ToUInt32((string) responseData["http_port"]); - simData.remotingPort = Convert.ToUInt32((string) responseData["remoting_port"]); - simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/"; - simData.serverURI = (string)responseData["server_uri"]; - simData.UUID = new LLUUID((string) responseData["region_UUID"]); - simData.regionName = (string) responseData["region_name"]; - - return simData; + return RequestSimData(gridserver_url, gridserver_sendkey, "region_handle", region_handle.ToString()); } /// @@ -224,38 +205,10 @@ namespace OpenSim.Data /// /// /// The sim profile. Null if there was a request failure - public static RegionProfileData RequestSimProfileData(string regionName, string gridserver_url, + public static RegionProfileData RequestSimProfileData(string regionName, Uri gridserver_url, string gridserver_sendkey, string gridserver_recvkey) { - Hashtable requestData = new Hashtable(); - requestData["region_name_search"] = regionName; - requestData["authkey"] = gridserver_sendkey; - ArrayList SendParams = new ArrayList(); - SendParams.Add(requestData); - XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); - XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000); - - Hashtable responseData = (Hashtable)GridResp.Value; - - if (responseData.ContainsKey("error")) - { - return null; - } - - RegionProfileData simData = new RegionProfileData(); - simData.regionLocX = Convert.ToUInt32((string)responseData["region_locx"]); - simData.regionLocY = Convert.ToUInt32((string)responseData["region_locy"]); - simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * Constants.RegionSize), (simData.regionLocY * Constants.RegionSize)); - simData.serverIP = (string)responseData["sim_ip"]; - simData.serverPort = Convert.ToUInt32((string)responseData["sim_port"]); - simData.httpPort = Convert.ToUInt32((string)responseData["http_port"]); - simData.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); - simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/"; - simData.serverURI = (string)responseData["server_uri"]; - simData.UUID = new LLUUID((string)responseData["region_UUID"]); - simData.regionName = (string)responseData["region_name"]; - - return simData; + return RequestSimData(gridserver_url, gridserver_sendkey, "region_name_search", regionName ); } } } diff --git a/OpenSim/Framework/UserConfig.cs b/OpenSim/Framework/UserConfig.cs index d8c83be..6cf526c 100644 --- a/OpenSim/Framework/UserConfig.cs +++ b/OpenSim/Framework/UserConfig.cs @@ -44,21 +44,34 @@ namespace OpenSim.Framework public uint DefaultY = 1000; public string GridRecvKey = String.Empty; public string GridSendKey = String.Empty; - public string GridServerURL = String.Empty; public uint HttpPort = DefaultHttpPort; public bool HttpSSL = DefaultHttpSSL; private Uri m_inventoryUrl; - public string InventoryUrl + public Uri InventoryUrl { get { - return m_inventoryUrl.ToString(); + return m_inventoryUrl; } set { - m_inventoryUrl = new Uri(value); + m_inventoryUrl = value; + } + } + + private Uri m_gridServerURL; + + public Uri GridServerURL + { + get + { + return m_gridServerURL; + } + set + { + m_gridServerURL = value; } } @@ -120,7 +133,7 @@ namespace OpenSim.Framework DefaultStartupMsg = (string) configuration_result; break; case "default_grid_server": - GridServerURL = (string) configuration_result; + GridServerURL = new Uri( (string) configuration_result ); break; case "grid_send_key": GridSendKey = (string) configuration_result; @@ -129,7 +142,7 @@ namespace OpenSim.Framework GridRecvKey = (string) configuration_result; break; case "default_inventory_server": - InventoryUrl = (string) configuration_result; + InventoryUrl = new Uri((string) configuration_result); break; case "database_provider": DatabaseProvider = (string) configuration_result; diff --git a/OpenSim/Grid/Communications/OGS1/OGS1InterServiceInventoryService.cs b/OpenSim/Grid/Communications/OGS1/OGS1InterServiceInventoryService.cs index 6aa1440..eed4621 100644 --- a/OpenSim/Grid/Communications/OGS1/OGS1InterServiceInventoryService.cs +++ b/OpenSim/Grid/Communications/OGS1/OGS1InterServiceInventoryService.cs @@ -39,9 +39,9 @@ namespace OpenSim.Grid.Communications.OGS1 /// public class OGS1InterServiceInventoryService : IInterServiceInventoryServices { - protected string m_inventoryServerUrl; + protected Uri m_inventoryServerUrl; - public OGS1InterServiceInventoryService(string inventoryServerUrl) + public OGS1InterServiceInventoryService(Uri inventoryServerUrl) { m_inventoryServerUrl = inventoryServerUrl; } -- cgit v1.1