From 61878884569f9c01b6324f9a9d9fbcac7034f536 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 12 Feb 2009 10:21:21 +0000 Subject: * Renamed RegionProfileService to RegionProfileServiceProxy to better reflect actual use. * Added IRegionProfileService --- OpenSim/Data/IRegionProfileService.cs | 44 ++++++++++++++ OpenSim/Data/RegionProfileService.cs | 94 ----------------------------- OpenSim/Data/RegionProfileServiceProxy.cs | 94 +++++++++++++++++++++++++++++ OpenSim/Grid/UserServer/Main.cs | 2 +- OpenSim/Grid/UserServer/UserLoginService.cs | 4 +- 5 files changed, 141 insertions(+), 97 deletions(-) create mode 100644 OpenSim/Data/IRegionProfileService.cs delete mode 100644 OpenSim/Data/RegionProfileService.cs create mode 100644 OpenSim/Data/RegionProfileServiceProxy.cs diff --git a/OpenSim/Data/IRegionProfileService.cs b/OpenSim/Data/IRegionProfileService.cs new file mode 100644 index 0000000..5aa5b58 --- /dev/null +++ b/OpenSim/Data/IRegionProfileService.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Data +{ + public interface IRegionProfileService + { + /// + /// 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 + RegionProfileData RequestSimProfileData(UUID regionId, Uri gridserverUrl, + string gridserverSendkey, string gridserverRecvkey); + + /// + /// 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 + RegionProfileData RequestSimProfileData(ulong region_handle, Uri gridserver_url, + string gridserver_sendkey, string gridserver_recvkey); + + /// + /// 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 + RegionProfileData RequestSimProfileData(string regionName, Uri gridserverUrl, + string gridserverSendkey, string gridserverRecvkey); + } +} diff --git a/OpenSim/Data/RegionProfileService.cs b/OpenSim/Data/RegionProfileService.cs deleted file mode 100644 index 0cd4021..0000000 --- a/OpenSim/Data/RegionProfileService.cs +++ /dev/null @@ -1,94 +0,0 @@ -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 RegionProfileData RequestSimData(Uri gridserverUrl, string gridserverSendkey, string keyField, string keyValue) - { - Hashtable requestData = new Hashtable(); - requestData[keyField] = keyValue; - requestData["authkey"] = gridserverSendkey; - ArrayList SendParams = new ArrayList(); - SendParams.Add(requestData); - XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); - XmlRpcResponse GridResp = GridReq.Send(gridserverUrl.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 RegionProfileData RequestSimProfileData(UUID regionId, Uri gridserverUrl, - string gridserverSendkey, string gridserverRecvkey) - { - return RequestSimData(gridserverUrl, gridserverSendkey, "region_UUID", regionId.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 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 RegionProfileData RequestSimProfileData(string regionName, Uri gridserverUrl, - string gridserverSendkey, string gridserverRecvkey) - { - return RequestSimData(gridserverUrl, gridserverSendkey, "region_name_search", regionName ); - } - } -} diff --git a/OpenSim/Data/RegionProfileServiceProxy.cs b/OpenSim/Data/RegionProfileServiceProxy.cs new file mode 100644 index 0000000..54e392a --- /dev/null +++ b/OpenSim/Data/RegionProfileServiceProxy.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 RegionProfileServiceProxy : IRegionProfileService + { + /// + /// Request sim data based on arbitrary key/value + /// + private RegionProfileData RequestSimData(Uri gridserverUrl, string gridserverSendkey, string keyField, string keyValue) + { + Hashtable requestData = new Hashtable(); + requestData[keyField] = keyValue; + requestData["authkey"] = gridserverSendkey; + ArrayList SendParams = new ArrayList(); + SendParams.Add(requestData); + XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); + XmlRpcResponse GridResp = GridReq.Send(gridserverUrl.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 RegionProfileData RequestSimProfileData(UUID regionId, Uri gridserverUrl, + string gridserverSendkey, string gridserverRecvkey) + { + return RequestSimData(gridserverUrl, gridserverSendkey, "region_UUID", regionId.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 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 RegionProfileData RequestSimProfileData(string regionName, Uri gridserverUrl, + string gridserverSendkey, string gridserverRecvkey) + { + return RequestSimData(gridserverUrl, gridserverSendkey, "region_name_search", regionName ); + } + } +} diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index 70aaea3..2199e93 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs @@ -168,7 +168,7 @@ namespace OpenSim.Grid.UserServer protected virtual void StartupLoginService(IInterServiceInventoryServices inventoryService) { m_loginService = new UserLoginService( - m_userManager, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile), Cfg, Cfg.DefaultStartupMsg, new RegionProfileService()); + m_userManager, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile), Cfg, Cfg.DefaultStartupMsg, new RegionProfileServiceProxy()); } protected virtual void AddHttpHandlers() diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs index b11714a..d069e1a 100644 --- a/OpenSim/Grid/UserServer/UserLoginService.cs +++ b/OpenSim/Grid/UserServer/UserLoginService.cs @@ -59,12 +59,12 @@ namespace OpenSim.Grid.UserServer private UserLoggedInAtLocation handlerUserLoggedInAtLocation; public UserConfig m_config; - private readonly RegionProfileService m_regionProfileService; + private readonly IRegionProfileService m_regionProfileService; public UserLoginService( UserManagerBase userManager, IInterServiceInventoryServices inventoryService, LibraryRootFolder libraryRootFolder, - UserConfig config, string welcomeMess, RegionProfileService regionProfileService) + UserConfig config, string welcomeMess, IRegionProfileService regionProfileService) : base(userManager, libraryRootFolder, welcomeMess) { m_config = config; -- cgit v1.1