From 9fbcceb1db84e62eedb75b2bd43f5e59142ec6c8 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 18 Jan 2010 20:35:59 -0800 Subject: [PATCH] * Towards enabling hyperlinks at grid-level. * Updated grid configs --- .../Hypergrid/GatekeeperServerConnector.cs | 11 +- .../Handlers/Hypergrid/HypergridHandlers.cs | 34 +++++- .../Hypergrid/HypergridServiceConnector.cs | 110 +++++++++++++++++- bin/OpenSim.Server.ini.example | 5 +- bin/config-include/GridHypergrid.ini | 13 +-- 5 files changed, 158 insertions(+), 15 deletions(-) diff --git a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs index 15b29d2e60..940ec7a32d 100644 --- a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs +++ b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs @@ -51,6 +51,8 @@ namespace OpenSim.Server.Handlers.Hypergrid get { return m_GatekeeperService; } } + private IHypergridService m_HypergridService; + public GatekeeperServiceInConnector(IConfigSource config, IHttpServer server, ISimulationService simService) : base(config, server, String.Empty) { @@ -60,12 +62,17 @@ namespace OpenSim.Server.Handlers.Hypergrid string serviceDll = gridConfig.GetString("LocalServiceModule", string.Empty); Object[] args = new Object[] { config, simService }; m_GatekeeperService = ServerUtils.LoadPlugin(serviceDll, args); + + serviceDll = gridConfig.GetString("HypergridService", string.Empty); + m_HypergridService = ServerUtils.LoadPlugin(serviceDll, args); + } - if (m_GatekeeperService == null) + if (m_GatekeeperService == null || m_HypergridService == null) throw new Exception("Gatekeeper server connector cannot proceed because of missing service"); - HypergridHandlers hghandlers = new HypergridHandlers(m_GatekeeperService); + HypergridHandlers hghandlers = new HypergridHandlers(m_GatekeeperService, m_HypergridService); server.AddXmlRPCHandler("link_region", hghandlers.LinkRegionRequest, false); + server.AddXmlRPCHandler("link_region_by_desc", hghandlers.LinkRegionByDescRequest, false); server.AddXmlRPCHandler("get_region", hghandlers.GetRegion, false); server.AddXmlRPCHandler("get_home_region", hghandlers.GetHomeRegion, false); diff --git a/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs index 846d1c2f18..1d711a867e 100644 --- a/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs +++ b/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs @@ -44,10 +44,12 @@ namespace OpenSim.Server.Handlers.Hypergrid private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private IGatekeeperService m_GatekeeperService; + private IHypergridService m_HypergridService; - public HypergridHandlers(IGatekeeperService gatekeeper) + public HypergridHandlers(IGatekeeperService gatekeeper, IHypergridService hyper) { m_GatekeeperService = gatekeeper; + m_HypergridService = hyper; } /// @@ -80,6 +82,36 @@ namespace OpenSim.Server.Handlers.Hypergrid return response; } + /// + /// A local region wants to establish a grid-wide hyperlink to another region + /// + /// + /// + public XmlRpcResponse LinkRegionByDescRequest(XmlRpcRequest request, IPEndPoint remoteClient) + { + Hashtable requestData = (Hashtable)request.Params[0]; + //string host = (string)requestData["host"]; + //string portstr = (string)requestData["port"]; + string descriptor = (string)requestData["region_desc"]; + + UUID regionID = UUID.Zero; + string imageURL = string.Empty; + ulong regionHandle = 0; + string reason = string.Empty; + + bool success = m_HypergridService.LinkRegion(descriptor, out regionID, out regionHandle, out imageURL, out reason); + + Hashtable hash = new Hashtable(); + hash["result"] = success.ToString(); + hash["uuid"] = regionID.ToString(); + hash["handle"] = regionHandle.ToString(); + hash["region_image"] = imageURL; + + XmlRpcResponse response = new XmlRpcResponse(); + response.Value = hash; + return response; + } + public XmlRpcResponse GetRegion(XmlRpcRequest request, IPEndPoint remoteClient) { Hashtable requestData = (Hashtable)request.Params[0]; diff --git a/OpenSim/Services/Connectors/Hypergrid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HypergridServiceConnector.cs index 953c7bdc58..1786d38a42 100644 --- a/OpenSim/Services/Connectors/Hypergrid/HypergridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/HypergridServiceConnector.cs @@ -41,22 +41,49 @@ using OpenMetaverse; using OpenMetaverse.Imaging; using log4net; using Nwc.XmlRpc; +using Nini.Config; namespace OpenSim.Services.Connectors.Hypergrid { - public class HypergridServiceConnector + public class HypergridServiceConnector : IHypergridService { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private IAssetService m_AssetService; + private string m_ServerURL; - public HypergridServiceConnector() : this(null) { } + public HypergridServiceConnector() { } - public HypergridServiceConnector(IAssetService assService) + public HypergridServiceConnector(IAssetService assService) { m_AssetService = assService; } + public HypergridServiceConnector(IConfigSource source) + { + Initialise(source); + } + + public virtual void Initialise(IConfigSource source) + { + IConfig hgConfig = source.Configs["HypergridService"]; + if (hgConfig == null) + { + m_log.Error("[HYPERGRID CONNECTOR]: HypergridService missing from OpenSim.ini"); + throw new Exception("Hypergrid connector init error"); + } + + string serviceURI = hgConfig.GetString("HypergridServerURI", + String.Empty); + + if (serviceURI == String.Empty) + { + m_log.Error("[HYPERGRID CONNECTOR]: No Server URI named in section HypergridService"); + throw new Exception("Hypergrid connector init error"); + } + m_ServerURL = serviceURI; + } + public bool LinkRegion(GridRegion info, out UUID regionID, out ulong realHandle, out string imageURL, out string reason) { regionID = UUID.Zero; @@ -246,5 +273,82 @@ namespace OpenSim.Services.Connectors.Hypergrid return null; } + + #region From local regions to grid-wide hypergrid service + + public bool LinkRegion(string regionDescriptor, out UUID regionID, out ulong realHandle, out string imageURL, out string reason) + { + regionID = UUID.Zero; + imageURL = string.Empty; + realHandle = 0; + reason = string.Empty; + + Hashtable hash = new Hashtable(); + hash["region_desc"] = regionDescriptor; + + IList paramList = new ArrayList(); + paramList.Add(hash); + + XmlRpcRequest request = new XmlRpcRequest("link_region_by_desc", paramList); + XmlRpcResponse response = null; + try + { + response = request.Send(m_ServerURL, 10000); + } + catch (Exception e) + { + m_log.Debug("[HGrid]: Exception " + e.Message); + reason = "Error contacting remote server"; + return false; + } + + if (response.IsFault) + { + reason = response.FaultString; + m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); + return false; + } + + hash = (Hashtable)response.Value; + //foreach (Object o in hash) + // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); + try + { + bool success = false; + Boolean.TryParse((string)hash["result"], out success); + if (success) + { + UUID.TryParse((string)hash["uuid"], out regionID); + //m_log.Debug(">> HERE, uuid: " + uuid); + if ((string)hash["handle"] != null) + { + realHandle = Convert.ToUInt64((string)hash["handle"]); + //m_log.Debug(">> HERE, realHandle: " + realHandle); + } + if (hash["region_image"] != null) + { + imageURL = (string)hash["region_image"]; + } + } + + } + catch (Exception e) + { + reason = "Error parsing return arguments"; + m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace); + return false; + } + + return true; + } + + // TODO !!! + public GridRegion GetRegionByUUID(UUID regionID) { return null; } + public GridRegion GetRegionByPosition(int x, int y) { return null; } + public GridRegion GetRegionByName(string name) { return null; } + public List GetRegionsByName(string name) { return null; } + public List GetRegionRange(int xmin, int xmax, int ymin, int ymax) { return null; } + + #endregion } } diff --git a/bin/OpenSim.Server.ini.example b/bin/OpenSim.Server.ini.example index 3d2a5ba0a8..0c6046fa13 100644 --- a/bin/OpenSim.Server.ini.example +++ b/bin/OpenSim.Server.ini.example @@ -42,7 +42,6 @@ ServiceConnectors = "OpenSim.Server.Handlers.dll:AssetServiceConnector,OpenSim.S ; * [InventoryService] LocalServiceModule = "OpenSim.Services.InventoryService.dll:InventoryService" - UserServerURI = "http://127.0.0.1:8002" SessionAuthentication = "false" StorageProvider = "OpenSim.Data.MySQL.dll" ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=opensim123;" @@ -58,10 +57,12 @@ ServiceConnectors = "OpenSim.Server.Handlers.dll:AssetServiceConnector,OpenSim.S Realm = "regions" ; AllowDuplicateNames = "True" ;; Next, we can specify properties of regions, including default and fallback regions - ;; The syntax is: Region_ = "" + ;; The syntax is: Region_ = "" + ;; or: Region_ = "" ;; where can be DefaultRegion, FallbackRegion, NoDirectLogin, Persistent, LockedOut,Reservation,NoMove,Authenticate ;; For example: ; Region_Welcome_Area = "DefaultRegion, FallbackRegion" + ; (replace spaces with underscore) ; * This is the configuration for the freeswitch server in grid mode [FreeswitchService] diff --git a/bin/config-include/GridHypergrid.ini b/bin/config-include/GridHypergrid.ini index 4b6bc17797..4885a4110e 100644 --- a/bin/config-include/GridHypergrid.ini +++ b/bin/config-include/GridHypergrid.ini @@ -17,18 +17,17 @@ AvatarServices = "RemoteAvatarServicesConnector" NeighbourServices = "RemoteNeighbourServicesConnector" AuthenticationServices = "RemoteAuthenticationServicesConnector" + AuthorizationServices = "LocalAuthorizationServicesConnector" PresenceServices = "RemotePresenceServicesConnector" UserAccountServices = "RemoteUserAccountServicesConnector" SimulationServices = "RemoteSimulationConnectorModule" - EntityTransferModule = "BasicEntityTransferModule" + EntityTransferModule = "HGEntityTransferModule" LandServiceInConnector = true NeighbourServiceInConnector = true - HypergridServiceInConnector = true SimulationServiceInConnector = true LibraryModule = true InventoryServiceInConnector = false AssetServiceInConnector = false - LLLoginServiceInConnector = false [AssetService] LocalGridAssetService = "OpenSim.Services.Connectors.dll:AssetServicesConnector" @@ -41,12 +40,12 @@ [GridService] ; for the HGGridServicesConnector to instantiate GridServiceConnectorModule = "OpenSim.Region.CoreModules.dll:RemoteGridServicesConnector" + HypergridService = "OpenSim.Services.HypergridService.dll:HypergridService" ; RemoteGridServicesConnector instantiates a LocalGridServicesConnector, ; which in turn uses this LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" StorageProvider = "OpenSim.Data.Null.dll:NullRegionData" -[LibraryService] - LocalServiceModule = "OpenSim.Services.InventoryService.dll:LibraryService" - LibraryName = "OpenSim Library" - DefaultLibrary = "./inventory/Libraries.xml" +[HypergridService] + GridService = "OpenSim.Services.GridService.dll:GridService" + AssetService = "OpenSim.Services.AssetService.dll:AssetService"