From f4efa325bb8a1e4ae876ec5f080cf87c1f8c1de9 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 31 Dec 2009 11:42:33 -0800 Subject: More progress on both the Simulation service and the Login service. Both still unfinished. --- .../Simulation/SimulationServiceConnector.cs | 242 +++++++++++++++++++++ 1 file changed, 242 insertions(+) create mode 100644 OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs (limited to 'OpenSim/Services/Connectors/Simulation') diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs new file mode 100644 index 0000000..6f71197 --- /dev/null +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs @@ -0,0 +1,242 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Net; +using System.Reflection; +using System.Text; + +using OpenSim.Framework; +using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + +using OpenMetaverse; +using OpenMetaverse.StructuredData; +using log4net; + +namespace OpenSim.Services.Connectors.Simulation +{ + public class SimulationServiceConnector : ISimulationService + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private GridRegion m_Region; + + public SimulationServiceConnector() + { + } + + public SimulationServiceConnector(GridRegion region) + { + m_Region = region; + } + + public IScene GetScene(ulong regionHandle) + { + return null; + } + + #region Agents + + public bool CreateAgent(ulong regionHandle, AgentCircuitData aCircuit, uint flags, out string reason) + { + reason = String.Empty; + + // Eventually, we want to use a caps url instead of the agentID + string uri = string.Empty; + try + { + uri = "http://" + m_Region.ExternalEndPoint.Address + ":" + m_Region.HttpPort + "/agent/" + aCircuit.AgentID + "/"; + } + catch (Exception e) + { + m_log.Debug("[REST COMMS]: Unable to resolve external endpoint on agent create. Reason: " + e.Message); + reason = e.Message; + return false; + } + + //Console.WriteLine(" >>> DoCreateChildAgentCall <<< " + uri); + + HttpWebRequest AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri); + AgentCreateRequest.Method = "POST"; + AgentCreateRequest.ContentType = "application/json"; + AgentCreateRequest.Timeout = 10000; + //AgentCreateRequest.KeepAlive = false; + //AgentCreateRequest.Headers.Add("Authorization", authKey); + + // Fill it in + OSDMap args = null; + try + { + args = aCircuit.PackAgentCircuitData(); + } + catch (Exception e) + { + m_log.Debug("[REST COMMS]: PackAgentCircuitData failed with exception: " + e.Message); + } + // Add the regionhandle and the name of the destination region + args["destination_handle"] = OSD.FromString(m_Region.RegionHandle.ToString()); + args["destination_name"] = OSD.FromString(m_Region.RegionName); + args["teleport_flags"] = OSD.FromString(flags.ToString()); + + string strBuffer = ""; + byte[] buffer = new byte[1]; + try + { + strBuffer = OSDParser.SerializeJsonString(args); + Encoding str = Util.UTF8; + buffer = str.GetBytes(strBuffer); + + } + catch (Exception e) + { + m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of ChildCreate: {0}", e.Message); + // ignore. buffer will be empty, caller should check. + } + + Stream os = null; + try + { // send the Post + AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send + os = AgentCreateRequest.GetRequestStream(); + os.Write(buffer, 0, strBuffer.Length); //Send it + //m_log.InfoFormat("[REST COMMS]: Posted CreateChildAgent request to remote sim {0}", uri); + } + //catch (WebException ex) + catch + { + //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message); + reason = "cannot contact remote region"; + return false; + } + finally + { + if (os != null) + os.Close(); + } + + // Let's wait for the response + //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); + + WebResponse webResponse = null; + StreamReader sr = null; + try + { + webResponse = AgentCreateRequest.GetResponse(); + if (webResponse == null) + { + m_log.Info("[REST COMMS]: Null reply on DoCreateChildAgentCall post"); + } + else + { + + sr = new StreamReader(webResponse.GetResponseStream()); + string response = sr.ReadToEnd().Trim(); + m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", response); + + if (!String.IsNullOrEmpty(response)) + { + try + { + // we assume we got an OSDMap back + OSDMap r = Util.GetOSDMap(response); + bool success = r["success"].AsBoolean(); + reason = r["reason"].AsString(); + return success; + } + catch (NullReferenceException e) + { + m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", e.Message); + + // check for old style response + if (response.ToLower().StartsWith("true")) + return true; + + return false; + } + } + } + } + catch (WebException ex) + { + m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); + // ignore, really + } + finally + { + if (sr != null) + sr.Close(); + } + + return true; + } + + public bool UpdateAgent(ulong regionHandle, AgentData data) + { + return false; + } + + public bool UpdateAgent(ulong regionHandle, AgentPosition data) + { + return false; + } + + public bool RetrieveAgent(ulong regionHandle, UUID id, out IAgentData agent) + { + agent = null; + return false; + } + + public bool ReleaseAgent(ulong regionHandle, UUID id, string uri) + { + return false; + } + + public bool CloseAgent(ulong regionHandle, UUID id) + { + return false; + } + + #endregion Agents + + #region Objects + + public bool CreateObject(ulong regionHandle, ISceneObject sog, bool isLocalCall) + { + return false; + } + + public bool CreateObject(ulong regionHandle, UUID userID, UUID itemID) + { + return false; + } + + #endregion Objects + } +} -- cgit v1.1 From c268e342d19b6cc5969b1c1d94f20a3f4eb844ef Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 3 Jan 2010 09:35:12 -0800 Subject: * Changed ISimulation interface to take a GridRegion as input arg instead of a regionHandle. * Added the RemoteSimulationConnectorModule, which is the replacement for RESTComms. Scenes is not using this yet, only (standalone) Login uses these region modules for now. * Completed SimulationServiceConnector and corresponding handlers. --- .../Simulation/SimulationServiceConnector.cs | 215 ++++++++++++++++++--- 1 file changed, 189 insertions(+), 26 deletions(-) (limited to 'OpenSim/Services/Connectors/Simulation') diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index 6f71197..fcf07c7 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs @@ -46,7 +46,7 @@ namespace OpenSim.Services.Connectors.Simulation { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private GridRegion m_Region; + //private GridRegion m_Region; public SimulationServiceConnector() { @@ -54,7 +54,7 @@ namespace OpenSim.Services.Connectors.Simulation public SimulationServiceConnector(GridRegion region) { - m_Region = region; + //m_Region = region; } public IScene GetScene(ulong regionHandle) @@ -64,7 +64,7 @@ namespace OpenSim.Services.Connectors.Simulation #region Agents - public bool CreateAgent(ulong regionHandle, AgentCircuitData aCircuit, uint flags, out string reason) + public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason) { reason = String.Empty; @@ -72,11 +72,11 @@ namespace OpenSim.Services.Connectors.Simulation string uri = string.Empty; try { - uri = "http://" + m_Region.ExternalEndPoint.Address + ":" + m_Region.HttpPort + "/agent/" + aCircuit.AgentID + "/"; + uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/agent/" + aCircuit.AgentID + "/"; } catch (Exception e) { - m_log.Debug("[REST COMMS]: Unable to resolve external endpoint on agent create. Reason: " + e.Message); + m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Unable to resolve external endpoint on agent create. Reason: " + e.Message); reason = e.Message; return false; } @@ -98,11 +98,13 @@ namespace OpenSim.Services.Connectors.Simulation } catch (Exception e) { - m_log.Debug("[REST COMMS]: PackAgentCircuitData failed with exception: " + e.Message); + m_log.Debug("[REMOTE SIMULATION CONNECTOR]: PackAgentCircuitData failed with exception: " + e.Message); } - // Add the regionhandle and the name of the destination region - args["destination_handle"] = OSD.FromString(m_Region.RegionHandle.ToString()); - args["destination_name"] = OSD.FromString(m_Region.RegionName); + // Add the input arguments + args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString()); + args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); + args["destination_name"] = OSD.FromString(destination.RegionName); + args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); args["teleport_flags"] = OSD.FromString(flags.ToString()); string strBuffer = ""; @@ -116,7 +118,7 @@ namespace OpenSim.Services.Connectors.Simulation } catch (Exception e) { - m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of ChildCreate: {0}", e.Message); + m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR]: Exception thrown on serialization of ChildCreate: {0}", e.Message); // ignore. buffer will be empty, caller should check. } @@ -126,12 +128,12 @@ namespace OpenSim.Services.Connectors.Simulation AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send os = AgentCreateRequest.GetRequestStream(); os.Write(buffer, 0, strBuffer.Length); //Send it - //m_log.InfoFormat("[REST COMMS]: Posted CreateChildAgent request to remote sim {0}", uri); + //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Posted CreateChildAgent request to remote sim {0}", uri); } //catch (WebException ex) catch { - //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message); + //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Bad send on ChildAgentUpdate {0}", ex.Message); reason = "cannot contact remote region"; return false; } @@ -142,7 +144,7 @@ namespace OpenSim.Services.Connectors.Simulation } // Let's wait for the response - //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); + //m_log.Info("[REMOTE SIMULATION CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall"); WebResponse webResponse = null; StreamReader sr = null; @@ -151,14 +153,14 @@ namespace OpenSim.Services.Connectors.Simulation webResponse = AgentCreateRequest.GetResponse(); if (webResponse == null) { - m_log.Info("[REST COMMS]: Null reply on DoCreateChildAgentCall post"); + m_log.Info("[REMOTE SIMULATION CONNECTOR]: Null reply on DoCreateChildAgentCall post"); } else { sr = new StreamReader(webResponse.GetResponseStream()); string response = sr.ReadToEnd().Trim(); - m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", response); + m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response); if (!String.IsNullOrEmpty(response)) { @@ -172,7 +174,7 @@ namespace OpenSim.Services.Connectors.Simulation } catch (NullReferenceException e) { - m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", e.Message); + m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message); // check for old style response if (response.ToLower().StartsWith("true")) @@ -185,7 +187,7 @@ namespace OpenSim.Services.Connectors.Simulation } catch (WebException ex) { - m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); + m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); // ignore, really } finally @@ -197,28 +199,189 @@ namespace OpenSim.Services.Connectors.Simulation return true; } - public bool UpdateAgent(ulong regionHandle, AgentData data) + public bool UpdateAgent(GridRegion destination, AgentData data) { - return false; + return UpdateAgent(destination, data); } - public bool UpdateAgent(ulong regionHandle, AgentPosition data) + public bool UpdateAgent(GridRegion destination, AgentPosition data) { - return false; + return UpdateAgent(destination, data); } - public bool RetrieveAgent(ulong regionHandle, UUID id, out IAgentData agent) + private bool UpdateAgent(GridRegion destination, IAgentData cAgentData) + { + // Eventually, we want to use a caps url instead of the agentID + string uri = string.Empty; + try + { + uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/agent/" + cAgentData.AgentID + "/"; + } + catch (Exception e) + { + m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Unable to resolve external endpoint on agent update. Reason: " + e.Message); + return false; + } + //Console.WriteLine(" >>> DoChildAgentUpdateCall <<< " + uri); + + HttpWebRequest ChildUpdateRequest = (HttpWebRequest)WebRequest.Create(uri); + ChildUpdateRequest.Method = "PUT"; + ChildUpdateRequest.ContentType = "application/json"; + ChildUpdateRequest.Timeout = 10000; + //ChildUpdateRequest.KeepAlive = false; + + // Fill it in + OSDMap args = null; + try + { + args = cAgentData.Pack(); + } + catch (Exception e) + { + m_log.Debug("[REMOTE SIMULATION CONNECTOR]: PackUpdateMessage failed with exception: " + e.Message); + } + // Add the input arguments + args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString()); + args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); + args["destination_name"] = OSD.FromString(destination.RegionName); + args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); + + string strBuffer = ""; + byte[] buffer = new byte[1]; + try + { + strBuffer = OSDParser.SerializeJsonString(args); + Encoding str = Util.UTF8; + buffer = str.GetBytes(strBuffer); + + } + catch (Exception e) + { + m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR]: Exception thrown on serialization of ChildUpdate: {0}", e.Message); + // ignore. buffer will be empty, caller should check. + } + + Stream os = null; + try + { // send the Post + ChildUpdateRequest.ContentLength = buffer.Length; //Count bytes to send + os = ChildUpdateRequest.GetRequestStream(); + os.Write(buffer, 0, strBuffer.Length); //Send it + //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Posted ChildAgentUpdate request to remote sim {0}", uri); + } + //catch (WebException ex) + catch + { + //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Bad send on ChildAgentUpdate {0}", ex.Message); + + return false; + } + finally + { + if (os != null) + os.Close(); + } + + // Let's wait for the response + //m_log.Info("[REMOTE SIMULATION CONNECTOR]: Waiting for a reply after ChildAgentUpdate"); + + WebResponse webResponse = null; + StreamReader sr = null; + try + { + webResponse = ChildUpdateRequest.GetResponse(); + if (webResponse == null) + { + m_log.Info("[REMOTE SIMULATION CONNECTOR]: Null reply on ChilAgentUpdate post"); + } + + sr = new StreamReader(webResponse.GetResponseStream()); + //reply = sr.ReadToEnd().Trim(); + sr.ReadToEnd().Trim(); + sr.Close(); + //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: ChilAgentUpdate reply was {0} ", reply); + + } + catch (WebException ex) + { + m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of ChilAgentUpdate {0}", ex.Message); + // ignore, really + } + finally + { + if (sr != null) + sr.Close(); + } + + return true; + } + + public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) { agent = null; + // Eventually, we want to use a caps url instead of the agentID + string uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/agent/" + id + "/" + destination.RegionID.ToString() + "/"; + //Console.WriteLine(" >>> DoRetrieveRootAgentCall <<< " + uri); + + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); + request.Method = "GET"; + 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.Info("[REMOTE SIMULATION CONNECTOR]: Null reply on agent get "); + } + + sr = new StreamReader(webResponse.GetResponseStream()); + reply = sr.ReadToEnd().Trim(); + + //Console.WriteLine("[REMOTE SIMULATION CONNECTOR]: ChilAgentUpdate reply was " + reply); + + } + catch (WebException ex) + { + m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of agent get {0}", ex.Message); + // ignore, really + return false; + } + finally + { + if (sr != null) + sr.Close(); + } + + if (webResponse.StatusCode == HttpStatusCode.OK) + { + // we know it's jason + OSDMap args = Util.GetOSDMap(reply); + if (args == null) + { + //Console.WriteLine("[REMOTE SIMULATION CONNECTOR]: Error getting OSDMap from reply"); + return false; + } + + agent = new CompleteAgentData(); + agent.Unpack(args); + return true; + } + + //Console.WriteLine("[REMOTE SIMULATION CONNECTOR]: DoRetrieveRootAgentCall returned status " + webResponse.StatusCode); return false; } - public bool ReleaseAgent(ulong regionHandle, UUID id, string uri) + public bool ReleaseAgent(GridRegion destination, UUID id, string uri) { return false; } - public bool CloseAgent(ulong regionHandle, UUID id) + public bool CloseAgent(GridRegion destination, UUID id) { return false; } @@ -227,12 +390,12 @@ namespace OpenSim.Services.Connectors.Simulation #region Objects - public bool CreateObject(ulong regionHandle, ISceneObject sog, bool isLocalCall) + public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) { return false; } - public bool CreateObject(ulong regionHandle, UUID userID, UUID itemID) + public bool CreateObject(GridRegion destination, UUID userID, UUID itemID) { return false; } -- cgit v1.1 From 99efa99585639c94fdb484681663ac7b6f03538e Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 3 Jan 2010 11:44:57 -0800 Subject: Successfully logged into a grid. --- .../Connectors/Simulation/SimulationServiceConnector.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services/Connectors/Simulation') diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index fcf07c7..dc532d0 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs @@ -39,6 +39,7 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenMetaverse; using OpenMetaverse.StructuredData; using log4net; +using Nini.Config; namespace OpenSim.Services.Connectors.Simulation { @@ -52,7 +53,7 @@ namespace OpenSim.Services.Connectors.Simulation { } - public SimulationServiceConnector(GridRegion region) + public SimulationServiceConnector(IConfigSource config) { //m_Region = region; } @@ -68,6 +69,13 @@ namespace OpenSim.Services.Connectors.Simulation { reason = String.Empty; + if (destination == null) + { + reason = "Destination is null"; + m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Given destination is null"); + return false; + } + // Eventually, we want to use a caps url instead of the agentID string uri = string.Empty; try @@ -128,7 +136,8 @@ namespace OpenSim.Services.Connectors.Simulation AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send os = AgentCreateRequest.GetRequestStream(); os.Write(buffer, 0, strBuffer.Length); //Send it - //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Posted CreateChildAgent request to remote sim {0}", uri); + m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Posted CreateAgent request to remote sim {0}, region {1}, x={2} y={3}", + uri, destination.RegionName, destination.RegionLocX, destination.RegionLocY); } //catch (WebException ex) catch -- cgit v1.1 From f11a97f12d328af8bb39b92fec5cb5780983b66a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 7 Jan 2010 15:53:55 -0800 Subject: * Finished SimulationServiceConnector * Started rerouting calls to UserService. * Compiles. May run. --- .../Simulation/SimulationServiceConnector.cs | 169 ++++++++++++++++++++- 1 file changed, 165 insertions(+), 4 deletions(-) (limited to 'OpenSim/Services/Connectors/Simulation') diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index dc532d0..76558aa 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs @@ -385,14 +385,89 @@ namespace OpenSim.Services.Connectors.Simulation return false; } - public bool ReleaseAgent(GridRegion destination, UUID id, string uri) + public bool ReleaseAgent(UUID origin, UUID id, string uri) { - return false; + WebRequest request = WebRequest.Create(uri); + request.Method = "DELETE"; + request.Timeout = 10000; + + StreamReader sr = null; + try + { + WebResponse webResponse = request.GetResponse(); + if (webResponse == null) + { + m_log.Info("[REMOTE SIMULATION CONNECTOR]: Null reply on ReleaseAgent"); + } + + sr = new StreamReader(webResponse.GetResponseStream()); + //reply = sr.ReadToEnd().Trim(); + sr.ReadToEnd().Trim(); + sr.Close(); + //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: ChilAgentUpdate reply was {0} ", reply); + + } + catch (WebException ex) + { + m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of ReleaseAgent {0}", ex.Message); + return false; + } + finally + { + if (sr != null) + sr.Close(); + } + + return true; } public bool CloseAgent(GridRegion destination, UUID id) { - return false; + string uri = string.Empty; + try + { + uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/agent/" + id + "/" + destination.RegionHandle.ToString() + "/"; + } + catch (Exception e) + { + m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Unable to resolve external endpoint on agent close. Reason: " + e.Message); + return false; + } + + //Console.WriteLine(" >>> DoCloseAgentCall <<< " + uri); + + WebRequest request = WebRequest.Create(uri); + request.Method = "DELETE"; + request.Timeout = 10000; + + StreamReader sr = null; + try + { + WebResponse webResponse = request.GetResponse(); + if (webResponse == null) + { + m_log.Info("[REMOTE SIMULATION CONNECTOR]: Null reply on agent delete "); + } + + sr = new StreamReader(webResponse.GetResponseStream()); + //reply = sr.ReadToEnd().Trim(); + sr.ReadToEnd().Trim(); + sr.Close(); + //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: ChilAgentUpdate reply was {0} ", reply); + + } + catch (WebException ex) + { + m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of agent delete {0}", ex.Message); + return false; + } + finally + { + if (sr != null) + sr.Close(); + } + + return true; } #endregion Agents @@ -401,11 +476,97 @@ namespace OpenSim.Services.Connectors.Simulation public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) { - return false; + string uri + = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/object/" + sog.UUID + "/"; + //m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri); + + WebRequest ObjectCreateRequest = WebRequest.Create(uri); + ObjectCreateRequest.Method = "POST"; + ObjectCreateRequest.ContentType = "application/json"; + ObjectCreateRequest.Timeout = 10000; + + OSDMap args = new OSDMap(2); + args["sog"] = OSD.FromString(sog.ToXml2()); + args["extra"] = OSD.FromString(sog.ExtraToXmlString()); + string state = sog.GetStateSnapshot(); + if (state.Length > 0) + args["state"] = OSD.FromString(state); + // Add the input general arguments + args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString()); + args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); + args["destination_name"] = OSD.FromString(destination.RegionName); + args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); + + string strBuffer = ""; + byte[] buffer = new byte[1]; + try + { + strBuffer = OSDParser.SerializeJsonString(args); + Encoding str = Util.UTF8; + buffer = str.GetBytes(strBuffer); + + } + catch (Exception e) + { + m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR]: Exception thrown on serialization of CreateObject: {0}", e.Message); + // ignore. buffer will be empty, caller should check. + } + + Stream os = null; + try + { // send the Post + ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send + os = ObjectCreateRequest.GetRequestStream(); + os.Write(buffer, 0, strBuffer.Length); //Send it + m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Posted CreateObject request to remote sim {0}", uri); + } + catch (WebException ex) + { + m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Bad send on CreateObject {0}", ex.Message); + return false; + } + finally + { + if (os != null) + os.Close(); + } + + // Let's wait for the response + //m_log.Info("[REMOTE SIMULATION CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall"); + + StreamReader sr = null; + try + { + WebResponse webResponse = ObjectCreateRequest.GetResponse(); + if (webResponse == null) + { + m_log.Info("[REMOTE SIMULATION CONNECTOR]: Null reply on CreateObject post"); + return false; + } + + sr = new StreamReader(webResponse.GetResponseStream()); + //reply = sr.ReadToEnd().Trim(); + sr.ReadToEnd().Trim(); + //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: DoCreateChildAgentCall reply was {0} ", reply); + + } + catch (WebException ex) + { + m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of CreateObject {0}", ex.Message); + return false; + } + finally + { + if (sr != null) + sr.Close(); + } + + return true; } public bool CreateObject(GridRegion destination, UUID userID, UUID itemID) { + // TODO, not that urgent return false; } -- cgit v1.1 From 66920a9047b54db947d02f252e17409b7fc32ef0 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 12 Jan 2010 09:22:58 -0800 Subject: Fixed more appearance woes that showed up using remote connectors. Appearance is now being passed with AgentCircuitData, as it should be. --- .../Connectors/Simulation/SimulationServiceConnector.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'OpenSim/Services/Connectors/Simulation') diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index 76558aa..bd72570 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs @@ -210,12 +210,12 @@ namespace OpenSim.Services.Connectors.Simulation public bool UpdateAgent(GridRegion destination, AgentData data) { - return UpdateAgent(destination, data); + return UpdateAgent(destination, (IAgentData)data); } public bool UpdateAgent(GridRegion destination, AgentPosition data) { - return UpdateAgent(destination, data); + return UpdateAgent(destination, (IAgentData)data); } private bool UpdateAgent(GridRegion destination, IAgentData cAgentData) @@ -231,7 +231,7 @@ namespace OpenSim.Services.Connectors.Simulation m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Unable to resolve external endpoint on agent update. Reason: " + e.Message); return false; } - //Console.WriteLine(" >>> DoChildAgentUpdateCall <<< " + uri); + Console.WriteLine(" >>> DoAgentUpdateCall <<< " + uri); HttpWebRequest ChildUpdateRequest = (HttpWebRequest)WebRequest.Create(uri); ChildUpdateRequest.Method = "PUT"; @@ -276,12 +276,12 @@ namespace OpenSim.Services.Connectors.Simulation ChildUpdateRequest.ContentLength = buffer.Length; //Count bytes to send os = ChildUpdateRequest.GetRequestStream(); os.Write(buffer, 0, strBuffer.Length); //Send it - //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Posted ChildAgentUpdate request to remote sim {0}", uri); + m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Posted AgentUpdate request to remote sim {0}", uri); } - //catch (WebException ex) - catch + catch (WebException ex) + //catch { - //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Bad send on ChildAgentUpdate {0}", ex.Message); + m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Bad send on AgentUpdate {0}", ex.Message); return false; } -- cgit v1.1 From 7356860b487febd12c2e0de2f009a6df9ea0aeec Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 13 Jan 2010 09:17:30 -0800 Subject: Several more buglets removed. --- OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services/Connectors/Simulation') diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index bd72570..6d588de 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs @@ -231,7 +231,7 @@ namespace OpenSim.Services.Connectors.Simulation m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Unable to resolve external endpoint on agent update. Reason: " + e.Message); return false; } - Console.WriteLine(" >>> DoAgentUpdateCall <<< " + uri); + //Console.WriteLine(" >>> DoAgentUpdateCall <<< " + uri); HttpWebRequest ChildUpdateRequest = (HttpWebRequest)WebRequest.Create(uri); ChildUpdateRequest.Method = "PUT"; @@ -478,7 +478,7 @@ namespace OpenSim.Services.Connectors.Simulation { string uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/object/" + sog.UUID + "/"; - //m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri); + //m_log.Debug(" >>> DoCreateObjectCall <<< " + uri); WebRequest ObjectCreateRequest = WebRequest.Create(uri); ObjectCreateRequest.Method = "POST"; -- cgit v1.1 From 640712fe88961ba04a09e7e5ec2c9be825c1faca Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 13 Jan 2010 09:38:09 -0800 Subject: * Removed debug messages. * Everything works! (everything that was tested; lots of things to test) --- OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Services/Connectors/Simulation') diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index 6d588de..cf8ab50 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs @@ -276,7 +276,7 @@ namespace OpenSim.Services.Connectors.Simulation ChildUpdateRequest.ContentLength = buffer.Length; //Count bytes to send os = ChildUpdateRequest.GetRequestStream(); os.Write(buffer, 0, strBuffer.Length); //Send it - m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Posted AgentUpdate request to remote sim {0}", uri); + //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Posted AgentUpdate request to remote sim {0}", uri); } catch (WebException ex) //catch -- cgit v1.1 From 901e94c836b8c460e6bd2e4f16835e139abaefd6 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 13 Jan 2010 09:54:27 -0800 Subject: One more buglet removed: send the region UUID, not the region handle. --- OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Services/Connectors/Simulation') diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index cf8ab50..b1b2a30 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs @@ -426,7 +426,7 @@ namespace OpenSim.Services.Connectors.Simulation string uri = string.Empty; try { - uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/agent/" + id + "/" + destination.RegionHandle.ToString() + "/"; + uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/agent/" + id + "/" + destination.RegionID.ToString() + "/"; } catch (Exception e) { -- cgit v1.1 From b2e6ec9e12ad07eb08496ebe8ca0476b793017d5 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 17 Jan 2010 18:04:55 -0800 Subject: Agent gets there through the Gatekeeper, but still a few quirks to fix. --- .../Simulation/SimulationServiceConnector.cs | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'OpenSim/Services/Connectors/Simulation') diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index b1b2a30..683fe79 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs @@ -65,6 +65,11 @@ namespace OpenSim.Services.Connectors.Simulation #region Agents + protected virtual string AgentPath() + { + return "/agent/"; + } + public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason) { reason = String.Empty; @@ -80,7 +85,7 @@ namespace OpenSim.Services.Connectors.Simulation string uri = string.Empty; try { - uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/agent/" + aCircuit.AgentID + "/"; + uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + AgentPath() + aCircuit.AgentID + "/"; } catch (Exception e) { @@ -197,7 +202,8 @@ namespace OpenSim.Services.Connectors.Simulation catch (WebException ex) { m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); - // ignore, really + reason = "Destination did not reply"; + return false; } finally { @@ -224,7 +230,7 @@ namespace OpenSim.Services.Connectors.Simulation string uri = string.Empty; try { - uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/agent/" + cAgentData.AgentID + "/"; + uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + AgentPath() + cAgentData.AgentID + "/"; } catch (Exception e) { @@ -329,7 +335,7 @@ namespace OpenSim.Services.Connectors.Simulation { agent = null; // Eventually, we want to use a caps url instead of the agentID - string uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/agent/" + id + "/" + destination.RegionID.ToString() + "/"; + string uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + AgentPath() + id + "/" + destination.RegionID.ToString() + "/"; //Console.WriteLine(" >>> DoRetrieveRootAgentCall <<< " + uri); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); @@ -426,7 +432,7 @@ namespace OpenSim.Services.Connectors.Simulation string uri = string.Empty; try { - uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/agent/" + id + "/" + destination.RegionID.ToString() + "/"; + uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + AgentPath() + id + "/" + destination.RegionID.ToString() + "/"; } catch (Exception e) { @@ -474,10 +480,15 @@ namespace OpenSim.Services.Connectors.Simulation #region Objects + protected virtual string ObjectPath() + { + return "/object/"; + } + public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) { string uri - = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/object/" + sog.UUID + "/"; + = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + ObjectPath() + sog.UUID + "/"; //m_log.Debug(" >>> DoCreateObjectCall <<< " + uri); WebRequest ObjectCreateRequest = WebRequest.Create(uri); -- cgit v1.1 From 00f7d622cbc2c2e61d2efaacd8275da3f9821d8b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 28 Jan 2010 19:19:42 -0800 Subject: HG 1.5 is in place. Tested in standalone only. --- .../Simulation/SimulationServiceConnector.cs | 37 +++++++++++++--------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'OpenSim/Services/Connectors/Simulation') diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index 683fe79..e2ab179 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs @@ -104,21 +104,7 @@ namespace OpenSim.Services.Connectors.Simulation //AgentCreateRequest.Headers.Add("Authorization", authKey); // Fill it in - OSDMap args = null; - try - { - args = aCircuit.PackAgentCircuitData(); - } - catch (Exception e) - { - m_log.Debug("[REMOTE SIMULATION CONNECTOR]: PackAgentCircuitData failed with exception: " + e.Message); - } - // Add the input arguments - args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString()); - args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); - args["destination_name"] = OSD.FromString(destination.RegionName); - args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); - args["teleport_flags"] = OSD.FromString(flags.ToString()); + OSDMap args = PackCreateAgentArguments(aCircuit, destination, flags); string strBuffer = ""; byte[] buffer = new byte[1]; @@ -214,6 +200,27 @@ namespace OpenSim.Services.Connectors.Simulation return true; } + protected virtual OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion destination, uint flags) + { + OSDMap args = null; + try + { + args = aCircuit.PackAgentCircuitData(); + } + catch (Exception e) + { + m_log.Debug("[REMOTE SIMULATION CONNECTOR]: PackAgentCircuitData failed with exception: " + e.Message); + } + // Add the input arguments + args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString()); + args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); + args["destination_name"] = OSD.FromString(destination.RegionName); + args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); + args["teleport_flags"] = OSD.FromString(flags.ToString()); + + return args; + } + public bool UpdateAgent(GridRegion destination, AgentData data) { return UpdateAgent(destination, (IAgentData)data); -- cgit v1.1 From 0c81966c0a8f69474fb542d7b4df1780ef756519 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 29 Jan 2010 09:12:22 -0800 Subject: Works for grid login. --- OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Services/Connectors/Simulation') diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index e2ab179..d3be1a8 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs @@ -105,6 +105,8 @@ namespace OpenSim.Services.Connectors.Simulation // Fill it in OSDMap args = PackCreateAgentArguments(aCircuit, destination, flags); + if (args == null) + return false; string strBuffer = ""; byte[] buffer = new byte[1]; @@ -210,6 +212,7 @@ namespace OpenSim.Services.Connectors.Simulation catch (Exception e) { m_log.Debug("[REMOTE SIMULATION CONNECTOR]: PackAgentCircuitData failed with exception: " + e.Message); + return null; } // Add the input arguments args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString()); -- cgit v1.1