From fd64823466ee667d0d827f95d3001ec8675512b2 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 18 Jan 2010 10:37:11 -0800 Subject: * Added missing GatekeeperServiceConnector * Added basic machinery for teleporting users home. Untested. --- .../Hypergrid/GatekeeperServiceConnector.cs | 119 +++++++++++++++++++++ .../Services/HypergridService/GatekeeperService.cs | 38 ++++++- .../Services/HypergridService/HypergridService.cs | 8 +- OpenSim/Services/Interfaces/IGatekeeperService.cs | 3 + 4 files changed, 163 insertions(+), 5 deletions(-) create mode 100644 OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs new file mode 100644 index 0000000..a8d9292 --- /dev/null +++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Net; + +using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + +using OpenMetaverse; +using Nwc.XmlRpc; + +using OpenSim.Services.Connectors.Simulation; + +namespace OpenSim.Services.Connectors.Hypergrid +{ + public class GatekeeperServiceConnector : SimulationServiceConnector + { + protected override string AgentPath() + { + return "/foreignagent/"; + } + + protected override string ObjectPath() + { + return "/foreignobject/"; + } + + public GridRegion GetHomeRegion(GridRegion gatekeeper, UUID userID, out Vector3 position, out Vector3 lookAt) + { + position = Vector3.UnitY; lookAt = Vector3.UnitY; + + Hashtable hash = new Hashtable(); + hash["userID"] = userID.ToString(); + + IList paramList = new ArrayList(); + paramList.Add(hash); + + XmlRpcRequest request = new XmlRpcRequest("get_home_region", paramList); + string uri = "http://" + gatekeeper.ExternalHostName + ":" + gatekeeper.HttpPort + "/"; + XmlRpcResponse response = null; + try + { + response = request.Send(uri, 10000); + } + catch (Exception e) + { + return null; + } + + if (response.IsFault) + { + return null; + } + + 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) + { + GridRegion region = new GridRegion(); + + UUID.TryParse((string)hash["uuid"], out region.RegionID); + //m_log.Debug(">> HERE, uuid: " + region.RegionID); + int n = 0; + if (hash["x"] != null) + { + Int32.TryParse((string)hash["x"], out n); + region.RegionLocX = n; + //m_log.Debug(">> HERE, x: " + region.RegionLocX); + } + if (hash["y"] != null) + { + Int32.TryParse((string)hash["y"], out n); + region.RegionLocY = n; + //m_log.Debug(">> HERE, y: " + region.RegionLocY); + } + if (hash["region_name"] != null) + { + region.RegionName = (string)hash["region_name"]; + //m_log.Debug(">> HERE, name: " + region.RegionName); + } + if (hash["hostname"] != null) + region.ExternalHostName = (string)hash["hostname"]; + if (hash["http_port"] != null) + { + uint p = 0; + UInt32.TryParse((string)hash["http_port"], out p); + region.HttpPort = p; + } + if (hash["internal_port"] != null) + { + int p = 0; + Int32.TryParse((string)hash["internal_port"], out p); + region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p); + } + if (hash["position"] != null) + Vector3.TryParse((string)hash["position"], out position); + if (hash["lookAt"] != null) + Vector3.TryParse((string)hash["lookAt"], out lookAt); + + // Successful return + return region; + } + + } + catch (Exception e) + { + return null; + } + + return null; + + } + } +} diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs index 72db93f..55d9ce1 100644 --- a/OpenSim/Services/HypergridService/GatekeeperService.cs +++ b/OpenSim/Services/HypergridService/GatekeeperService.cs @@ -164,6 +164,7 @@ namespace OpenSim.Services.HypergridService return region; } + #region Login Agent public bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination, out string reason) { reason = string.Empty; @@ -221,7 +222,7 @@ namespace OpenSim.Services.HypergridService return m_SimulationService.CreateAgent(destination, aCircuit, 0, out reason); } - protected bool Authenticate(AgentCircuitData aCircuit) + protected bool Authenticate(AgentCircuitData aCircuit) { string authURL = string.Empty; if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) @@ -250,5 +251,40 @@ namespace OpenSim.Services.HypergridService return false; } + + #endregion + + public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt) + { + position = new Vector3(128, 128, 0); lookAt = Vector3.UnitY; + + m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to get home region of user {0}", userID); + + GridRegion home = null; + PresenceInfo[] presences = m_PresenceService.GetAgents(new string[] { userID.ToString() }); + if (presences != null && presences.Length > 0) + { + UUID homeID = presences[0].HomeRegionID; + if (homeID != UUID.Zero) + { + home = m_GridService.GetRegionByUUID(m_ScopeID, homeID); + position = presences[0].HomePosition; + lookAt = presences[0].HomeLookAt; + } + if (home == null) + { + List defs = m_GridService.GetDefaultRegions(m_ScopeID); + if (defs != null && defs.Count > 0) + home = defs[0]; + } + } + + return home; + } + + #region Misc + + + #endregion } } diff --git a/OpenSim/Services/HypergridService/HypergridService.cs b/OpenSim/Services/HypergridService/HypergridService.cs index 734931d..ac0f5ac 100644 --- a/OpenSim/Services/HypergridService/HypergridService.cs +++ b/OpenSim/Services/HypergridService/HypergridService.cs @@ -51,7 +51,7 @@ namespace OpenSim.Services.HypergridService private static HypergridService m_RootInstance = null; protected IConfigSource m_config; - protected IAuthenticationService m_AuthenticationService = null; + protected IPresenceService m_PresenceService = null; protected IGridService m_GridService; protected IAssetService m_AssetService; protected HypergridServiceConnector m_HypergridConnector; @@ -94,7 +94,7 @@ namespace OpenSim.Services.HypergridService if (gridConfig != null) { string gridService = gridConfig.GetString("GridService", string.Empty); - string authService = gridConfig.GetString("AuthenticationService", String.Empty); + string presenceService = gridConfig.GetString("PresenceService", String.Empty); string assetService = gridConfig.GetString("AssetService", string.Empty); Object[] args = new Object[] { config }; @@ -104,8 +104,8 @@ namespace OpenSim.Services.HypergridService if (m_GridService == null) throw new Exception("HypergridService cannot function without a GridService"); - if (authService != String.Empty) - m_AuthenticationService = ServerUtils.LoadPlugin(authService, args); + if (presenceService != String.Empty) + m_PresenceService = ServerUtils.LoadPlugin(presenceService, args); if (assetService != string.Empty) m_AssetService = ServerUtils.LoadPlugin(assetService, args); diff --git a/OpenSim/Services/Interfaces/IGatekeeperService.cs b/OpenSim/Services/Interfaces/IGatekeeperService.cs index d41df75..59e0f82 100644 --- a/OpenSim/Services/Interfaces/IGatekeeperService.cs +++ b/OpenSim/Services/Interfaces/IGatekeeperService.cs @@ -39,5 +39,8 @@ namespace OpenSim.Services.Interfaces GridRegion GetHyperlinkRegion(UUID regionID); bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination, out string reason); + + GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt); + } } -- cgit v1.1