* Added RegionProfileService and moved RequestSimData to it.

0.6.3-post-fixes
lbsa71 2009-02-12 10:05:15 +00:00
parent 801da4346a
commit fa796308c3
3 changed files with 98 additions and 85 deletions

View File

@ -131,87 +131,6 @@ namespace OpenSim.Data
/// </summary> /// </summary>
public UUID originUUID; public UUID 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 =
Utils.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://" + (string)responseData["sim_ip"] + ":" + simData.httpPort.ToString() + "/";
simData.UUID = new UUID((string) responseData["region_UUID"]);
simData.regionName = (string) responseData["region_name"];
}
return simData;
}
/// <summary>
/// Request sim profile information from a grid server, by Region UUID
/// </summary>
/// <param name="region_UUID">The region UUID to look for</param>
/// <param name="gridserver_url"></param>
/// <param name="gridserver_sendkey"></param>
/// <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 static RegionProfileData RequestSimProfileData(UUID region_uuid, Uri gridserver_url,
string gridserver_sendkey, string gridserver_recvkey)
{
return RequestSimData(gridserver_url, gridserver_sendkey, "region_UUID", region_uuid.Guid.ToString());
}
/// <summary>
/// Request sim profile information from a grid server, by Region Handle
/// </summary>
/// <param name="region_handle">the region handle to look for</param>
/// <param name="gridserver_url"></param>
/// <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, Uri gridserver_url,
string gridserver_sendkey, string gridserver_recvkey)
{
return RequestSimData(gridserver_url, gridserver_sendkey, "region_handle", region_handle.ToString());
}
/// <summary>
/// Request sim profile information from a grid server, by Region Name
/// </summary>
/// <param name="region_handle">the region name to look for</param>
/// <param name="gridserver_url"></param>
/// <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, Uri gridserver_url,
string gridserver_sendkey, string gridserver_recvkey)
{
return RequestSimData(gridserver_url, gridserver_sendkey, "region_name_search", regionName );
}
//Data Wrappers //Data Wrappers
public string RegionName public string RegionName

View File

@ -0,0 +1,94 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Nwc.XmlRpc;
using OpenMetaverse;
using OpenSim.Framework;
namespace OpenSim.Data
{
public class RegionProfileService
{
/// <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 =
Utils.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://" + (string)responseData["sim_ip"] + ":" + simData.httpPort.ToString() + "/";
simData.UUID = new UUID((string) responseData["region_UUID"]);
simData.regionName = (string) responseData["region_name"];
}
return simData;
}
/// <summary>
/// Request sim profile information from a grid server, by Region UUID
/// </summary>
/// <param name="region_UUID">The region UUID to look for</param>
/// <param name="gridserver_url"></param>
/// <param name="gridserver_sendkey"></param>
/// <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 static RegionProfileData RequestSimProfileData(UUID region_uuid, Uri gridserver_url,
string gridserver_sendkey, string gridserver_recvkey)
{
return RequestSimData(gridserver_url, gridserver_sendkey, "region_UUID", region_uuid.Guid.ToString());
}
/// <summary>
/// Request sim profile information from a grid server, by Region Handle
/// </summary>
/// <param name="region_handle">the region handle to look for</param>
/// <param name="gridserver_url"></param>
/// <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, Uri gridserver_url,
string gridserver_sendkey, string gridserver_recvkey)
{
return RequestSimData(gridserver_url, gridserver_sendkey, "region_handle", region_handle.ToString());
}
/// <summary>
/// Request sim profile information from a grid server, by Region Name
/// </summary>
/// <param name="region_handle">the region name to look for</param>
/// <param name="gridserver_url"></param>
/// <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, Uri gridserver_url,
string gridserver_sendkey, string gridserver_recvkey)
{
return RequestSimData(gridserver_url, gridserver_sendkey, "region_name_search", regionName );
}
}
}

View File

@ -86,7 +86,7 @@ namespace OpenSim.Grid.UserServer
RegionProfileData SimInfo; RegionProfileData SimInfo;
try try
{ {
SimInfo = RegionProfileData.RequestSimProfileData( SimInfo = RegionProfileService.RequestSimProfileData(
theUser.CurrentAgent.Handle, m_config.GridServerURL, theUser.CurrentAgent.Handle, m_config.GridServerURL,
m_config.GridSendKey, m_config.GridRecvKey); m_config.GridSendKey, m_config.GridRecvKey);
@ -302,20 +302,20 @@ namespace OpenSim.Grid.UserServer
protected RegionProfileData RequestClosestRegion(string region) protected RegionProfileData RequestClosestRegion(string region)
{ {
return RegionProfileData.RequestSimProfileData(region, return RegionProfileService.RequestSimProfileData(region,
m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey);
} }
protected RegionProfileData GetRegionInfo(ulong homeRegionHandle) protected RegionProfileData GetRegionInfo(ulong homeRegionHandle)
{ {
return RegionProfileData.RequestSimProfileData(homeRegionHandle, return RegionProfileService.RequestSimProfileData(homeRegionHandle,
m_config.GridServerURL, m_config.GridSendKey, m_config.GridServerURL, m_config.GridSendKey,
m_config.GridRecvKey); m_config.GridRecvKey);
} }
protected RegionProfileData GetRegionInfo(UUID homeRegionId) protected RegionProfileData GetRegionInfo(UUID homeRegionId)
{ {
return RegionProfileData.RequestSimProfileData(homeRegionId, return RegionProfileService.RequestSimProfileData(homeRegionId,
m_config.GridServerURL, m_config.GridSendKey, m_config.GridServerURL, m_config.GridSendKey,
m_config.GridRecvKey); m_config.GridRecvKey);
} }