diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs (renamed from OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs) | 180 |
1 files changed, 109 insertions, 71 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index d68c683..e913891 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs | |||
@@ -33,33 +33,49 @@ using OpenMetaverse; | |||
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
35 | using OpenSim.Region.Framework.Scenes; | 35 | using OpenSim.Region.Framework.Scenes; |
36 | using OpenSim.Services.Interfaces; | ||
37 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
36 | 38 | ||
37 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | 39 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation |
38 | { | 40 | { |
39 | public class LocalInterregionComms : ISharedRegionModule, IInterregionCommsOut, IInterregionCommsIn | 41 | public class LocalSimulationConnectorModule : ISharedRegionModule, ISimulationService |
40 | { | 42 | { |
41 | private bool m_enabled = false; | ||
42 | |||
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
44 | private List<Scene> m_sceneList = new List<Scene>(); | 44 | private List<Scene> m_sceneList = new List<Scene>(); |
45 | 45 | ||
46 | #region Events | 46 | private IEntityTransferModule m_AgentTransferModule; |
47 | public event ChildAgentUpdateReceived OnChildAgentUpdate; | 47 | protected IEntityTransferModule AgentTransferModule |
48 | { | ||
49 | get | ||
50 | { | ||
51 | if (m_AgentTransferModule == null) | ||
52 | m_AgentTransferModule = m_sceneList[0].RequestModuleInterface<IEntityTransferModule>(); | ||
53 | return m_AgentTransferModule; | ||
54 | } | ||
55 | } | ||
48 | 56 | ||
49 | #endregion /* Events */ | 57 | private bool m_ModuleEnabled = false; |
50 | 58 | ||
51 | #region IRegionModule | 59 | #region IRegionModule |
52 | 60 | ||
53 | public void Initialise(IConfigSource config) | 61 | public void Initialise(IConfigSource config) |
54 | { | 62 | { |
55 | if (m_sceneList.Count == 0) | 63 | IConfig moduleConfig = config.Configs["Modules"]; |
64 | if (moduleConfig != null) | ||
56 | { | 65 | { |
57 | IConfig startupConfig = config.Configs["Communications"]; | 66 | string name = moduleConfig.GetString("SimulationServices", ""); |
58 | 67 | if (name == Name) | |
59 | if ((startupConfig != null) && (startupConfig.GetString("InterregionComms", "RESTComms") == "LocalComms")) | ||
60 | { | 68 | { |
61 | m_log.Debug("[LOCAL COMMS]: Enabling InterregionComms LocalComms module"); | 69 | //IConfig userConfig = config.Configs["SimulationService"]; |
62 | m_enabled = true; | 70 | //if (userConfig == null) |
71 | //{ | ||
72 | // m_log.Error("[AVATAR CONNECTOR]: SimulationService missing from OpanSim.ini"); | ||
73 | // return; | ||
74 | //} | ||
75 | |||
76 | m_ModuleEnabled = true; | ||
77 | |||
78 | m_log.Info("[SIMULATION CONNECTOR]: Local simulation enabled"); | ||
63 | } | 79 | } |
64 | } | 80 | } |
65 | } | 81 | } |
@@ -70,22 +86,24 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
70 | 86 | ||
71 | public void AddRegion(Scene scene) | 87 | public void AddRegion(Scene scene) |
72 | { | 88 | { |
89 | if (!m_ModuleEnabled) | ||
90 | return; | ||
91 | |||
92 | Init(scene); | ||
93 | scene.RegisterModuleInterface<ISimulationService>(this); | ||
73 | } | 94 | } |
74 | 95 | ||
75 | public void RemoveRegion(Scene scene) | 96 | public void RemoveRegion(Scene scene) |
76 | { | 97 | { |
77 | if (m_enabled) | 98 | if (!m_ModuleEnabled) |
78 | { | 99 | return; |
79 | RemoveScene(scene); | 100 | |
80 | } | 101 | RemoveScene(scene); |
102 | scene.UnregisterModuleInterface<ISimulationService>(this); | ||
81 | } | 103 | } |
82 | 104 | ||
83 | public void RegionLoaded(Scene scene) | 105 | public void RegionLoaded(Scene scene) |
84 | { | 106 | { |
85 | if (m_enabled) | ||
86 | { | ||
87 | Init(scene); | ||
88 | } | ||
89 | } | 107 | } |
90 | 108 | ||
91 | public void Close() | 109 | public void Close() |
@@ -99,7 +117,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
99 | 117 | ||
100 | public string Name | 118 | public string Name |
101 | { | 119 | { |
102 | get { return "LocalInterregionCommsModule"; } | 120 | get { return "LocalSimulationConnectorModule"; } |
103 | } | 121 | } |
104 | 122 | ||
105 | /// <summary> | 123 | /// <summary> |
@@ -128,9 +146,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
128 | lock (m_sceneList) | 146 | lock (m_sceneList) |
129 | { | 147 | { |
130 | m_sceneList.Add(scene); | 148 | m_sceneList.Add(scene); |
131 | if (m_enabled) | ||
132 | scene.RegisterModuleInterface<IInterregionCommsOut>(this); | ||
133 | scene.RegisterModuleInterface<IInterregionCommsIn>(this); | ||
134 | } | 149 | } |
135 | 150 | ||
136 | } | 151 | } |
@@ -138,40 +153,58 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
138 | 153 | ||
139 | #endregion /* IRegionModule */ | 154 | #endregion /* IRegionModule */ |
140 | 155 | ||
141 | #region IInterregionComms | 156 | #region ISimulation |
157 | |||
158 | public IScene GetScene(ulong regionhandle) | ||
159 | { | ||
160 | foreach (Scene s in m_sceneList) | ||
161 | { | ||
162 | if (s.RegionInfo.RegionHandle == regionhandle) | ||
163 | return s; | ||
164 | } | ||
165 | // ? weird. should not happen | ||
166 | return m_sceneList[0]; | ||
167 | } | ||
142 | 168 | ||
143 | /** | 169 | /** |
144 | * Agent-related communications | 170 | * Agent-related communications |
145 | */ | 171 | */ |
146 | 172 | ||
147 | public bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit, uint teleportFlags, out string reason) | 173 | public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason) |
148 | { | 174 | { |
175 | if (destination == null) | ||
176 | { | ||
177 | reason = "Given destination was null"; | ||
178 | m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: CreateAgent was given a null destination"); | ||
179 | return false; | ||
180 | } | ||
149 | 181 | ||
150 | foreach (Scene s in m_sceneList) | 182 | foreach (Scene s in m_sceneList) |
151 | { | 183 | { |
152 | if (s.RegionInfo.RegionHandle == regionHandle) | 184 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) |
153 | { | 185 | { |
154 | // m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", regionHandle); | 186 | m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: Found region {0} to send SendCreateChildAgent", destination.RegionName); |
155 | return s.NewUserConnection(aCircuit, teleportFlags, out reason); | 187 | return s.NewUserConnection(aCircuit, teleportFlags, out reason); |
156 | } | 188 | } |
157 | } | 189 | } |
158 | 190 | ||
159 | // m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", regionHandle); | 191 | m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: Did not find region {0} for SendCreateChildAgent", destination.RegionName); |
160 | uint x = 0, y = 0; | 192 | reason = "Did not find region " + destination.RegionName; |
161 | Utils.LongToUInts(regionHandle, out x, out y); | ||
162 | reason = "Did not find region " + x + "-" + y; | ||
163 | return false; | 193 | return false; |
164 | } | 194 | } |
165 | 195 | ||
166 | public bool SendChildAgentUpdate(ulong regionHandle, AgentData cAgentData) | 196 | public bool UpdateAgent(GridRegion destination, AgentData cAgentData) |
167 | { | 197 | { |
198 | if (destination == null) | ||
199 | return false; | ||
200 | |||
168 | foreach (Scene s in m_sceneList) | 201 | foreach (Scene s in m_sceneList) |
169 | { | 202 | { |
170 | if (s.RegionInfo.RegionHandle == regionHandle) | 203 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) |
171 | { | 204 | { |
172 | //m_log.DebugFormat( | 205 | m_log.DebugFormat( |
173 | // "[LOCAL COMMS]: Found region {0} {1} to send ChildAgentUpdate", | 206 | "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", |
174 | // s.RegionInfo.RegionName, regionHandle); | 207 | s.RegionInfo.RegionName, destination.RegionHandle); |
175 | 208 | ||
176 | s.IncomingChildAgentDataUpdate(cAgentData); | 209 | s.IncomingChildAgentDataUpdate(cAgentData); |
177 | return true; | 210 | return true; |
@@ -182,11 +215,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
182 | return false; | 215 | return false; |
183 | } | 216 | } |
184 | 217 | ||
185 | public bool SendChildAgentUpdate(ulong regionHandle, AgentPosition cAgentData) | 218 | public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData) |
186 | { | 219 | { |
220 | if (destination == null) | ||
221 | return false; | ||
222 | |||
187 | foreach (Scene s in m_sceneList) | 223 | foreach (Scene s in m_sceneList) |
188 | { | 224 | { |
189 | if (s.RegionInfo.RegionHandle == regionHandle) | 225 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) |
190 | { | 226 | { |
191 | //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); | 227 | //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); |
192 | s.IncomingChildAgentDataUpdate(cAgentData); | 228 | s.IncomingChildAgentDataUpdate(cAgentData); |
@@ -197,12 +233,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
197 | return false; | 233 | return false; |
198 | } | 234 | } |
199 | 235 | ||
200 | public bool SendRetrieveRootAgent(ulong regionHandle, UUID id, out IAgentData agent) | 236 | public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) |
201 | { | 237 | { |
202 | agent = null; | 238 | agent = null; |
239 | |||
240 | if (destination == null) | ||
241 | return false; | ||
242 | |||
203 | foreach (Scene s in m_sceneList) | 243 | foreach (Scene s in m_sceneList) |
204 | { | 244 | { |
205 | if (s.RegionInfo.RegionHandle == regionHandle) | 245 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) |
206 | { | 246 | { |
207 | //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); | 247 | //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); |
208 | return s.IncomingRetrieveRootAgent(id, out agent); | 248 | return s.IncomingRetrieveRootAgent(id, out agent); |
@@ -212,35 +252,30 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
212 | return false; | 252 | return false; |
213 | } | 253 | } |
214 | 254 | ||
215 | public bool SendReleaseAgent(ulong regionHandle, UUID id, string uri) | 255 | public bool ReleaseAgent(UUID origin, UUID id, string uri) |
216 | { | 256 | { |
217 | //uint x, y; | ||
218 | //Utils.LongToUInts(regionHandle, out x, out y); | ||
219 | //x = x / Constants.RegionSize; | ||
220 | //y = y / Constants.RegionSize; | ||
221 | //m_log.Debug("\n >>> Local SendReleaseAgent " + x + "-" + y); | ||
222 | foreach (Scene s in m_sceneList) | 257 | foreach (Scene s in m_sceneList) |
223 | { | 258 | { |
224 | if (s.RegionInfo.RegionHandle == regionHandle) | 259 | if (s.RegionInfo.RegionID == origin) |
225 | { | 260 | { |
226 | //m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent"); | 261 | m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent"); |
227 | return s.IncomingReleaseAgent(id); | 262 | AgentTransferModule.AgentArrivedAtDestination(id); |
263 | return true; | ||
264 | // return s.IncomingReleaseAgent(id); | ||
228 | } | 265 | } |
229 | } | 266 | } |
230 | //m_log.Debug("[LOCAL COMMS]: region not found in SendReleaseAgent"); | 267 | //m_log.Debug("[LOCAL COMMS]: region not found in SendReleaseAgent " + origin); |
231 | return false; | 268 | return false; |
232 | } | 269 | } |
233 | 270 | ||
234 | public bool SendCloseAgent(ulong regionHandle, UUID id) | 271 | public bool CloseAgent(GridRegion destination, UUID id) |
235 | { | 272 | { |
236 | //uint x, y; | 273 | if (destination == null) |
237 | //Utils.LongToUInts(regionHandle, out x, out y); | 274 | return false; |
238 | //x = x / Constants.RegionSize; | 275 | |
239 | //y = y / Constants.RegionSize; | ||
240 | //m_log.Debug("\n >>> Local SendCloseAgent " + x + "-" + y); | ||
241 | foreach (Scene s in m_sceneList) | 276 | foreach (Scene s in m_sceneList) |
242 | { | 277 | { |
243 | if (s.RegionInfo.RegionHandle == regionHandle) | 278 | if (s.RegionInfo.RegionID == destination.RegionID) |
244 | { | 279 | { |
245 | //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent"); | 280 | //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent"); |
246 | return s.IncomingCloseAgent(id); | 281 | return s.IncomingCloseAgent(id); |
@@ -254,11 +289,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
254 | * Object-related communications | 289 | * Object-related communications |
255 | */ | 290 | */ |
256 | 291 | ||
257 | public bool SendCreateObject(ulong regionHandle, SceneObjectGroup sog, bool isLocalCall) | 292 | public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) |
258 | { | 293 | { |
294 | if (destination == null) | ||
295 | return false; | ||
296 | |||
259 | foreach (Scene s in m_sceneList) | 297 | foreach (Scene s in m_sceneList) |
260 | { | 298 | { |
261 | if (s.RegionInfo.RegionHandle == regionHandle) | 299 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) |
262 | { | 300 | { |
263 | //m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject"); | 301 | //m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject"); |
264 | if (isLocalCall) | 302 | if (isLocalCall) |
@@ -278,11 +316,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
278 | return false; | 316 | return false; |
279 | } | 317 | } |
280 | 318 | ||
281 | public bool SendCreateObject(ulong regionHandle, UUID userID, UUID itemID) | 319 | public bool CreateObject(GridRegion destination, UUID userID, UUID itemID) |
282 | { | 320 | { |
321 | if (destination == null) | ||
322 | return false; | ||
323 | |||
283 | foreach (Scene s in m_sceneList) | 324 | foreach (Scene s in m_sceneList) |
284 | { | 325 | { |
285 | if (s.RegionInfo.RegionHandle == regionHandle) | 326 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) |
286 | { | 327 | { |
287 | return s.IncomingCreateObject(userID, itemID); | 328 | return s.IncomingCreateObject(userID, itemID); |
288 | } | 329 | } |
@@ -295,21 +336,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
295 | 336 | ||
296 | #region Misc | 337 | #region Misc |
297 | 338 | ||
298 | public Scene GetScene(ulong regionhandle) | 339 | public bool IsLocalRegion(ulong regionhandle) |
299 | { | 340 | { |
300 | foreach (Scene s in m_sceneList) | 341 | foreach (Scene s in m_sceneList) |
301 | { | ||
302 | if (s.RegionInfo.RegionHandle == regionhandle) | 342 | if (s.RegionInfo.RegionHandle == regionhandle) |
303 | return s; | 343 | return true; |
304 | } | 344 | return false; |
305 | // ? weird. should not happen | ||
306 | return m_sceneList[0]; | ||
307 | } | 345 | } |
308 | 346 | ||
309 | public bool IsLocalRegion(ulong regionhandle) | 347 | public bool IsLocalRegion(UUID id) |
310 | { | 348 | { |
311 | foreach (Scene s in m_sceneList) | 349 | foreach (Scene s in m_sceneList) |
312 | if (s.RegionInfo.RegionHandle == regionhandle) | 350 | if (s.RegionInfo.RegionID == id) |
313 | return true; | 351 | return true; |
314 | return false; | 352 | return false; |
315 | } | 353 | } |