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.
---
.../Resources/CoreModulePlugin.addin.xml | 2 +
.../SimulationServiceInConnectorModule.cs | 9 +-
.../Simulation/LocalSimulationConnector.cs | 129 +++++---
.../Simulation/RemoteSimulationConnector.cs | 356 +++++++++++++++++++++
.../Server/Handlers/Simulation/AgentHandlers.cs | 244 ++++----------
.../Server/Handlers/Simulation/ObjectHandlers.cs | 64 +++-
.../Simulation/SimulationServiceInConnector.cs | 6 +-
OpenSim/Server/Handlers/Simulation/Utils.cs | 6 +-
.../Simulation/SimulationServiceConnector.cs | 215 +++++++++++--
OpenSim/Services/Interfaces/ISimulationService.cs | 18 +-
OpenSim/Services/LLLoginService/LLLoginService.cs | 2 +-
bin/config-include/StandaloneHypergrid.ini | 1 +
12 files changed, 763 insertions(+), 289 deletions(-)
create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
index 8b831a5..7b9fdee 100644
--- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
+++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
@@ -56,6 +56,7 @@
+
@@ -63,6 +64,7 @@
\
\
\
+ \
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs
index f28a318..03a5124 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs
@@ -58,11 +58,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation
IConfig moduleConfig = config.Configs["Modules"];
if (moduleConfig != null)
{
- string name = moduleConfig.GetString("SimulationService", "");
- if (name == Name)
+ m_Enabled = moduleConfig.GetBoolean("SimulationServiceInConnector", false);
+ if (m_Enabled)
{
- m_Enabled = true;
- m_log.Info("[SIM SERVICE]: SimulationService enabled");
+ m_log.Info("[SIM SERVICE]: SimulationService IN connector enabled");
}
}
@@ -84,7 +83,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation
public string Name
{
- get { return "SimulationService"; }
+ get { return "SimulationServiceInConnectorModule"; }
}
public void AddRegion(Scene scene)
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
index 430cc6e..074bfb5 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
@@ -34,6 +34,7 @@ using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
{
@@ -42,13 +43,30 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private List m_sceneList = new List();
+ private bool m_ModuleEnabled = false;
#region IRegionModule
public void Initialise(IConfigSource config)
{
- // This module is always on
- m_log.Debug("[LOCAL SIMULATION]: Enabling LocalSimulation module");
+ IConfig moduleConfig = config.Configs["Modules"];
+ if (moduleConfig != null)
+ {
+ string name = moduleConfig.GetString("SimulationServices", "");
+ if (name == Name)
+ {
+ //IConfig userConfig = config.Configs["SimulationService"];
+ //if (userConfig == null)
+ //{
+ // m_log.Error("[AVATAR CONNECTOR]: SimulationService missing from OpanSim.ini");
+ // return;
+ //}
+
+ m_ModuleEnabled = true;
+
+ m_log.Info("[SIMULATION CONNECTOR]: Local simulation enabled");
+ }
+ }
}
public void PostInitialise()
@@ -57,16 +75,24 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
public void AddRegion(Scene scene)
{
+ if (!m_ModuleEnabled)
+ return;
+
+ Init(scene);
+ scene.RegisterModuleInterface(this);
}
public void RemoveRegion(Scene scene)
{
+ if (!m_ModuleEnabled)
+ return;
+
RemoveScene(scene);
+ scene.UnregisterModuleInterface(this);
}
public void RegionLoaded(Scene scene)
{
- Init(scene);
}
public void Close()
@@ -109,7 +135,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
lock (m_sceneList)
{
m_sceneList.Add(scene);
- scene.RegisterModuleInterface(this);
}
}
@@ -119,16 +144,33 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
#region ISimulation
+ public IScene GetScene(ulong regionhandle)
+ {
+ foreach (Scene s in m_sceneList)
+ {
+ if (s.RegionInfo.RegionHandle == regionhandle)
+ return s;
+ }
+ // ? weird. should not happen
+ return m_sceneList[0];
+ }
+
/**
* Agent-related communications
*/
- public bool CreateAgent(ulong regionHandle, AgentCircuitData aCircuit, uint teleportFlags, out string reason)
+ public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason)
{
+ if (destination == null)
+ {
+ reason = "Given destination was null";
+ m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: CreateAgent was given a null destination");
+ return false;
+ }
foreach (Scene s in m_sceneList)
{
- if (s.RegionInfo.RegionHandle == regionHandle)
+ if (s.RegionInfo.RegionHandle == destination.RegionHandle)
{
// m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", regionHandle);
return s.NewUserConnection(aCircuit, teleportFlags, out reason);
@@ -136,17 +178,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
}
// m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", regionHandle);
- uint x = 0, y = 0;
- Utils.LongToUInts(regionHandle, out x, out y);
- reason = "Did not find region " + x + "-" + y;
+ reason = "Did not find region " + destination.RegionName;
return false;
}
- public bool UpdateAgent(ulong regionHandle, AgentData cAgentData)
+ public bool UpdateAgent(GridRegion destination, AgentData cAgentData)
{
+ if (destination == null)
+ return false;
+
foreach (Scene s in m_sceneList)
{
- if (s.RegionInfo.RegionHandle == regionHandle)
+ if (s.RegionInfo.RegionHandle == destination.RegionHandle)
{
//m_log.DebugFormat(
// "[LOCAL COMMS]: Found region {0} {1} to send ChildAgentUpdate",
@@ -161,11 +204,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
return false;
}
- public bool UpdateAgent(ulong regionHandle, AgentPosition cAgentData)
+ public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData)
{
+ if (destination == null)
+ return false;
+
foreach (Scene s in m_sceneList)
{
- if (s.RegionInfo.RegionHandle == regionHandle)
+ if (s.RegionInfo.RegionHandle == destination.RegionHandle)
{
//m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate");
s.IncomingChildAgentDataUpdate(cAgentData);
@@ -176,12 +222,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
return false;
}
- public bool RetrieveAgent(ulong regionHandle, UUID id, out IAgentData agent)
+ public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent)
{
agent = null;
+
+ if (destination == null)
+ return false;
+
foreach (Scene s in m_sceneList)
{
- if (s.RegionInfo.RegionHandle == regionHandle)
+ if (s.RegionInfo.RegionHandle == destination.RegionHandle)
{
//m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate");
return s.IncomingRetrieveRootAgent(id, out agent);
@@ -191,16 +241,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
return false;
}
- public bool ReleaseAgent(ulong regionHandle, UUID id, string uri)
+ public bool ReleaseAgent(GridRegion destination, UUID id, string uri)
{
- //uint x, y;
- //Utils.LongToUInts(regionHandle, out x, out y);
- //x = x / Constants.RegionSize;
- //y = y / Constants.RegionSize;
- //m_log.Debug("\n >>> Local SendReleaseAgent " + x + "-" + y);
+ if (destination == null)
+ return false;
+
foreach (Scene s in m_sceneList)
{
- if (s.RegionInfo.RegionHandle == regionHandle)
+ if (s.RegionInfo.RegionHandle == destination.RegionHandle)
{
//m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent");
return s.IncomingReleaseAgent(id);
@@ -210,16 +258,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
return false;
}
- public bool CloseAgent(ulong regionHandle, UUID id)
+ public bool CloseAgent(GridRegion destination, UUID id)
{
- //uint x, y;
- //Utils.LongToUInts(regionHandle, out x, out y);
- //x = x / Constants.RegionSize;
- //y = y / Constants.RegionSize;
- //m_log.Debug("\n >>> Local SendCloseAgent " + x + "-" + y);
+ if (destination == null)
+ return false;
+
foreach (Scene s in m_sceneList)
{
- if (s.RegionInfo.RegionHandle == regionHandle)
+ if (s.RegionInfo.RegionHandle == destination.RegionHandle)
{
//m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent");
return s.IncomingCloseAgent(id);
@@ -233,11 +279,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
* Object-related communications
*/
- public bool CreateObject(ulong regionHandle, ISceneObject sog, bool isLocalCall)
+ public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall)
{
+ if (destination == null)
+ return false;
+
foreach (Scene s in m_sceneList)
{
- if (s.RegionInfo.RegionHandle == regionHandle)
+ if (s.RegionInfo.RegionHandle == destination.RegionHandle)
{
//m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject");
if (isLocalCall)
@@ -257,11 +306,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
return false;
}
- public bool CreateObject(ulong regionHandle, UUID userID, UUID itemID)
+ public bool CreateObject(GridRegion destination, UUID userID, UUID itemID)
{
+ if (destination == null)
+ return false;
+
foreach (Scene s in m_sceneList)
{
- if (s.RegionInfo.RegionHandle == regionHandle)
+ if (s.RegionInfo.RegionHandle == destination.RegionHandle)
{
return s.IncomingCreateObject(userID, itemID);
}
@@ -274,17 +326,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
#region Misc
- public IScene GetScene(ulong regionhandle)
- {
- foreach (Scene s in m_sceneList)
- {
- if (s.RegionInfo.RegionHandle == regionhandle)
- return s;
- }
- // ? weird. should not happen
- return m_sceneList[0];
- }
-
public bool IsLocalRegion(ulong regionhandle)
{
foreach (Scene s in m_sceneList)
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
new file mode 100644
index 0000000..b7dc283
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
@@ -0,0 +1,356 @@
+/*
+ * 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;
+using System.IO;
+using System.Net;
+using System.Reflection;
+using System.Text;
+using log4net;
+using Nini.Config;
+using OpenMetaverse;
+using OpenMetaverse.StructuredData;
+using OpenSim.Framework;
+using OpenSim.Framework.Communications;
+using OpenSim.Framework.Communications.Clients;
+using OpenSim.Region.Framework.Interfaces;
+using OpenSim.Region.Framework.Scenes;
+using OpenSim.Region.Framework.Scenes.Hypergrid;
+using OpenSim.Region.Framework.Scenes.Serialization;
+using OpenSim.Services.Interfaces;
+using OpenSim.Services.Connectors.Simulation;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
+
+namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
+{
+ public class RemoteSimulationConnectorModule : ISharedRegionModule, ISimulationService
+ {
+ private bool initialized = false;
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ protected bool m_enabled = false;
+ protected Scene m_aScene;
+ // RemoteSimulationConnector does not care about local regions; it delegates that to the Local module
+ protected LocalSimulationConnectorModule m_localBackend;
+ protected SimulationServiceConnector m_remoteConnector;
+
+ protected CommunicationsManager m_commsManager;
+
+ protected IHyperlinkService m_hyperlinkService;
+
+ protected bool m_safemode;
+ protected IPAddress m_thisIP;
+
+ #region IRegionModule
+
+ public virtual void Initialise(IConfigSource config)
+ {
+
+ IConfig moduleConfig = config.Configs["Modules"];
+ if (moduleConfig != null)
+ {
+ string name = moduleConfig.GetString("SimulationServices", "");
+ if (name == Name)
+ {
+ //IConfig userConfig = config.Configs["SimulationService"];
+ //if (userConfig == null)
+ //{
+ // m_log.Error("[AVATAR CONNECTOR]: SimulationService missing from OpanSim.ini");
+ // return;
+ //}
+
+ m_remoteConnector = new SimulationServiceConnector();
+
+ m_enabled = true;
+
+ m_log.Info("[SIMULATION CONNECTOR]: Remote simulation enabled");
+ }
+ }
+ }
+
+ public virtual void PostInitialise()
+ {
+ }
+
+ public virtual void Close()
+ {
+ }
+
+ public void AddRegion(Scene scene)
+ {
+ }
+
+ public void RemoveRegion(Scene scene)
+ {
+ if (m_enabled)
+ {
+ m_localBackend.RemoveScene(scene);
+ scene.UnregisterModuleInterface(this);
+ }
+ }
+
+ public void RegionLoaded(Scene scene)
+ {
+ if (m_enabled)
+ {
+ if (!initialized)
+ {
+ InitOnce(scene);
+ initialized = true;
+ }
+ InitEach(scene);
+ }
+ }
+
+ public Type ReplaceableInterface
+ {
+ get { return null; }
+ }
+
+ public virtual string Name
+ {
+ get { return "RemoteSimulationConnectorModule"; }
+ }
+
+ protected virtual void InitEach(Scene scene)
+ {
+ m_localBackend.Init(scene);
+ scene.RegisterModuleInterface(this);
+ }
+
+ protected virtual void InitOnce(Scene scene)
+ {
+ m_localBackend = new LocalSimulationConnectorModule();
+ m_commsManager = scene.CommsManager;
+ m_aScene = scene;
+ m_hyperlinkService = m_aScene.RequestModuleInterface();
+ //m_regionClient = new RegionToRegionClient(m_aScene, m_hyperlinkService);
+ m_thisIP = Util.GetHostFromDNS(scene.RegionInfo.ExternalHostName);
+ }
+
+ #endregion /* IRegionModule */
+
+ #region IInterregionComms
+
+ public IScene GetScene(ulong handle)
+ {
+ return m_localBackend.GetScene(handle);
+ }
+
+ /**
+ * Agent-related communications
+ */
+
+ public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason)
+ {
+ if (destination == null)
+ {
+ reason = "Given destination was null";
+ m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CreateAgent was given a null destination");
+ return false;
+ }
+
+ // Try local first
+ if (m_localBackend.CreateAgent(destination, aCircuit, teleportFlags, out reason))
+ return true;
+
+ // else do the remote thing
+ if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
+ {
+ //m_regionClient.SendUserInformation(regInfo, aCircuit);
+ return m_remoteConnector.CreateAgent(destination, aCircuit, teleportFlags, out reason);
+ }
+ return false;
+ }
+
+ public bool UpdateAgent(GridRegion destination, AgentData cAgentData)
+ {
+ if (destination == null)
+ return false;
+
+ // Try local first
+ if (m_localBackend.UpdateAgent(destination, cAgentData))
+ return true;
+
+ // else do the remote thing
+ if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
+ return m_remoteConnector.UpdateAgent(destination, cAgentData);
+
+ return false;
+
+ }
+
+ public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData)
+ {
+ if (destination == null)
+ return false;
+
+ // Try local first
+ if (m_localBackend.UpdateAgent(destination, cAgentData))
+ return true;
+
+ // else do the remote thing
+ if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
+ return m_remoteConnector.UpdateAgent(destination, cAgentData);
+
+ return false;
+
+ }
+
+ public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent)
+ {
+ agent = null;
+
+ if (destination == null)
+ return false;
+
+ // Try local first
+ if (m_localBackend.RetrieveAgent(destination, id, out agent))
+ return true;
+
+ // else do the remote thing
+ if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
+ return m_remoteConnector.RetrieveAgent(destination, id, out agent);
+
+ return false;
+
+ }
+
+ public bool ReleaseAgent(GridRegion destination, UUID id, string uri)
+ {
+ if (destination == null)
+ return false;
+
+ // Try local first
+ if (m_localBackend.ReleaseAgent(destination, id, uri))
+ return true;
+
+ // else do the remote thing
+ if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
+ return m_remoteConnector.ReleaseAgent(destination, id, uri);
+
+ return false;
+ }
+
+
+ public bool CloseAgent(GridRegion destination, UUID id)
+ {
+ if (destination == null)
+ return false;
+
+ // Try local first
+ if (m_localBackend.CloseAgent(destination, id))
+ return true;
+
+ // else do the remote thing
+ if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
+ return m_remoteConnector.CloseAgent(destination, id);
+
+ return false;
+ }
+
+ /**
+ * Object-related communications
+ */
+
+ public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall)
+ {
+ if (destination == null)
+ return false;
+
+ // Try local first
+ if (m_localBackend.CreateObject(destination, sog, true))
+ {
+ //m_log.Debug("[REST COMMS]: LocalBackEnd SendCreateObject succeeded");
+ return true;
+ }
+
+ // else do the remote thing
+ if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
+ return m_remoteConnector.CreateObject(destination, sog, isLocalCall);
+
+ return false;
+ }
+
+ public bool CreateObject(GridRegion destination, UUID userID, UUID itemID)
+ {
+ // Not Implemented
+ return false;
+ }
+
+ #endregion /* IInterregionComms */
+
+
+ protected class RegionToRegionClient : RegionClient
+ {
+ Scene m_aScene = null;
+ IHyperlinkService m_hyperlinkService;
+
+ public RegionToRegionClient(Scene s, IHyperlinkService hyperService)
+ {
+ m_aScene = s;
+ m_hyperlinkService = hyperService;
+ }
+
+ public override ulong GetRegionHandle(ulong handle)
+ {
+ if (m_aScene.SceneGridService is HGSceneCommunicationService)
+ {
+ if (m_hyperlinkService != null)
+ return m_hyperlinkService.FindRegionHandle(handle);
+ }
+
+ return handle;
+ }
+
+ public override bool IsHyperlink(ulong handle)
+ {
+ if (m_aScene.SceneGridService is HGSceneCommunicationService)
+ {
+ if ((m_hyperlinkService != null) && (m_hyperlinkService.GetHyperlinkRegion(handle) != null))
+ return true;
+ }
+ return false;
+ }
+
+ public override void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit)
+ {
+ if (m_hyperlinkService != null)
+ m_hyperlinkService.SendUserInformation(regInfo, aCircuit);
+
+ }
+
+ public override void AdjustUserInformation(AgentCircuitData aCircuit)
+ {
+ if (m_hyperlinkService != null)
+ m_hyperlinkService.AdjustUserInformation(aCircuit);
+ }
+ }
+
+ }
+}
diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
index 4966f66..f4f3eea 100644
--- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
+++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
@@ -35,6 +35,7 @@ using System.Text;
using OpenSim.Server.Base;
using OpenSim.Server.Handlers.Base;
using OpenSim.Services.Interfaces;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
@@ -72,9 +73,9 @@ namespace OpenSim.Server.Handlers.Simulation
UUID agentID;
+ UUID regionID;
string action;
- ulong regionHandle;
- if (!Utils.GetParams((string)request["uri"], out agentID, out regionHandle, out action))
+ if (!Utils.GetParams((string)request["uri"], out agentID, out regionID, out action))
{
m_log.InfoFormat("[AGENT HANDLER]: Invalid parameters for agent message {0}", request["uri"]);
responsedata["int_response_code"] = 404;
@@ -97,12 +98,12 @@ namespace OpenSim.Server.Handlers.Simulation
}
else if (method.Equals("GET"))
{
- DoAgentGet(request, responsedata, agentID, regionHandle);
+ DoAgentGet(request, responsedata, agentID, regionID);
return responsedata;
}
else if (method.Equals("DELETE"))
{
- DoAgentDelete(request, responsedata, agentID, action, regionHandle);
+ DoAgentDelete(request, responsedata, agentID, action, regionID);
return responsedata;
}
else
@@ -126,10 +127,27 @@ namespace OpenSim.Server.Handlers.Simulation
return;
}
- // retrieve the regionhandle
- ulong regionhandle = 0;
- if (args["destination_handle"] != null)
- UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle);
+ // retrieve the input arguments
+ int x = 0, y = 0;
+ UUID uuid = UUID.Zero;
+ string regionname = string.Empty;
+ uint teleportFlags = 0;
+ if (args.ContainsKey("destination_x") && args["destination_x"] != null)
+ Int32.TryParse(args["destination_x"].AsString(), out x);
+ if (args.ContainsKey("destination_y") && args["destination_y"] != null)
+ Int32.TryParse(args["destination_y"].AsString(), out y);
+ if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null)
+ UUID.TryParse(args["destination_uuid"].AsString(), out uuid);
+ if (args.ContainsKey("destination_name") && args["destination_name"] != null)
+ regionname = args["destination_name"].ToString();
+ if (args.ContainsKey("teleport_flags") && args["teleport_flags"] != null)
+ teleportFlags = args["teleport_flags"].AsUInteger();
+
+ GridRegion destination = new GridRegion();
+ destination.RegionID = uuid;
+ destination.RegionLocX = x;
+ destination.RegionLocY = y;
+ destination.RegionName = regionname;
AgentCircuitData aCircuit = new AgentCircuitData();
try
@@ -146,15 +164,10 @@ namespace OpenSim.Server.Handlers.Simulation
OSDMap resp = new OSDMap(2);
string reason = String.Empty;
- uint teleportFlags = 0;
- if (args.ContainsKey("teleport_flags"))
- {
- teleportFlags = args["teleport_flags"].AsUInteger();
- }
// This is the meaning of POST agent
//m_regionClient.AdjustUserInformation(aCircuit);
- bool result = m_SimulationService.CreateAgent(regionhandle, aCircuit, teleportFlags, out reason);
+ bool result = m_SimulationService.CreateAgent(destination, aCircuit, teleportFlags, out reason);
resp["reason"] = OSD.FromString(reason);
resp["success"] = OSD.FromBoolean(result);
@@ -174,10 +187,24 @@ namespace OpenSim.Server.Handlers.Simulation
return;
}
- // retrieve the regionhandle
- ulong regionhandle = 0;
- if (args["destination_handle"] != null)
- UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle);
+ // retrieve the input arguments
+ int x = 0, y = 0;
+ UUID uuid = UUID.Zero;
+ string regionname = string.Empty;
+ if (args.ContainsKey("destination_x") && args["destination_x"] != null)
+ Int32.TryParse(args["destination_x"].AsString(), out x);
+ if (args.ContainsKey("destination_y") && args["destination_y"] != null)
+ Int32.TryParse(args["destination_y"].AsString(), out y);
+ if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null)
+ UUID.TryParse(args["destination_uuid"].AsString(), out uuid);
+ if (args.ContainsKey("destination_name") && args["destination_name"] != null)
+ regionname = args["destination_name"].ToString();
+
+ GridRegion destination = new GridRegion();
+ destination.RegionID = uuid;
+ destination.RegionLocX = x;
+ destination.RegionLocY = y;
+ destination.RegionName = regionname;
string messageType;
if (args["message_type"] != null)
@@ -206,7 +233,7 @@ namespace OpenSim.Server.Handlers.Simulation
//agent.Dump();
// This is one of the meanings of PUT agent
- result = m_SimulationService.UpdateAgent(regionhandle, agent);
+ result = m_SimulationService.UpdateAgent(destination, agent);
}
else if ("AgentPosition".Equals(messageType))
@@ -223,7 +250,7 @@ namespace OpenSim.Server.Handlers.Simulation
}
//agent.Dump();
// This is one of the meanings of PUT agent
- result = m_SimulationService.UpdateAgent(regionhandle, agent);
+ result = m_SimulationService.UpdateAgent(destination, agent);
}
@@ -232,10 +259,13 @@ namespace OpenSim.Server.Handlers.Simulation
//responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); ??? instead
}
- protected virtual void DoAgentGet(Hashtable request, Hashtable responsedata, UUID id, ulong regionHandle)
+ protected virtual void DoAgentGet(Hashtable request, Hashtable responsedata, UUID id, UUID regionID)
{
+ GridRegion destination = new GridRegion();
+ destination.RegionID = regionID;
+
IAgentData agent = null;
- bool result = m_SimulationService.RetrieveAgent(regionHandle, id, out agent);
+ bool result = m_SimulationService.RetrieveAgent(destination, id, out agent);
OSDMap map = null;
if (result)
{
@@ -271,14 +301,17 @@ namespace OpenSim.Server.Handlers.Simulation
}
}
- protected virtual void DoAgentDelete(Hashtable request, Hashtable responsedata, UUID id, string action, ulong regionHandle)
+ protected virtual void DoAgentDelete(Hashtable request, Hashtable responsedata, UUID id, string action, UUID regionID)
{
//m_log.Debug(" >>> DoDelete action:" + action + "; regionHandle:" + regionHandle);
+ GridRegion destination = new GridRegion();
+ destination.RegionID = regionID;
+
if (action.Equals("release"))
- m_SimulationService.ReleaseAgent(regionHandle, id, "");
+ m_SimulationService.ReleaseAgent(destination, id, "");
else
- m_SimulationService.CloseAgent(regionHandle, id);
+ m_SimulationService.CloseAgent(destination, id);
responsedata["int_response_code"] = HttpStatusCode.OK;
responsedata["str_response_string"] = "OpenSim agent " + id.ToString();
@@ -287,165 +320,4 @@ namespace OpenSim.Server.Handlers.Simulation
}
}
- public class AgentGetHandler : BaseStreamHandler
- {
- // TODO: unused: private ISimulationService m_SimulationService;
- // TODO: unused: private IAuthenticationService m_AuthenticationService;
-
- public AgentGetHandler(ISimulationService service, IAuthenticationService authentication) :
- base("GET", "/agent")
- {
- // TODO: unused: m_SimulationService = service;
- // TODO: unused: m_AuthenticationService = authentication;
- }
-
- public override byte[] Handle(string path, Stream request,
- OSHttpRequest httpRequest, OSHttpResponse httpResponse)
- {
- // Not implemented yet
- httpResponse.StatusCode = (int)HttpStatusCode.NotImplemented;
- return new byte[] { };
- }
- }
-
- public class AgentPostHandler : BaseStreamHandler
- {
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
- private ISimulationService m_SimulationService;
- private IAuthenticationService m_AuthenticationService;
- // TODO: unused: private bool m_AllowForeignGuests;
-
- public AgentPostHandler(ISimulationService service, IAuthenticationService authentication, bool foreignGuests) :
- base("POST", "/agent")
- {
- m_SimulationService = service;
- m_AuthenticationService = authentication;
- // TODO: unused: m_AllowForeignGuests = foreignGuests;
- }
-
- public override byte[] Handle(string path, Stream request,
- OSHttpRequest httpRequest, OSHttpResponse httpResponse)
- {
- byte[] result = new byte[0];
-
- UUID agentID;
- string action;
- ulong regionHandle;
- if (!RestHandlerUtils.GetParams(path, out agentID, out regionHandle, out action))
- {
- m_log.InfoFormat("[AgentPostHandler]: Invalid parameters for agent message {0}", path);
- httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
- httpResponse.StatusDescription = "Invalid parameters for agent message " + path;
-
- return result;
- }
-
- if (m_AuthenticationService != null)
- {
- // Authentication
- string authority = string.Empty;
- string authToken = string.Empty;
- if (!RestHandlerUtils.GetAuthentication(httpRequest, out authority, out authToken))
- {
- m_log.InfoFormat("[AgentPostHandler]: Authentication failed for agent message {0}", path);
- httpResponse.StatusCode = (int)HttpStatusCode.Unauthorized;
- return result;
- }
- // TODO: Rethink this
- //if (!m_AuthenticationService.VerifyKey(agentID, authToken))
- //{
- // m_log.InfoFormat("[AgentPostHandler]: Authentication failed for agent message {0}", path);
- // httpResponse.StatusCode = (int)HttpStatusCode.Forbidden;
- // return result;
- //}
- m_log.DebugFormat("[AgentPostHandler]: Authentication succeeded for {0}", agentID);
- }
-
- OSDMap args = Util.GetOSDMap(request, (int)httpRequest.ContentLength);
- if (args == null)
- {
- httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
- httpResponse.StatusDescription = "Unable to retrieve data";
- m_log.DebugFormat("[AgentPostHandler]: Unable to retrieve data for post {0}", path);
- return result;
- }
-
- // retrieve the regionhandle
- ulong regionhandle = 0;
- if (args["destination_handle"] != null)
- UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle);
-
- AgentCircuitData aCircuit = new AgentCircuitData();
- try
- {
- aCircuit.UnpackAgentCircuitData(args);
- }
- catch (Exception ex)
- {
- m_log.InfoFormat("[AgentPostHandler]: exception on unpacking CreateAgent message {0}", ex.Message);
- httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
- httpResponse.StatusDescription = "Problems with data deserialization";
- return result;
- }
-
- string reason = string.Empty;
-
- // We need to clean up a few things in the user service before I can do this
- //if (m_AllowForeignGuests)
- // m_regionClient.AdjustUserInformation(aCircuit);
-
- // Finally!
- bool success = m_SimulationService.CreateAgent(regionhandle, aCircuit, /*!!!*/0, out reason);
-
- OSDMap resp = new OSDMap(1);
-
- resp["success"] = OSD.FromBoolean(success);
-
- httpResponse.StatusCode = (int)HttpStatusCode.OK;
-
- return Util.UTF8.GetBytes(OSDParser.SerializeJsonString(resp));
- }
- }
-
- public class AgentPutHandler : BaseStreamHandler
- {
- // TODO: unused: private ISimulationService m_SimulationService;
- // TODO: unused: private IAuthenticationService m_AuthenticationService;
-
- public AgentPutHandler(ISimulationService service, IAuthenticationService authentication) :
- base("PUT", "/agent")
- {
- // TODO: unused: m_SimulationService = service;
- // TODO: unused: m_AuthenticationService = authentication;
- }
-
- public override byte[] Handle(string path, Stream request,
- OSHttpRequest httpRequest, OSHttpResponse httpResponse)
- {
- // Not implemented yet
- httpResponse.StatusCode = (int)HttpStatusCode.NotImplemented;
- return new byte[] { };
- }
- }
-
- public class AgentDeleteHandler : BaseStreamHandler
- {
- // TODO: unused: private ISimulationService m_SimulationService;
- // TODO: unused: private IAuthenticationService m_AuthenticationService;
-
- public AgentDeleteHandler(ISimulationService service, IAuthenticationService authentication) :
- base("DELETE", "/agent")
- {
- // TODO: unused: m_SimulationService = service;
- // TODO: unused: m_AuthenticationService = authentication;
- }
-
- public override byte[] Handle(string path, Stream request,
- OSHttpRequest httpRequest, OSHttpResponse httpResponse)
- {
- // Not implemented yet
- httpResponse.StatusCode = (int)HttpStatusCode.NotImplemented;
- return new byte[] { };
- }
- }
}
diff --git a/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs b/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs
index 8c3af72..995a3c4 100644
--- a/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs
+++ b/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs
@@ -35,6 +35,7 @@ using System.Text;
using OpenSim.Server.Base;
using OpenSim.Server.Handlers.Base;
using OpenSim.Services.Interfaces;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
@@ -70,9 +71,9 @@ namespace OpenSim.Server.Handlers.Simulation
responsedata["content_type"] = "text/html";
UUID objectID;
+ UUID regionID;
string action;
- ulong regionHandle;
- if (!Utils.GetParams((string)request["uri"], out objectID, out regionHandle, out action))
+ if (!Utils.GetParams((string)request["uri"], out objectID, out regionID, out action))
{
m_log.InfoFormat("[REST COMMS]: Invalid parameters for object message {0}", request["uri"]);
responsedata["int_response_code"] = 404;
@@ -85,12 +86,12 @@ namespace OpenSim.Server.Handlers.Simulation
string method = (string)request["http-method"];
if (method.Equals("POST"))
{
- DoObjectPost(request, responsedata, regionHandle);
+ DoObjectPost(request, responsedata, regionID);
return responsedata;
}
else if (method.Equals("PUT"))
{
- DoObjectPut(request, responsedata, regionHandle);
+ DoObjectPut(request, responsedata, regionID);
return responsedata;
}
//else if (method.Equals("DELETE"))
@@ -109,7 +110,7 @@ namespace OpenSim.Server.Handlers.Simulation
}
- protected virtual void DoObjectPost(Hashtable request, Hashtable responsedata, ulong regionhandle)
+ protected virtual void DoObjectPost(Hashtable request, Hashtable responsedata, UUID regionID)
{
OSDMap args = Utils.GetOSDMap((string)request["body"]);
if (args == null)
@@ -118,14 +119,32 @@ namespace OpenSim.Server.Handlers.Simulation
responsedata["str_response_string"] = "false";
return;
}
+ // retrieve the input arguments
+ int x = 0, y = 0;
+ UUID uuid = UUID.Zero;
+ string regionname = string.Empty;
+ if (args.ContainsKey("destination_x") && args["destination_x"] != null)
+ Int32.TryParse(args["destination_x"].AsString(), out x);
+ if (args.ContainsKey("destination_y") && args["destination_y"] != null)
+ Int32.TryParse(args["destination_y"].AsString(), out y);
+ if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null)
+ UUID.TryParse(args["destination_uuid"].AsString(), out uuid);
+ if (args.ContainsKey("destination_name") && args["destination_name"] != null)
+ regionname = args["destination_name"].ToString();
+
+ GridRegion destination = new GridRegion();
+ destination.RegionID = uuid;
+ destination.RegionLocX = x;
+ destination.RegionLocY = y;
+ destination.RegionName = regionname;
string sogXmlStr = "", extraStr = "", stateXmlStr = "";
- if (args["sog"] != null)
+ if (args.ContainsKey("sog") && args["sog"] != null)
sogXmlStr = args["sog"].AsString();
- if (args["extra"] != null)
+ if (args.ContainsKey("extra") && args["extra"] != null)
extraStr = args["extra"].AsString();
- IScene s = m_SimulationService.GetScene(regionhandle);
+ IScene s = m_SimulationService.GetScene(destination.RegionHandle);
ISceneObject sog = null;
try
{
@@ -158,13 +177,13 @@ namespace OpenSim.Server.Handlers.Simulation
}
}
// This is the meaning of POST object
- bool result = m_SimulationService.CreateObject(regionhandle, sog, false);
+ bool result = m_SimulationService.CreateObject(destination, sog, false);
responsedata["int_response_code"] = HttpStatusCode.OK;
responsedata["str_response_string"] = result.ToString();
}
- protected virtual void DoObjectPut(Hashtable request, Hashtable responsedata, ulong regionhandle)
+ protected virtual void DoObjectPut(Hashtable request, Hashtable responsedata, UUID regionID)
{
OSDMap args = Utils.GetOSDMap((string)request["body"]);
if (args == null)
@@ -174,14 +193,33 @@ namespace OpenSim.Server.Handlers.Simulation
return;
}
+ // retrieve the input arguments
+ int x = 0, y = 0;
+ UUID uuid = UUID.Zero;
+ string regionname = string.Empty;
+ if (args.ContainsKey("destination_x") && args["destination_x"] != null)
+ Int32.TryParse(args["destination_x"].AsString(), out x);
+ if (args.ContainsKey("destination_y") && args["destination_y"] != null)
+ Int32.TryParse(args["destination_y"].AsString(), out y);
+ if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null)
+ UUID.TryParse(args["destination_uuid"].AsString(), out uuid);
+ if (args.ContainsKey("destination_name") && args["destination_name"] != null)
+ regionname = args["destination_name"].ToString();
+
+ GridRegion destination = new GridRegion();
+ destination.RegionID = uuid;
+ destination.RegionLocX = x;
+ destination.RegionLocY = y;
+ destination.RegionName = regionname;
+
UUID userID = UUID.Zero, itemID = UUID.Zero;
- if (args["userid"] != null)
+ if (args.ContainsKey("userid") && args["userid"] != null)
userID = args["userid"].AsUUID();
- if (args["itemid"] != null)
+ if (args.ContainsKey("itemid") && args["itemid"] != null)
itemID = args["itemid"].AsUUID();
// This is the meaning of PUT object
- bool result = m_SimulationService.CreateObject(regionhandle, userID, itemID);
+ bool result = m_SimulationService.CreateObject(destination, userID, itemID);
responsedata["int_response_code"] = 200;
responsedata["str_response_string"] = result.ToString();
diff --git a/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs b/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs
index 8611228..55a575c 100644
--- a/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs
+++ b/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs
@@ -43,9 +43,9 @@ namespace OpenSim.Server.Handlers.Simulation
public SimulationServiceInConnector(IConfigSource config, IHttpServer server, IScene scene) :
base(config, server, String.Empty)
{
- IConfig serverConfig = config.Configs["SimulationService"];
- if (serverConfig == null)
- throw new Exception("No section 'SimulationService' in config file");
+ //IConfig serverConfig = config.Configs["SimulationService"];
+ //if (serverConfig == null)
+ // throw new Exception("No section 'SimulationService' in config file");
//string simService = serverConfig.GetString("LocalServiceModule",
// String.Empty);
diff --git a/OpenSim/Server/Handlers/Simulation/Utils.cs b/OpenSim/Server/Handlers/Simulation/Utils.cs
index 1f2f851..ed379da 100644
--- a/OpenSim/Server/Handlers/Simulation/Utils.cs
+++ b/OpenSim/Server/Handlers/Simulation/Utils.cs
@@ -46,11 +46,11 @@ namespace OpenSim.Server.Handlers.Simulation
/// Something like this: /agent/uuid/ or /agent/uuid/handle/release
/// uuid on uuid field
/// optional action
- public static bool GetParams(string uri, out UUID uuid, out ulong regionHandle, out string action)
+ public static bool GetParams(string uri, out UUID uuid, out UUID regionID, out string action)
{
uuid = UUID.Zero;
+ regionID = UUID.Zero;
action = "";
- regionHandle = 0;
uri = uri.Trim(new char[] { '/' });
string[] parts = uri.Split('/');
@@ -64,7 +64,7 @@ namespace OpenSim.Server.Handlers.Simulation
return false;
if (parts.Length >= 3)
- UInt64.TryParse(parts[2], out regionHandle);
+ UUID.TryParse(parts[2], out regionID);
if (parts.Length >= 4)
action = parts[3];
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;
}
diff --git a/OpenSim/Services/Interfaces/ISimulationService.cs b/OpenSim/Services/Interfaces/ISimulationService.cs
index 7ba3e66..14f462c 100644
--- a/OpenSim/Services/Interfaces/ISimulationService.cs
+++ b/OpenSim/Services/Interfaces/ISimulationService.cs
@@ -29,6 +29,8 @@ using System;
using OpenSim.Framework;
using OpenMetaverse;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
+
namespace OpenSim.Services.Interfaces
{
public interface ISimulationService
@@ -37,7 +39,7 @@ namespace OpenSim.Services.Interfaces
#region Agents
- bool CreateAgent(ulong regionHandle, AgentCircuitData aCircuit, uint flags, out string reason);
+ bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason);
///
/// Full child agent update.
@@ -45,7 +47,7 @@ namespace OpenSim.Services.Interfaces
///
///
///
- bool UpdateAgent(ulong regionHandle, AgentData data);
+ bool UpdateAgent(GridRegion destination, AgentData data);
///
/// Short child agent update, mostly for position.
@@ -53,9 +55,9 @@ namespace OpenSim.Services.Interfaces
///
///
///
- bool UpdateAgent(ulong regionHandle, AgentPosition data);
+ bool UpdateAgent(GridRegion destination, AgentPosition data);
- bool RetrieveAgent(ulong regionHandle, UUID id, out IAgentData agent);
+ bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent);
///
/// Message from receiving region to departing region, telling it got contacted by the client.
@@ -65,7 +67,7 @@ namespace OpenSim.Services.Interfaces
///
///
///
- bool ReleaseAgent(ulong regionHandle, UUID id, string uri);
+ bool ReleaseAgent(GridRegion destination, UUID id, string uri);
///
/// Close agent.
@@ -73,7 +75,7 @@ namespace OpenSim.Services.Interfaces
///
///
///
- bool CloseAgent(ulong regionHandle, UUID id);
+ bool CloseAgent(GridRegion destination, UUID id);
#endregion Agents
@@ -86,7 +88,7 @@ namespace OpenSim.Services.Interfaces
///
///
///
- bool CreateObject(ulong regionHandle, ISceneObject sog, bool isLocalCall);
+ bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall);
///
/// Create an object from the user's inventory in the destination region.
@@ -96,7 +98,7 @@ namespace OpenSim.Services.Interfaces
///
///
///
- bool CreateObject(ulong regionHandle, UUID userID, UUID itemID);
+ bool CreateObject(GridRegion destination, UUID userID, UUID itemID);
#endregion Objects
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index 82e5ba4..638fa9f 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -370,7 +370,7 @@ namespace OpenSim.Services.LLLoginService
aCircuit.SessionID = session;
aCircuit.startpos = position;
- if (simConnector.CreateAgent(region.RegionHandle, aCircuit, 0, out reason))
+ if (simConnector.CreateAgent(region, aCircuit, 0, out reason))
return aCircuit;
return null;
diff --git a/bin/config-include/StandaloneHypergrid.ini b/bin/config-include/StandaloneHypergrid.ini
index d89029f..5e54cde 100644
--- a/bin/config-include/StandaloneHypergrid.ini
+++ b/bin/config-include/StandaloneHypergrid.ini
@@ -19,6 +19,7 @@
GridServices = "HGGridServicesConnector"
PresenceServices = "LocalPresenceServicesConnector"
UserAccountServices = "LocalUserAccountServicesConnector"
+ SimulationServices = "RemoteSimulationConnectorModule"
InventoryServiceInConnector = true
AssetServiceInConnector = true
HGAuthServiceInConnector = true
--
cgit v1.1