* Refactored some heavily duplicated RequestSimProfileData functions

* Changed InventoryUrl and GridServerURL type to Uri instead of string - to address '/' issues.
0.6.0-stable
lbsa71 2008-07-29 19:52:58 +00:00
parent d84a6bca55
commit 8edab95bad
3 changed files with 64 additions and 98 deletions

View File

@ -130,6 +130,43 @@ namespace OpenSim.Data
/// </summary>
public LLUUID originUUID;
/// <summary>
/// Request sim data based on arbitrary key/value
/// </summary>
private static RegionProfileData RequestSimData(Uri gridserver_url, string gridserver_sendkey, string keyField, string keyValue)
{
Hashtable requestData = new Hashtable();
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.ToString(), 3000);
Hashtable responseData = (Hashtable) GridResp.Value;
RegionProfileData simData = null;
if (!responseData.ContainsKey("error"))
{
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;
}
/// <summary>
/// Request sim profile information from a grid server, by Region UUID
@ -140,38 +177,10 @@ namespace OpenSim.Data
/// <param name="gridserver_recvkey"></param>
/// <returns>The sim profile. Null if there was a request failure</returns>
/// <remarks>This method should be statics</remarks>
public RegionProfileData RequestSimProfileData(LLUUID region_uuid, string gridserver_url,
public static RegionProfileData RequestSimProfileData(LLUUID region_uuid, Uri gridserver_url,
string gridserver_sendkey, string gridserver_recvkey)
{
Hashtable requestData = new Hashtable();
requestData["region_uuid"] = region_uuid.UUID.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.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;
return RequestSimData(gridserver_url, gridserver_sendkey, "region_uuid", region_uuid.UUID.ToString());
}
/// <summary>
@ -182,38 +191,10 @@ namespace OpenSim.Data
/// <param name="gridserver_sendkey"></param>
/// <param name="gridserver_recvkey"></param>
/// <returns>The sim profile. Null if there was a request failure</returns>
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());
}
/// <summary>
@ -224,38 +205,10 @@ namespace OpenSim.Data
/// <param name="gridserver_sendkey"></param>
/// <param name="gridserver_recvkey"></param>
/// <returns>The sim profile. Null if there was a request failure</returns>
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 );
}
}
}

View File

@ -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;

View File

@ -39,9 +39,9 @@ namespace OpenSim.Grid.Communications.OGS1
/// </summary>
public class OGS1InterServiceInventoryService : IInterServiceInventoryServices
{
protected string m_inventoryServerUrl;
protected Uri m_inventoryServerUrl;
public OGS1InterServiceInventoryService(string inventoryServerUrl)
public OGS1InterServiceInventoryService(Uri inventoryServerUrl)
{
m_inventoryServerUrl = inventoryServerUrl;
}