From fa796308c39be2666bfae00238cf9d29cb4b9e03 Mon Sep 17 00:00:00 2001
From: lbsa71
Date: Thu, 12 Feb 2009 10:05:15 +0000
Subject: * Added RegionProfileService and moved RequestSimData to it.
---
OpenSim/Data/RegionProfileData.cs | 81 -------------------------
OpenSim/Data/RegionProfileService.cs | 94 +++++++++++++++++++++++++++++
OpenSim/Grid/UserServer/UserLoginService.cs | 8 +--
3 files changed, 98 insertions(+), 85 deletions(-)
create mode 100644 OpenSim/Data/RegionProfileService.cs
(limited to 'OpenSim')
diff --git a/OpenSim/Data/RegionProfileData.cs b/OpenSim/Data/RegionProfileData.cs
index d01aaa0..0b757f3 100644
--- a/OpenSim/Data/RegionProfileData.cs
+++ b/OpenSim/Data/RegionProfileData.cs
@@ -131,87 +131,6 @@ namespace OpenSim.Data
///
public UUID originUUID;
- ///
- /// Request sim data based on arbitrary key/value
- ///
- 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;
- }
-
- ///
- /// 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(UUID region_uuid, Uri gridserver_url,
- string gridserver_sendkey, string gridserver_recvkey)
- {
- return RequestSimData(gridserver_url, gridserver_sendkey, "region_UUID", region_uuid.Guid.ToString());
- }
-
- ///
- /// Request sim profile information from a grid server, by Region Handle
- ///
- /// the region handle to look for
- ///
- ///
- ///
- /// The sim profile. Null if there was a request failure
- 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());
- }
-
- ///
- /// Request sim profile information from a grid server, by Region Name
- ///
- /// the region name to look for
- ///
- ///
- ///
- /// The sim profile. Null if there was a request failure
- 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
public string RegionName
diff --git a/OpenSim/Data/RegionProfileService.cs b/OpenSim/Data/RegionProfileService.cs
new file mode 100644
index 0000000..1a73ed1
--- /dev/null
+++ b/OpenSim/Data/RegionProfileService.cs
@@ -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
+ {
+ ///
+ /// Request sim data based on arbitrary key/value
+ ///
+ 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;
+ }
+
+ ///
+ /// 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(UUID region_uuid, Uri gridserver_url,
+ string gridserver_sendkey, string gridserver_recvkey)
+ {
+ return RequestSimData(gridserver_url, gridserver_sendkey, "region_UUID", region_uuid.Guid.ToString());
+ }
+
+ ///
+ /// Request sim profile information from a grid server, by Region Handle
+ ///
+ /// the region handle to look for
+ ///
+ ///
+ ///
+ /// The sim profile. Null if there was a request failure
+ 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());
+ }
+
+ ///
+ /// Request sim profile information from a grid server, by Region Name
+ ///
+ /// the region name to look for
+ ///
+ ///
+ ///
+ /// The sim profile. Null if there was a request failure
+ 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 );
+ }
+ }
+}
diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs
index 905f4aa..7dce157 100644
--- a/OpenSim/Grid/UserServer/UserLoginService.cs
+++ b/OpenSim/Grid/UserServer/UserLoginService.cs
@@ -86,7 +86,7 @@ namespace OpenSim.Grid.UserServer
RegionProfileData SimInfo;
try
{
- SimInfo = RegionProfileData.RequestSimProfileData(
+ SimInfo = RegionProfileService.RequestSimProfileData(
theUser.CurrentAgent.Handle, m_config.GridServerURL,
m_config.GridSendKey, m_config.GridRecvKey);
@@ -302,20 +302,20 @@ namespace OpenSim.Grid.UserServer
protected RegionProfileData RequestClosestRegion(string region)
{
- return RegionProfileData.RequestSimProfileData(region,
+ return RegionProfileService.RequestSimProfileData(region,
m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey);
}
protected RegionProfileData GetRegionInfo(ulong homeRegionHandle)
{
- return RegionProfileData.RequestSimProfileData(homeRegionHandle,
+ return RegionProfileService.RequestSimProfileData(homeRegionHandle,
m_config.GridServerURL, m_config.GridSendKey,
m_config.GridRecvKey);
}
protected RegionProfileData GetRegionInfo(UUID homeRegionId)
{
- return RegionProfileData.RequestSimProfileData(homeRegionId,
+ return RegionProfileService.RequestSimProfileData(homeRegionId,
m_config.GridServerURL, m_config.GridSendKey,
m_config.GridRecvKey);
}
--
cgit v1.1