* 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.slimupdates
parent
ae1bdaa7b5
commit
c268e342d1
|
@ -56,6 +56,7 @@
|
||||||
<RegionModule id="LocalUserAccountServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts.LocalUserAccountServicesConnector" />
|
<RegionModule id="LocalUserAccountServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts.LocalUserAccountServicesConnector" />
|
||||||
<RegionModule id="RemoteUserAccountServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts.RemoteUserAccountServicesConnector" />
|
<RegionModule id="RemoteUserAccountServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts.RemoteUserAccountServicesConnector" />
|
||||||
<RegionModule id="LocalSimulationConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation.LocalSimulationConnectorModule" />
|
<RegionModule id="LocalSimulationConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation.LocalSimulationConnectorModule" />
|
||||||
|
<RegionModule id="RemoteSimulationConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation.RemoteSimulationConnectorModule" />
|
||||||
<!-- Service connectors IN modules -->
|
<!-- Service connectors IN modules -->
|
||||||
<RegionModule id="AssetServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset.AssetServiceInConnectorModule" />
|
<RegionModule id="AssetServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset.AssetServiceInConnectorModule" />
|
||||||
<RegionModule id="InventoryServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory.InventoryServiceInConnectorModule" />
|
<RegionModule id="InventoryServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory.InventoryServiceInConnectorModule" />
|
||||||
|
@ -63,6 +64,7 @@
|
||||||
<RegionModule id="NeighbourServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour.NeighbourServiceInConnectorModule" /> \
|
<RegionModule id="NeighbourServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour.NeighbourServiceInConnectorModule" /> \
|
||||||
<RegionModule id="HypergridServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid.HypergridServiceInConnectorModule" /> \
|
<RegionModule id="HypergridServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid.HypergridServiceInConnectorModule" /> \
|
||||||
<RegionModule id="LLLoginServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Login.LLLoginServiceInConnectorModule" /> \
|
<RegionModule id="LLLoginServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Login.LLLoginServiceInConnectorModule" /> \
|
||||||
|
<RegionModule id="SimulationServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation.SimulationServiceInConnectorModule" /> \
|
||||||
|
|
||||||
</Extension>
|
</Extension>
|
||||||
|
|
||||||
|
|
|
@ -58,11 +58,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation
|
||||||
IConfig moduleConfig = config.Configs["Modules"];
|
IConfig moduleConfig = config.Configs["Modules"];
|
||||||
if (moduleConfig != null)
|
if (moduleConfig != null)
|
||||||
{
|
{
|
||||||
string name = moduleConfig.GetString("SimulationService", "");
|
m_Enabled = moduleConfig.GetBoolean("SimulationServiceInConnector", false);
|
||||||
if (name == Name)
|
if (m_Enabled)
|
||||||
{
|
{
|
||||||
m_Enabled = true;
|
m_log.Info("[SIM SERVICE]: SimulationService IN connector enabled");
|
||||||
m_log.Info("[SIM SERVICE]: SimulationService enabled");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +83,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get { return "SimulationService"; }
|
get { return "SimulationServiceInConnectorModule"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddRegion(Scene scene)
|
public void AddRegion(Scene scene)
|
||||||
|
|
|
@ -34,6 +34,7 @@ using OpenSim.Framework;
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
using OpenSim.Region.Framework.Scenes;
|
using OpenSim.Region.Framework.Scenes;
|
||||||
using OpenSim.Services.Interfaces;
|
using OpenSim.Services.Interfaces;
|
||||||
|
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
|
||||||
|
|
||||||
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
|
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 static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
private List<Scene> m_sceneList = new List<Scene>();
|
private List<Scene> m_sceneList = new List<Scene>();
|
||||||
|
|
||||||
|
private bool m_ModuleEnabled = false;
|
||||||
|
|
||||||
#region IRegionModule
|
#region IRegionModule
|
||||||
|
|
||||||
public void Initialise(IConfigSource config)
|
public void Initialise(IConfigSource config)
|
||||||
{
|
{
|
||||||
// This module is always on
|
IConfig moduleConfig = config.Configs["Modules"];
|
||||||
m_log.Debug("[LOCAL SIMULATION]: Enabling LocalSimulation module");
|
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()
|
public void PostInitialise()
|
||||||
|
@ -57,16 +75,24 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
|
||||||
|
|
||||||
public void AddRegion(Scene scene)
|
public void AddRegion(Scene scene)
|
||||||
{
|
{
|
||||||
|
if (!m_ModuleEnabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Init(scene);
|
||||||
|
scene.RegisterModuleInterface<ISimulationService>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveRegion(Scene scene)
|
public void RemoveRegion(Scene scene)
|
||||||
{
|
{
|
||||||
|
if (!m_ModuleEnabled)
|
||||||
|
return;
|
||||||
|
|
||||||
RemoveScene(scene);
|
RemoveScene(scene);
|
||||||
|
scene.UnregisterModuleInterface<ISimulationService>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegionLoaded(Scene scene)
|
public void RegionLoaded(Scene scene)
|
||||||
{
|
{
|
||||||
Init(scene);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Close()
|
public void Close()
|
||||||
|
@ -109,7 +135,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
|
||||||
lock (m_sceneList)
|
lock (m_sceneList)
|
||||||
{
|
{
|
||||||
m_sceneList.Add(scene);
|
m_sceneList.Add(scene);
|
||||||
scene.RegisterModuleInterface<ISimulationService>(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -119,16 +144,33 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
|
||||||
|
|
||||||
#region ISimulation
|
#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
|
* 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)
|
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);
|
// m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", regionHandle);
|
||||||
return s.NewUserConnection(aCircuit, teleportFlags, out reason);
|
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);
|
// m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", regionHandle);
|
||||||
uint x = 0, y = 0;
|
reason = "Did not find region " + destination.RegionName;
|
||||||
Utils.LongToUInts(regionHandle, out x, out y);
|
|
||||||
reason = "Did not find region " + x + "-" + y;
|
|
||||||
return false;
|
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)
|
foreach (Scene s in m_sceneList)
|
||||||
{
|
{
|
||||||
if (s.RegionInfo.RegionHandle == regionHandle)
|
if (s.RegionInfo.RegionHandle == destination.RegionHandle)
|
||||||
{
|
{
|
||||||
//m_log.DebugFormat(
|
//m_log.DebugFormat(
|
||||||
// "[LOCAL COMMS]: Found region {0} {1} to send ChildAgentUpdate",
|
// "[LOCAL COMMS]: Found region {0} {1} to send ChildAgentUpdate",
|
||||||
|
@ -161,11 +204,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
|
||||||
return false;
|
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)
|
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");
|
//m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate");
|
||||||
s.IncomingChildAgentDataUpdate(cAgentData);
|
s.IncomingChildAgentDataUpdate(cAgentData);
|
||||||
|
@ -176,12 +222,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool RetrieveAgent(ulong regionHandle, UUID id, out IAgentData agent)
|
public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent)
|
||||||
{
|
{
|
||||||
agent = null;
|
agent = null;
|
||||||
|
|
||||||
|
if (destination == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
foreach (Scene s in m_sceneList)
|
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");
|
//m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate");
|
||||||
return s.IncomingRetrieveRootAgent(id, out agent);
|
return s.IncomingRetrieveRootAgent(id, out agent);
|
||||||
|
@ -191,16 +241,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ReleaseAgent(ulong regionHandle, UUID id, string uri)
|
public bool ReleaseAgent(GridRegion destination, UUID id, string uri)
|
||||||
{
|
{
|
||||||
//uint x, y;
|
if (destination == null)
|
||||||
//Utils.LongToUInts(regionHandle, out x, out y);
|
return false;
|
||||||
//x = x / Constants.RegionSize;
|
|
||||||
//y = y / Constants.RegionSize;
|
|
||||||
//m_log.Debug("\n >>> Local SendReleaseAgent " + x + "-" + y);
|
|
||||||
foreach (Scene s in m_sceneList)
|
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");
|
//m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent");
|
||||||
return s.IncomingReleaseAgent(id);
|
return s.IncomingReleaseAgent(id);
|
||||||
|
@ -210,16 +258,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CloseAgent(ulong regionHandle, UUID id)
|
public bool CloseAgent(GridRegion destination, UUID id)
|
||||||
{
|
{
|
||||||
//uint x, y;
|
if (destination == null)
|
||||||
//Utils.LongToUInts(regionHandle, out x, out y);
|
return false;
|
||||||
//x = x / Constants.RegionSize;
|
|
||||||
//y = y / Constants.RegionSize;
|
|
||||||
//m_log.Debug("\n >>> Local SendCloseAgent " + x + "-" + y);
|
|
||||||
foreach (Scene s in m_sceneList)
|
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");
|
//m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent");
|
||||||
return s.IncomingCloseAgent(id);
|
return s.IncomingCloseAgent(id);
|
||||||
|
@ -233,11 +279,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
|
||||||
* Object-related communications
|
* 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)
|
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");
|
//m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject");
|
||||||
if (isLocalCall)
|
if (isLocalCall)
|
||||||
|
@ -257,11 +306,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
|
||||||
return false;
|
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)
|
foreach (Scene s in m_sceneList)
|
||||||
{
|
{
|
||||||
if (s.RegionInfo.RegionHandle == regionHandle)
|
if (s.RegionInfo.RegionHandle == destination.RegionHandle)
|
||||||
{
|
{
|
||||||
return s.IncomingCreateObject(userID, itemID);
|
return s.IncomingCreateObject(userID, itemID);
|
||||||
}
|
}
|
||||||
|
@ -274,17 +326,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
|
||||||
|
|
||||||
#region Misc
|
#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)
|
public bool IsLocalRegion(ulong regionhandle)
|
||||||
{
|
{
|
||||||
foreach (Scene s in m_sceneList)
|
foreach (Scene s in m_sceneList)
|
||||||
|
|
|
@ -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<ISimulationService>(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<ISimulationService>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void InitOnce(Scene scene)
|
||||||
|
{
|
||||||
|
m_localBackend = new LocalSimulationConnectorModule();
|
||||||
|
m_commsManager = scene.CommsManager;
|
||||||
|
m_aScene = scene;
|
||||||
|
m_hyperlinkService = m_aScene.RequestModuleInterface<IHyperlinkService>();
|
||||||
|
//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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -35,6 +35,7 @@ using System.Text;
|
||||||
using OpenSim.Server.Base;
|
using OpenSim.Server.Base;
|
||||||
using OpenSim.Server.Handlers.Base;
|
using OpenSim.Server.Handlers.Base;
|
||||||
using OpenSim.Services.Interfaces;
|
using OpenSim.Services.Interfaces;
|
||||||
|
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Servers.HttpServer;
|
using OpenSim.Framework.Servers.HttpServer;
|
||||||
|
|
||||||
|
@ -72,9 +73,9 @@ namespace OpenSim.Server.Handlers.Simulation
|
||||||
|
|
||||||
|
|
||||||
UUID agentID;
|
UUID agentID;
|
||||||
|
UUID regionID;
|
||||||
string action;
|
string action;
|
||||||
ulong regionHandle;
|
if (!Utils.GetParams((string)request["uri"], out agentID, out regionID, out action))
|
||||||
if (!Utils.GetParams((string)request["uri"], out agentID, out regionHandle, out action))
|
|
||||||
{
|
{
|
||||||
m_log.InfoFormat("[AGENT HANDLER]: Invalid parameters for agent message {0}", request["uri"]);
|
m_log.InfoFormat("[AGENT HANDLER]: Invalid parameters for agent message {0}", request["uri"]);
|
||||||
responsedata["int_response_code"] = 404;
|
responsedata["int_response_code"] = 404;
|
||||||
|
@ -97,12 +98,12 @@ namespace OpenSim.Server.Handlers.Simulation
|
||||||
}
|
}
|
||||||
else if (method.Equals("GET"))
|
else if (method.Equals("GET"))
|
||||||
{
|
{
|
||||||
DoAgentGet(request, responsedata, agentID, regionHandle);
|
DoAgentGet(request, responsedata, agentID, regionID);
|
||||||
return responsedata;
|
return responsedata;
|
||||||
}
|
}
|
||||||
else if (method.Equals("DELETE"))
|
else if (method.Equals("DELETE"))
|
||||||
{
|
{
|
||||||
DoAgentDelete(request, responsedata, agentID, action, regionHandle);
|
DoAgentDelete(request, responsedata, agentID, action, regionID);
|
||||||
return responsedata;
|
return responsedata;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -126,10 +127,27 @@ namespace OpenSim.Server.Handlers.Simulation
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// retrieve the regionhandle
|
// retrieve the input arguments
|
||||||
ulong regionhandle = 0;
|
int x = 0, y = 0;
|
||||||
if (args["destination_handle"] != null)
|
UUID uuid = UUID.Zero;
|
||||||
UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle);
|
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();
|
AgentCircuitData aCircuit = new AgentCircuitData();
|
||||||
try
|
try
|
||||||
|
@ -146,15 +164,10 @@ namespace OpenSim.Server.Handlers.Simulation
|
||||||
|
|
||||||
OSDMap resp = new OSDMap(2);
|
OSDMap resp = new OSDMap(2);
|
||||||
string reason = String.Empty;
|
string reason = String.Empty;
|
||||||
uint teleportFlags = 0;
|
|
||||||
if (args.ContainsKey("teleport_flags"))
|
|
||||||
{
|
|
||||||
teleportFlags = args["teleport_flags"].AsUInteger();
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is the meaning of POST agent
|
// This is the meaning of POST agent
|
||||||
//m_regionClient.AdjustUserInformation(aCircuit);
|
//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["reason"] = OSD.FromString(reason);
|
||||||
resp["success"] = OSD.FromBoolean(result);
|
resp["success"] = OSD.FromBoolean(result);
|
||||||
|
@ -174,10 +187,24 @@ namespace OpenSim.Server.Handlers.Simulation
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// retrieve the regionhandle
|
// retrieve the input arguments
|
||||||
ulong regionhandle = 0;
|
int x = 0, y = 0;
|
||||||
if (args["destination_handle"] != null)
|
UUID uuid = UUID.Zero;
|
||||||
UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle);
|
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;
|
string messageType;
|
||||||
if (args["message_type"] != null)
|
if (args["message_type"] != null)
|
||||||
|
@ -206,7 +233,7 @@ namespace OpenSim.Server.Handlers.Simulation
|
||||||
|
|
||||||
//agent.Dump();
|
//agent.Dump();
|
||||||
// This is one of the meanings of PUT agent
|
// 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))
|
else if ("AgentPosition".Equals(messageType))
|
||||||
|
@ -223,7 +250,7 @@ namespace OpenSim.Server.Handlers.Simulation
|
||||||
}
|
}
|
||||||
//agent.Dump();
|
//agent.Dump();
|
||||||
// This is one of the meanings of PUT agent
|
// 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
|
//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;
|
IAgentData agent = null;
|
||||||
bool result = m_SimulationService.RetrieveAgent(regionHandle, id, out agent);
|
bool result = m_SimulationService.RetrieveAgent(destination, id, out agent);
|
||||||
OSDMap map = null;
|
OSDMap map = null;
|
||||||
if (result)
|
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);
|
//m_log.Debug(" >>> DoDelete action:" + action + "; regionHandle:" + regionHandle);
|
||||||
|
|
||||||
|
GridRegion destination = new GridRegion();
|
||||||
|
destination.RegionID = regionID;
|
||||||
|
|
||||||
if (action.Equals("release"))
|
if (action.Equals("release"))
|
||||||
m_SimulationService.ReleaseAgent(regionHandle, id, "");
|
m_SimulationService.ReleaseAgent(destination, id, "");
|
||||||
else
|
else
|
||||||
m_SimulationService.CloseAgent(regionHandle, id);
|
m_SimulationService.CloseAgent(destination, id);
|
||||||
|
|
||||||
responsedata["int_response_code"] = HttpStatusCode.OK;
|
responsedata["int_response_code"] = HttpStatusCode.OK;
|
||||||
responsedata["str_response_string"] = "OpenSim agent " + id.ToString();
|
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[] { };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ using System.Text;
|
||||||
using OpenSim.Server.Base;
|
using OpenSim.Server.Base;
|
||||||
using OpenSim.Server.Handlers.Base;
|
using OpenSim.Server.Handlers.Base;
|
||||||
using OpenSim.Services.Interfaces;
|
using OpenSim.Services.Interfaces;
|
||||||
|
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Servers.HttpServer;
|
using OpenSim.Framework.Servers.HttpServer;
|
||||||
|
|
||||||
|
@ -70,9 +71,9 @@ namespace OpenSim.Server.Handlers.Simulation
|
||||||
responsedata["content_type"] = "text/html";
|
responsedata["content_type"] = "text/html";
|
||||||
|
|
||||||
UUID objectID;
|
UUID objectID;
|
||||||
|
UUID regionID;
|
||||||
string action;
|
string action;
|
||||||
ulong regionHandle;
|
if (!Utils.GetParams((string)request["uri"], out objectID, out regionID, out action))
|
||||||
if (!Utils.GetParams((string)request["uri"], out objectID, out regionHandle, out action))
|
|
||||||
{
|
{
|
||||||
m_log.InfoFormat("[REST COMMS]: Invalid parameters for object message {0}", request["uri"]);
|
m_log.InfoFormat("[REST COMMS]: Invalid parameters for object message {0}", request["uri"]);
|
||||||
responsedata["int_response_code"] = 404;
|
responsedata["int_response_code"] = 404;
|
||||||
|
@ -85,12 +86,12 @@ namespace OpenSim.Server.Handlers.Simulation
|
||||||
string method = (string)request["http-method"];
|
string method = (string)request["http-method"];
|
||||||
if (method.Equals("POST"))
|
if (method.Equals("POST"))
|
||||||
{
|
{
|
||||||
DoObjectPost(request, responsedata, regionHandle);
|
DoObjectPost(request, responsedata, regionID);
|
||||||
return responsedata;
|
return responsedata;
|
||||||
}
|
}
|
||||||
else if (method.Equals("PUT"))
|
else if (method.Equals("PUT"))
|
||||||
{
|
{
|
||||||
DoObjectPut(request, responsedata, regionHandle);
|
DoObjectPut(request, responsedata, regionID);
|
||||||
return responsedata;
|
return responsedata;
|
||||||
}
|
}
|
||||||
//else if (method.Equals("DELETE"))
|
//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"]);
|
OSDMap args = Utils.GetOSDMap((string)request["body"]);
|
||||||
if (args == null)
|
if (args == null)
|
||||||
|
@ -118,14 +119,32 @@ namespace OpenSim.Server.Handlers.Simulation
|
||||||
responsedata["str_response_string"] = "false";
|
responsedata["str_response_string"] = "false";
|
||||||
return;
|
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 = "";
|
string sogXmlStr = "", extraStr = "", stateXmlStr = "";
|
||||||
if (args["sog"] != null)
|
if (args.ContainsKey("sog") && args["sog"] != null)
|
||||||
sogXmlStr = args["sog"].AsString();
|
sogXmlStr = args["sog"].AsString();
|
||||||
if (args["extra"] != null)
|
if (args.ContainsKey("extra") && args["extra"] != null)
|
||||||
extraStr = args["extra"].AsString();
|
extraStr = args["extra"].AsString();
|
||||||
|
|
||||||
IScene s = m_SimulationService.GetScene(regionhandle);
|
IScene s = m_SimulationService.GetScene(destination.RegionHandle);
|
||||||
ISceneObject sog = null;
|
ISceneObject sog = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -158,13 +177,13 @@ namespace OpenSim.Server.Handlers.Simulation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// This is the meaning of POST object
|
// 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["int_response_code"] = HttpStatusCode.OK;
|
||||||
responsedata["str_response_string"] = result.ToString();
|
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"]);
|
OSDMap args = Utils.GetOSDMap((string)request["body"]);
|
||||||
if (args == null)
|
if (args == null)
|
||||||
|
@ -174,14 +193,33 @@ namespace OpenSim.Server.Handlers.Simulation
|
||||||
return;
|
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;
|
UUID userID = UUID.Zero, itemID = UUID.Zero;
|
||||||
if (args["userid"] != null)
|
if (args.ContainsKey("userid") && args["userid"] != null)
|
||||||
userID = args["userid"].AsUUID();
|
userID = args["userid"].AsUUID();
|
||||||
if (args["itemid"] != null)
|
if (args.ContainsKey("itemid") && args["itemid"] != null)
|
||||||
itemID = args["itemid"].AsUUID();
|
itemID = args["itemid"].AsUUID();
|
||||||
|
|
||||||
// This is the meaning of PUT object
|
// 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["int_response_code"] = 200;
|
||||||
responsedata["str_response_string"] = result.ToString();
|
responsedata["str_response_string"] = result.ToString();
|
||||||
|
|
|
@ -43,9 +43,9 @@ namespace OpenSim.Server.Handlers.Simulation
|
||||||
public SimulationServiceInConnector(IConfigSource config, IHttpServer server, IScene scene) :
|
public SimulationServiceInConnector(IConfigSource config, IHttpServer server, IScene scene) :
|
||||||
base(config, server, String.Empty)
|
base(config, server, String.Empty)
|
||||||
{
|
{
|
||||||
IConfig serverConfig = config.Configs["SimulationService"];
|
//IConfig serverConfig = config.Configs["SimulationService"];
|
||||||
if (serverConfig == null)
|
//if (serverConfig == null)
|
||||||
throw new Exception("No section 'SimulationService' in config file");
|
// throw new Exception("No section 'SimulationService' in config file");
|
||||||
|
|
||||||
//string simService = serverConfig.GetString("LocalServiceModule",
|
//string simService = serverConfig.GetString("LocalServiceModule",
|
||||||
// String.Empty);
|
// String.Empty);
|
||||||
|
|
|
@ -46,11 +46,11 @@ namespace OpenSim.Server.Handlers.Simulation
|
||||||
/// <param name="uri">Something like this: /agent/uuid/ or /agent/uuid/handle/release</param>
|
/// <param name="uri">Something like this: /agent/uuid/ or /agent/uuid/handle/release</param>
|
||||||
/// <param name="uri">uuid on uuid field</param>
|
/// <param name="uri">uuid on uuid field</param>
|
||||||
/// <param name="action">optional action</param>
|
/// <param name="action">optional action</param>
|
||||||
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;
|
uuid = UUID.Zero;
|
||||||
|
regionID = UUID.Zero;
|
||||||
action = "";
|
action = "";
|
||||||
regionHandle = 0;
|
|
||||||
|
|
||||||
uri = uri.Trim(new char[] { '/' });
|
uri = uri.Trim(new char[] { '/' });
|
||||||
string[] parts = uri.Split('/');
|
string[] parts = uri.Split('/');
|
||||||
|
@ -64,7 +64,7 @@ namespace OpenSim.Server.Handlers.Simulation
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (parts.Length >= 3)
|
if (parts.Length >= 3)
|
||||||
UInt64.TryParse(parts[2], out regionHandle);
|
UUID.TryParse(parts[2], out regionID);
|
||||||
if (parts.Length >= 4)
|
if (parts.Length >= 4)
|
||||||
action = parts[3];
|
action = parts[3];
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace OpenSim.Services.Connectors.Simulation
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
private GridRegion m_Region;
|
//private GridRegion m_Region;
|
||||||
|
|
||||||
public SimulationServiceConnector()
|
public SimulationServiceConnector()
|
||||||
{
|
{
|
||||||
|
@ -54,7 +54,7 @@ namespace OpenSim.Services.Connectors.Simulation
|
||||||
|
|
||||||
public SimulationServiceConnector(GridRegion region)
|
public SimulationServiceConnector(GridRegion region)
|
||||||
{
|
{
|
||||||
m_Region = region;
|
//m_Region = region;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IScene GetScene(ulong regionHandle)
|
public IScene GetScene(ulong regionHandle)
|
||||||
|
@ -64,7 +64,7 @@ namespace OpenSim.Services.Connectors.Simulation
|
||||||
|
|
||||||
#region Agents
|
#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;
|
reason = String.Empty;
|
||||||
|
|
||||||
|
@ -72,11 +72,11 @@ namespace OpenSim.Services.Connectors.Simulation
|
||||||
string uri = string.Empty;
|
string uri = string.Empty;
|
||||||
try
|
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)
|
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;
|
reason = e.Message;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -98,11 +98,13 @@ namespace OpenSim.Services.Connectors.Simulation
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
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
|
// Add the input arguments
|
||||||
args["destination_handle"] = OSD.FromString(m_Region.RegionHandle.ToString());
|
args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
|
||||||
args["destination_name"] = OSD.FromString(m_Region.RegionName);
|
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());
|
args["teleport_flags"] = OSD.FromString(flags.ToString());
|
||||||
|
|
||||||
string strBuffer = "";
|
string strBuffer = "";
|
||||||
|
@ -116,7 +118,7 @@ namespace OpenSim.Services.Connectors.Simulation
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
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.
|
// 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
|
AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send
|
||||||
os = AgentCreateRequest.GetRequestStream();
|
os = AgentCreateRequest.GetRequestStream();
|
||||||
os.Write(buffer, 0, strBuffer.Length); //Send it
|
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 (WebException ex)
|
||||||
catch
|
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";
|
reason = "cannot contact remote region";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -142,7 +144,7 @@ namespace OpenSim.Services.Connectors.Simulation
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let's wait for the response
|
// 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;
|
WebResponse webResponse = null;
|
||||||
StreamReader sr = null;
|
StreamReader sr = null;
|
||||||
|
@ -151,14 +153,14 @@ namespace OpenSim.Services.Connectors.Simulation
|
||||||
webResponse = AgentCreateRequest.GetResponse();
|
webResponse = AgentCreateRequest.GetResponse();
|
||||||
if (webResponse == null)
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
sr = new StreamReader(webResponse.GetResponseStream());
|
sr = new StreamReader(webResponse.GetResponseStream());
|
||||||
string response = sr.ReadToEnd().Trim();
|
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))
|
if (!String.IsNullOrEmpty(response))
|
||||||
{
|
{
|
||||||
|
@ -172,7 +174,7 @@ namespace OpenSim.Services.Connectors.Simulation
|
||||||
}
|
}
|
||||||
catch (NullReferenceException e)
|
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
|
// check for old style response
|
||||||
if (response.ToLower().StartsWith("true"))
|
if (response.ToLower().StartsWith("true"))
|
||||||
|
@ -185,7 +187,7 @@ namespace OpenSim.Services.Connectors.Simulation
|
||||||
}
|
}
|
||||||
catch (WebException ex)
|
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
|
// ignore, really
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -197,28 +199,189 @@ namespace OpenSim.Services.Connectors.Simulation
|
||||||
return true;
|
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;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ReleaseAgent(ulong regionHandle, UUID id, string uri)
|
public bool ReleaseAgent(GridRegion destination, UUID id, string uri)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CloseAgent(ulong regionHandle, UUID id)
|
public bool CloseAgent(GridRegion destination, UUID id)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -227,12 +390,12 @@ namespace OpenSim.Services.Connectors.Simulation
|
||||||
|
|
||||||
#region Objects
|
#region Objects
|
||||||
|
|
||||||
public bool CreateObject(ulong regionHandle, ISceneObject sog, bool isLocalCall)
|
public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CreateObject(ulong regionHandle, UUID userID, UUID itemID)
|
public bool CreateObject(GridRegion destination, UUID userID, UUID itemID)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,8 @@ using System;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
|
|
||||||
|
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
|
||||||
|
|
||||||
namespace OpenSim.Services.Interfaces
|
namespace OpenSim.Services.Interfaces
|
||||||
{
|
{
|
||||||
public interface ISimulationService
|
public interface ISimulationService
|
||||||
|
@ -37,7 +39,7 @@ namespace OpenSim.Services.Interfaces
|
||||||
|
|
||||||
#region Agents
|
#region Agents
|
||||||
|
|
||||||
bool CreateAgent(ulong regionHandle, AgentCircuitData aCircuit, uint flags, out string reason);
|
bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Full child agent update.
|
/// Full child agent update.
|
||||||
|
@ -45,7 +47,7 @@ namespace OpenSim.Services.Interfaces
|
||||||
/// <param name="regionHandle"></param>
|
/// <param name="regionHandle"></param>
|
||||||
/// <param name="data"></param>
|
/// <param name="data"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
bool UpdateAgent(ulong regionHandle, AgentData data);
|
bool UpdateAgent(GridRegion destination, AgentData data);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Short child agent update, mostly for position.
|
/// Short child agent update, mostly for position.
|
||||||
|
@ -53,9 +55,9 @@ namespace OpenSim.Services.Interfaces
|
||||||
/// <param name="regionHandle"></param>
|
/// <param name="regionHandle"></param>
|
||||||
/// <param name="data"></param>
|
/// <param name="data"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
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);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Message from receiving region to departing region, telling it got contacted by the client.
|
/// Message from receiving region to departing region, telling it got contacted by the client.
|
||||||
|
@ -65,7 +67,7 @@ namespace OpenSim.Services.Interfaces
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <param name="uri"></param>
|
/// <param name="uri"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
bool ReleaseAgent(ulong regionHandle, UUID id, string uri);
|
bool ReleaseAgent(GridRegion destination, UUID id, string uri);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Close agent.
|
/// Close agent.
|
||||||
|
@ -73,7 +75,7 @@ namespace OpenSim.Services.Interfaces
|
||||||
/// <param name="regionHandle"></param>
|
/// <param name="regionHandle"></param>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
bool CloseAgent(ulong regionHandle, UUID id);
|
bool CloseAgent(GridRegion destination, UUID id);
|
||||||
|
|
||||||
#endregion Agents
|
#endregion Agents
|
||||||
|
|
||||||
|
@ -86,7 +88,7 @@ namespace OpenSim.Services.Interfaces
|
||||||
/// <param name="sog"></param>
|
/// <param name="sog"></param>
|
||||||
/// <param name="isLocalCall"></param>
|
/// <param name="isLocalCall"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
bool CreateObject(ulong regionHandle, ISceneObject sog, bool isLocalCall);
|
bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create an object from the user's inventory in the destination region.
|
/// Create an object from the user's inventory in the destination region.
|
||||||
|
@ -96,7 +98,7 @@ namespace OpenSim.Services.Interfaces
|
||||||
/// <param name="userID"></param>
|
/// <param name="userID"></param>
|
||||||
/// <param name="itemID"></param>
|
/// <param name="itemID"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
bool CreateObject(ulong regionHandle, UUID userID, UUID itemID);
|
bool CreateObject(GridRegion destination, UUID userID, UUID itemID);
|
||||||
|
|
||||||
#endregion Objects
|
#endregion Objects
|
||||||
|
|
||||||
|
|
|
@ -370,7 +370,7 @@ namespace OpenSim.Services.LLLoginService
|
||||||
aCircuit.SessionID = session;
|
aCircuit.SessionID = session;
|
||||||
aCircuit.startpos = position;
|
aCircuit.startpos = position;
|
||||||
|
|
||||||
if (simConnector.CreateAgent(region.RegionHandle, aCircuit, 0, out reason))
|
if (simConnector.CreateAgent(region, aCircuit, 0, out reason))
|
||||||
return aCircuit;
|
return aCircuit;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
GridServices = "HGGridServicesConnector"
|
GridServices = "HGGridServicesConnector"
|
||||||
PresenceServices = "LocalPresenceServicesConnector"
|
PresenceServices = "LocalPresenceServicesConnector"
|
||||||
UserAccountServices = "LocalUserAccountServicesConnector"
|
UserAccountServices = "LocalUserAccountServicesConnector"
|
||||||
|
SimulationServices = "RemoteSimulationConnectorModule"
|
||||||
InventoryServiceInConnector = true
|
InventoryServiceInConnector = true
|
||||||
AssetServiceInConnector = true
|
AssetServiceInConnector = true
|
||||||
HGAuthServiceInConnector = true
|
HGAuthServiceInConnector = true
|
||||||
|
|
Loading…
Reference in New Issue