From 4df1d25d23d76ee3ae8c7da155462b57735f6418 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 9 Dec 2010 01:55:32 +0000 Subject: Plumb a code path for the entity transfer module to ask a destination scene whether or not an agent is allowed there as a root agent. --- .../Simulation/SimulationServiceConnector.cs | 59 ++++++++++++++++++++++ OpenSim/Services/Interfaces/ISimulationService.cs | 2 + 2 files changed, 61 insertions(+) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index 3b907c1..e2032d9 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs @@ -409,6 +409,65 @@ namespace OpenSim.Services.Connectors.Simulation return false; } + public bool QueryAccess(GridRegion destination, UUID id) + { + IPEndPoint ext = destination.ExternalEndPoint; + if (ext == null) return false; + // Eventually, we want to use a caps url instead of the agentID + string uri = destination.ServerURI + AgentPath() + id + "/" + destination.RegionID.ToString() + "/"; + + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); + request.Method = "QUERYACCESS"; + request.Timeout = 10000; + //request.Headers.Add("authorization", ""); // coming soon + + HttpWebResponse webResponse = null; + string reply = string.Empty; + StreamReader sr = null; + try + { + webResponse = (HttpWebResponse)request.GetResponse(); + if (webResponse == null) + { + m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Null reply on agent query "); + } + + sr = new StreamReader(webResponse.GetResponseStream()); + reply = sr.ReadToEnd().Trim(); + + + } + catch (WebException ex) + { + m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of agent query {0}", ex.Message); + // ignore, really + return false; + } + finally + { + if (sr != null) + sr.Close(); + } + + if (webResponse.StatusCode == HttpStatusCode.OK) + { + try + { + bool result; + + result = bool.Parse(reply); + + return result; + } + catch + { + return false; + } + } + + return false; + } + public bool ReleaseAgent(UUID origin, UUID id, string uri) { WebRequest request = WebRequest.Create(uri); diff --git a/OpenSim/Services/Interfaces/ISimulationService.cs b/OpenSim/Services/Interfaces/ISimulationService.cs index 67d7cbe..12e8982 100644 --- a/OpenSim/Services/Interfaces/ISimulationService.cs +++ b/OpenSim/Services/Interfaces/ISimulationService.cs @@ -60,6 +60,8 @@ namespace OpenSim.Services.Interfaces bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent); + bool QueryAccess(GridRegion destination, UUID id); + /// /// Message from receiving region to departing region, telling it got contacted by the client. /// When sent over REST, it invokes the opaque uri. -- cgit v1.1