28 using System.Collections.Generic;
30 using System.Reflection;
35 using OpenSim.Framework;
36 using OpenSim.Region.Framework.Interfaces;
37 using OpenSim.Region.Framework.Scenes;
38 using OpenSim.Services.Interfaces;
43 [Extension(Path =
"/OpenSim/RegionModules", NodeName =
"RegionModule", Id =
"LocalSimulationConnectorModule")]
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 private Dictionary<UUID, Scene> m_scenes =
new Dictionary<UUID, Scene>();
56 private bool m_ModuleEnabled =
false;
58 #region Region Module interface
62 IConfig moduleConfig = configSource.Configs[
"Modules"];
63 if (moduleConfig != null)
65 string name = moduleConfig.GetString(
"SimulationServices",
"");
68 InitialiseService(configSource);
70 m_ModuleEnabled =
true;
72 m_log.Info(
"[LOCAL SIMULATION CONNECTOR]: Local simulation enabled.");
111 public Type ReplaceableInterface
118 get {
return "LocalSimulationConnectorModule"; }
133 "[LOCAL SIMULATION CONNECTOR]: Tried to remove region {0} but it was not present",
134 scene.RegionInfo.RegionName);
150 "[LOCAL SIMULATION CONNECTOR]: Tried to add region {0} but it is already present",
157 #region ISimulationService
161 if (m_scenes.ContainsKey(regionId))
163 return m_scenes[regionId];
169 Scene s = m_scenes.Values.ToArray()[0];
172 "[LOCAL SIMULATION CONNECTOR]: Region with id {0} not found. Returning {1} {2} instead",
173 regionId, s.RegionInfo.RegionName, s.RegionInfo.RegionID);
190 if (destination == null)
192 reason =
"Given destination was null";
193 m_log.DebugFormat(
"[LOCAL SIMULATION CONNECTOR]: CreateAgent was given a null destination");
197 if (m_scenes.ContainsKey(destination.
RegionID))
200 return m_scenes[destination.RegionID].NewUserConnection(aCircuit, teleportFlags, source, out reason);
203 reason =
"Did not find region " + destination.RegionName;
209 if (destination == null)
212 if (m_scenes.ContainsKey(destination.
RegionID))
218 return m_scenes[destination.RegionID].IncomingUpdateChildAgent(cAgentData);
230 if (destination == null)
237 foreach (
Scene s
in m_scenes.Values)
240 s.IncomingUpdateChildAgent(agentPosition);
249 reason =
"Communications failure";
250 if (destination == null)
253 if (m_scenes.ContainsKey(destination.
RegionID))
258 uint sizeX = m_scenes[destination.RegionID].RegionInfo.RegionSizeX;
259 uint sizeY = m_scenes[destination.RegionID].RegionInfo.RegionSizeY;
265 reason =
"Destination is a variable-sized region, and source is an old simulator. Consider upgrading.";
266 m_log.DebugFormat(
"[LOCAL SIMULATION CONNECTOR]: Request to access this variable-sized region from older simulator was denied");
272 return m_scenes[destination.RegionID].QueryAccess(agentID, agentHomeURI, viaTeleport, position, features, out reason);
281 if (m_scenes.ContainsKey(originId))
287 m_scenes[originId].EntityTransferModule.AgentArrivedAtDestination(agentId);
297 if (destination == null)
300 if (m_scenes.ContainsKey(destination.
RegionID))
306 m_scenes[destination.RegionID].CloseAgent(id,
false, auth_token);
319 if (destination == null)
322 if (m_scenes.ContainsKey(destination.
RegionID))
328 Scene s = m_scenes[destination.RegionID];
334 sogClone.SetState(sog.GetStateSnapshot(), s);
335 return s.IncomingCreateObject(newPosition, sogClone);
340 return s.IncomingCreateObject(newPosition, sog);
353 foreach (
Scene s
in m_scenes.Values)
362 return m_scenes.ContainsKey(id);
OpenSim.Services.Interfaces.GridRegion GridRegion
void RemoveScene(Scene scene)
Can be called from other modules.
bool ReleaseAgent(UUID originId, UUID agentId, string uri)
Message from receiving region to departing region, telling it got contacted by the client...
bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, List< UUID > features, EntityTransferContext ctx, out string reason)
Returns whether a propspective user is allowed to visit the region.
IScene GetScene(UUID regionId)
Retrieve the scene with the given region ID.
void Init(Scene scene)
Can be called from other modules.
bool UpdateAgent(GridRegion destination, AgentData cAgentData, EntityTransferContext ctx)
Full child agent update.
void InitialiseService(IConfigSource configSource)
void PostInitialise()
This is called exactly once after all the shared region-modules have been instanciated and IRegionMod...
void Initialise(IConfigSource configSource)
This is called to initialize the region module. For shared modules, this is called exactly once...
bool IsLocalRegion(UUID id)
void RemoveRegion(Scene scene)
This is called whenever a Scene is removed. For shared modules, this can happen several times...
bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, EntityTransferContext ctx, out string reason)
void RegionLoaded(Scene scene)
This will be called once for every scene loaded. In a shared module this will be multiple times in on...
Circuit data for an agent. Connection information shared between regions that accept UDP connections ...
bool CloseAgent(GridRegion destination, UUID id, string auth_token)
Close agent.
ISimulationService GetInnerService()
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...
Replacement for ChildAgentDataUpdate. Used over RESTComms and LocalComms.
bool IsLocalRegion(ulong regionhandle)
Interactive OpenSim region server
bool CreateObject(GridRegion destination, Vector3 newPosition, ISceneObject sog, bool isLocalCall)
void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...
virtual RegionInfo RegionInfo
bool UpdateAgent(GridRegion destination, AgentPosition agentPosition)
Short child agent update, mostly for position.