diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation')
2 files changed, 699 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs new file mode 100644 index 0000000..074bfb5 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs | |||
@@ -0,0 +1,339 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Reflection; | ||
30 | using log4net; | ||
31 | using Nini.Config; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Region.Framework.Interfaces; | ||
35 | using OpenSim.Region.Framework.Scenes; | ||
36 | using OpenSim.Services.Interfaces; | ||
37 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
38 | |||
39 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | ||
40 | { | ||
41 | public class LocalSimulationConnectorModule : ISharedRegionModule, ISimulationService | ||
42 | { | ||
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
44 | private List<Scene> m_sceneList = new List<Scene>(); | ||
45 | |||
46 | private bool m_ModuleEnabled = false; | ||
47 | |||
48 | #region IRegionModule | ||
49 | |||
50 | public void Initialise(IConfigSource config) | ||
51 | { | ||
52 | IConfig moduleConfig = config.Configs["Modules"]; | ||
53 | if (moduleConfig != null) | ||
54 | { | ||
55 | string name = moduleConfig.GetString("SimulationServices", ""); | ||
56 | if (name == Name) | ||
57 | { | ||
58 | //IConfig userConfig = config.Configs["SimulationService"]; | ||
59 | //if (userConfig == null) | ||
60 | //{ | ||
61 | // m_log.Error("[AVATAR CONNECTOR]: SimulationService missing from OpanSim.ini"); | ||
62 | // return; | ||
63 | //} | ||
64 | |||
65 | m_ModuleEnabled = true; | ||
66 | |||
67 | m_log.Info("[SIMULATION CONNECTOR]: Local simulation enabled"); | ||
68 | } | ||
69 | } | ||
70 | } | ||
71 | |||
72 | public void PostInitialise() | ||
73 | { | ||
74 | } | ||
75 | |||
76 | public void AddRegion(Scene scene) | ||
77 | { | ||
78 | if (!m_ModuleEnabled) | ||
79 | return; | ||
80 | |||
81 | Init(scene); | ||
82 | scene.RegisterModuleInterface<ISimulationService>(this); | ||
83 | } | ||
84 | |||
85 | public void RemoveRegion(Scene scene) | ||
86 | { | ||
87 | if (!m_ModuleEnabled) | ||
88 | return; | ||
89 | |||
90 | RemoveScene(scene); | ||
91 | scene.UnregisterModuleInterface<ISimulationService>(this); | ||
92 | } | ||
93 | |||
94 | public void RegionLoaded(Scene scene) | ||
95 | { | ||
96 | } | ||
97 | |||
98 | public void Close() | ||
99 | { | ||
100 | } | ||
101 | |||
102 | public Type ReplaceableInterface | ||
103 | { | ||
104 | get { return null; } | ||
105 | } | ||
106 | |||
107 | public string Name | ||
108 | { | ||
109 | get { return "LocalSimulationConnectorModule"; } | ||
110 | } | ||
111 | |||
112 | /// <summary> | ||
113 | /// Can be called from other modules. | ||
114 | /// </summary> | ||
115 | /// <param name="scene"></param> | ||
116 | public void RemoveScene(Scene scene) | ||
117 | { | ||
118 | lock (m_sceneList) | ||
119 | { | ||
120 | if (m_sceneList.Contains(scene)) | ||
121 | { | ||
122 | m_sceneList.Remove(scene); | ||
123 | } | ||
124 | } | ||
125 | } | ||
126 | |||
127 | /// <summary> | ||
128 | /// Can be called from other modules. | ||
129 | /// </summary> | ||
130 | /// <param name="scene"></param> | ||
131 | public void Init(Scene scene) | ||
132 | { | ||
133 | if (!m_sceneList.Contains(scene)) | ||
134 | { | ||
135 | lock (m_sceneList) | ||
136 | { | ||
137 | m_sceneList.Add(scene); | ||
138 | } | ||
139 | |||
140 | } | ||
141 | } | ||
142 | |||
143 | #endregion /* IRegionModule */ | ||
144 | |||
145 | #region ISimulation | ||
146 | |||
147 | public IScene GetScene(ulong regionhandle) | ||
148 | { | ||
149 | foreach (Scene s in m_sceneList) | ||
150 | { | ||
151 | if (s.RegionInfo.RegionHandle == regionhandle) | ||
152 | return s; | ||
153 | } | ||
154 | // ? weird. should not happen | ||
155 | return m_sceneList[0]; | ||
156 | } | ||
157 | |||
158 | /** | ||
159 | * Agent-related communications | ||
160 | */ | ||
161 | |||
162 | public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason) | ||
163 | { | ||
164 | if (destination == null) | ||
165 | { | ||
166 | reason = "Given destination was null"; | ||
167 | m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: CreateAgent was given a null destination"); | ||
168 | return false; | ||
169 | } | ||
170 | |||
171 | foreach (Scene s in m_sceneList) | ||
172 | { | ||
173 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
174 | { | ||
175 | // m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", regionHandle); | ||
176 | return s.NewUserConnection(aCircuit, teleportFlags, out reason); | ||
177 | } | ||
178 | } | ||
179 | |||
180 | // m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", regionHandle); | ||
181 | reason = "Did not find region " + destination.RegionName; | ||
182 | return false; | ||
183 | } | ||
184 | |||
185 | public bool UpdateAgent(GridRegion destination, AgentData cAgentData) | ||
186 | { | ||
187 | if (destination == null) | ||
188 | return false; | ||
189 | |||
190 | foreach (Scene s in m_sceneList) | ||
191 | { | ||
192 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
193 | { | ||
194 | //m_log.DebugFormat( | ||
195 | // "[LOCAL COMMS]: Found region {0} {1} to send ChildAgentUpdate", | ||
196 | // s.RegionInfo.RegionName, regionHandle); | ||
197 | |||
198 | s.IncomingChildAgentDataUpdate(cAgentData); | ||
199 | return true; | ||
200 | } | ||
201 | } | ||
202 | |||
203 | // m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for ChildAgentUpdate", regionHandle); | ||
204 | return false; | ||
205 | } | ||
206 | |||
207 | public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData) | ||
208 | { | ||
209 | if (destination == null) | ||
210 | return false; | ||
211 | |||
212 | foreach (Scene s in m_sceneList) | ||
213 | { | ||
214 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
215 | { | ||
216 | //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); | ||
217 | s.IncomingChildAgentDataUpdate(cAgentData); | ||
218 | return true; | ||
219 | } | ||
220 | } | ||
221 | //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); | ||
222 | return false; | ||
223 | } | ||
224 | |||
225 | public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) | ||
226 | { | ||
227 | agent = null; | ||
228 | |||
229 | if (destination == null) | ||
230 | return false; | ||
231 | |||
232 | foreach (Scene s in m_sceneList) | ||
233 | { | ||
234 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
235 | { | ||
236 | //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); | ||
237 | return s.IncomingRetrieveRootAgent(id, out agent); | ||
238 | } | ||
239 | } | ||
240 | //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); | ||
241 | return false; | ||
242 | } | ||
243 | |||
244 | public bool ReleaseAgent(GridRegion destination, UUID id, string uri) | ||
245 | { | ||
246 | if (destination == null) | ||
247 | return false; | ||
248 | |||
249 | foreach (Scene s in m_sceneList) | ||
250 | { | ||
251 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
252 | { | ||
253 | //m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent"); | ||
254 | return s.IncomingReleaseAgent(id); | ||
255 | } | ||
256 | } | ||
257 | //m_log.Debug("[LOCAL COMMS]: region not found in SendReleaseAgent"); | ||
258 | return false; | ||
259 | } | ||
260 | |||
261 | public bool CloseAgent(GridRegion destination, UUID id) | ||
262 | { | ||
263 | if (destination == null) | ||
264 | return false; | ||
265 | |||
266 | foreach (Scene s in m_sceneList) | ||
267 | { | ||
268 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
269 | { | ||
270 | //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent"); | ||
271 | return s.IncomingCloseAgent(id); | ||
272 | } | ||
273 | } | ||
274 | //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent"); | ||
275 | return false; | ||
276 | } | ||
277 | |||
278 | /** | ||
279 | * Object-related communications | ||
280 | */ | ||
281 | |||
282 | public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) | ||
283 | { | ||
284 | if (destination == null) | ||
285 | return false; | ||
286 | |||
287 | foreach (Scene s in m_sceneList) | ||
288 | { | ||
289 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
290 | { | ||
291 | //m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject"); | ||
292 | if (isLocalCall) | ||
293 | { | ||
294 | // We need to make a local copy of the object | ||
295 | ISceneObject sogClone = sog.CloneForNewScene(); | ||
296 | sogClone.SetState(sog.GetStateSnapshot(), s); | ||
297 | return s.IncomingCreateObject(sogClone); | ||
298 | } | ||
299 | else | ||
300 | { | ||
301 | // Use the object as it came through the wire | ||
302 | return s.IncomingCreateObject(sog); | ||
303 | } | ||
304 | } | ||
305 | } | ||
306 | return false; | ||
307 | } | ||
308 | |||
309 | public bool CreateObject(GridRegion destination, UUID userID, UUID itemID) | ||
310 | { | ||
311 | if (destination == null) | ||
312 | return false; | ||
313 | |||
314 | foreach (Scene s in m_sceneList) | ||
315 | { | ||
316 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
317 | { | ||
318 | return s.IncomingCreateObject(userID, itemID); | ||
319 | } | ||
320 | } | ||
321 | return false; | ||
322 | } | ||
323 | |||
324 | |||
325 | #endregion /* IInterregionComms */ | ||
326 | |||
327 | #region Misc | ||
328 | |||
329 | public bool IsLocalRegion(ulong regionhandle) | ||
330 | { | ||
331 | foreach (Scene s in m_sceneList) | ||
332 | if (s.RegionInfo.RegionHandle == regionhandle) | ||
333 | return true; | ||
334 | return false; | ||
335 | } | ||
336 | |||
337 | #endregion | ||
338 | } | ||
339 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs new file mode 100644 index 0000000..c9cc368 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs | |||
@@ -0,0 +1,360 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.IO; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Text; | ||
34 | using log4net; | ||
35 | using Nini.Config; | ||
36 | using OpenMetaverse; | ||
37 | using OpenMetaverse.StructuredData; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Framework.Communications; | ||
40 | using OpenSim.Framework.Communications.Clients; | ||
41 | using OpenSim.Region.Framework.Interfaces; | ||
42 | using OpenSim.Region.Framework.Scenes; | ||
43 | using OpenSim.Region.Framework.Scenes.Hypergrid; | ||
44 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
45 | using OpenSim.Services.Interfaces; | ||
46 | using OpenSim.Services.Connectors.Simulation; | ||
47 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
48 | |||
49 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | ||
50 | { | ||
51 | public class RemoteSimulationConnectorModule : ISharedRegionModule, ISimulationService | ||
52 | { | ||
53 | private bool initialized = false; | ||
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
55 | |||
56 | protected bool m_enabled = false; | ||
57 | protected Scene m_aScene; | ||
58 | // RemoteSimulationConnector does not care about local regions; it delegates that to the Local module | ||
59 | protected LocalSimulationConnectorModule m_localBackend; | ||
60 | protected SimulationServiceConnector m_remoteConnector; | ||
61 | |||
62 | protected CommunicationsManager m_commsManager; | ||
63 | |||
64 | protected IHyperlinkService m_hyperlinkService; | ||
65 | |||
66 | protected bool m_safemode; | ||
67 | protected IPAddress m_thisIP; | ||
68 | |||
69 | #region IRegionModule | ||
70 | |||
71 | public virtual void Initialise(IConfigSource config) | ||
72 | { | ||
73 | |||
74 | IConfig moduleConfig = config.Configs["Modules"]; | ||
75 | if (moduleConfig != null) | ||
76 | { | ||
77 | string name = moduleConfig.GetString("SimulationServices", ""); | ||
78 | if (name == Name) | ||
79 | { | ||
80 | //IConfig userConfig = config.Configs["SimulationService"]; | ||
81 | //if (userConfig == null) | ||
82 | //{ | ||
83 | // m_log.Error("[AVATAR CONNECTOR]: SimulationService missing from OpanSim.ini"); | ||
84 | // return; | ||
85 | //} | ||
86 | |||
87 | m_remoteConnector = new SimulationServiceConnector(); | ||
88 | |||
89 | m_enabled = true; | ||
90 | |||
91 | m_log.Info("[SIMULATION CONNECTOR]: Remote simulation enabled"); | ||
92 | } | ||
93 | } | ||
94 | } | ||
95 | |||
96 | public virtual void PostInitialise() | ||
97 | { | ||
98 | } | ||
99 | |||
100 | public virtual void Close() | ||
101 | { | ||
102 | } | ||
103 | |||
104 | public void AddRegion(Scene scene) | ||
105 | { | ||
106 | if (!m_enabled) | ||
107 | return; | ||
108 | |||
109 | if (!initialized) | ||
110 | { | ||
111 | InitOnce(scene); | ||
112 | initialized = true; | ||
113 | } | ||
114 | InitEach(scene); | ||
115 | } | ||
116 | |||
117 | public void RemoveRegion(Scene scene) | ||
118 | { | ||
119 | if (m_enabled) | ||
120 | { | ||
121 | m_localBackend.RemoveScene(scene); | ||
122 | scene.UnregisterModuleInterface<ISimulationService>(this); | ||
123 | } | ||
124 | } | ||
125 | |||
126 | public void RegionLoaded(Scene scene) | ||
127 | { | ||
128 | if (!m_enabled) | ||
129 | return; | ||
130 | |||
131 | m_hyperlinkService = m_aScene.RequestModuleInterface<IHyperlinkService>(); | ||
132 | |||
133 | } | ||
134 | |||
135 | public Type ReplaceableInterface | ||
136 | { | ||
137 | get { return null; } | ||
138 | } | ||
139 | |||
140 | public virtual string Name | ||
141 | { | ||
142 | get { return "RemoteSimulationConnectorModule"; } | ||
143 | } | ||
144 | |||
145 | protected virtual void InitEach(Scene scene) | ||
146 | { | ||
147 | m_localBackend.Init(scene); | ||
148 | scene.RegisterModuleInterface<ISimulationService>(this); | ||
149 | } | ||
150 | |||
151 | protected virtual void InitOnce(Scene scene) | ||
152 | { | ||
153 | m_localBackend = new LocalSimulationConnectorModule(); | ||
154 | m_commsManager = scene.CommsManager; | ||
155 | m_aScene = scene; | ||
156 | //m_regionClient = new RegionToRegionClient(m_aScene, m_hyperlinkService); | ||
157 | m_thisIP = Util.GetHostFromDNS(scene.RegionInfo.ExternalHostName); | ||
158 | } | ||
159 | |||
160 | #endregion /* IRegionModule */ | ||
161 | |||
162 | #region IInterregionComms | ||
163 | |||
164 | public IScene GetScene(ulong handle) | ||
165 | { | ||
166 | return m_localBackend.GetScene(handle); | ||
167 | } | ||
168 | |||
169 | /** | ||
170 | * Agent-related communications | ||
171 | */ | ||
172 | |||
173 | public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason) | ||
174 | { | ||
175 | if (destination == null) | ||
176 | { | ||
177 | reason = "Given destination was null"; | ||
178 | m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CreateAgent was given a null destination"); | ||
179 | return false; | ||
180 | } | ||
181 | |||
182 | // Try local first | ||
183 | if (m_localBackend.CreateAgent(destination, aCircuit, teleportFlags, out reason)) | ||
184 | return true; | ||
185 | |||
186 | // else do the remote thing | ||
187 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
188 | { | ||
189 | //m_regionClient.SendUserInformation(regInfo, aCircuit); | ||
190 | return m_remoteConnector.CreateAgent(destination, aCircuit, teleportFlags, out reason); | ||
191 | } | ||
192 | return false; | ||
193 | } | ||
194 | |||
195 | public bool UpdateAgent(GridRegion destination, AgentData cAgentData) | ||
196 | { | ||
197 | if (destination == null) | ||
198 | return false; | ||
199 | |||
200 | // Try local first | ||
201 | if (m_localBackend.UpdateAgent(destination, cAgentData)) | ||
202 | return true; | ||
203 | |||
204 | // else do the remote thing | ||
205 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
206 | return m_remoteConnector.UpdateAgent(destination, cAgentData); | ||
207 | |||
208 | return false; | ||
209 | |||
210 | } | ||
211 | |||
212 | public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData) | ||
213 | { | ||
214 | if (destination == null) | ||
215 | return false; | ||
216 | |||
217 | // Try local first | ||
218 | if (m_localBackend.UpdateAgent(destination, cAgentData)) | ||
219 | return true; | ||
220 | |||
221 | // else do the remote thing | ||
222 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
223 | return m_remoteConnector.UpdateAgent(destination, cAgentData); | ||
224 | |||
225 | return false; | ||
226 | |||
227 | } | ||
228 | |||
229 | public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) | ||
230 | { | ||
231 | agent = null; | ||
232 | |||
233 | if (destination == null) | ||
234 | return false; | ||
235 | |||
236 | // Try local first | ||
237 | if (m_localBackend.RetrieveAgent(destination, id, out agent)) | ||
238 | return true; | ||
239 | |||
240 | // else do the remote thing | ||
241 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
242 | return m_remoteConnector.RetrieveAgent(destination, id, out agent); | ||
243 | |||
244 | return false; | ||
245 | |||
246 | } | ||
247 | |||
248 | public bool ReleaseAgent(GridRegion destination, UUID id, string uri) | ||
249 | { | ||
250 | if (destination == null) | ||
251 | return false; | ||
252 | |||
253 | // Try local first | ||
254 | if (m_localBackend.ReleaseAgent(destination, id, uri)) | ||
255 | return true; | ||
256 | |||
257 | // else do the remote thing | ||
258 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
259 | return m_remoteConnector.ReleaseAgent(destination, id, uri); | ||
260 | |||
261 | return false; | ||
262 | } | ||
263 | |||
264 | |||
265 | public bool CloseAgent(GridRegion destination, UUID id) | ||
266 | { | ||
267 | if (destination == null) | ||
268 | return false; | ||
269 | |||
270 | // Try local first | ||
271 | if (m_localBackend.CloseAgent(destination, id)) | ||
272 | return true; | ||
273 | |||
274 | // else do the remote thing | ||
275 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
276 | return m_remoteConnector.CloseAgent(destination, id); | ||
277 | |||
278 | return false; | ||
279 | } | ||
280 | |||
281 | /** | ||
282 | * Object-related communications | ||
283 | */ | ||
284 | |||
285 | public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) | ||
286 | { | ||
287 | if (destination == null) | ||
288 | return false; | ||
289 | |||
290 | // Try local first | ||
291 | if (m_localBackend.CreateObject(destination, sog, true)) | ||
292 | { | ||
293 | //m_log.Debug("[REST COMMS]: LocalBackEnd SendCreateObject succeeded"); | ||
294 | return true; | ||
295 | } | ||
296 | |||
297 | // else do the remote thing | ||
298 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
299 | return m_remoteConnector.CreateObject(destination, sog, isLocalCall); | ||
300 | |||
301 | return false; | ||
302 | } | ||
303 | |||
304 | public bool CreateObject(GridRegion destination, UUID userID, UUID itemID) | ||
305 | { | ||
306 | // Not Implemented | ||
307 | return false; | ||
308 | } | ||
309 | |||
310 | #endregion /* IInterregionComms */ | ||
311 | |||
312 | |||
313 | protected class RegionToRegionClient : RegionClient | ||
314 | { | ||
315 | Scene m_aScene = null; | ||
316 | IHyperlinkService m_hyperlinkService; | ||
317 | |||
318 | public RegionToRegionClient(Scene s, IHyperlinkService hyperService) | ||
319 | { | ||
320 | m_aScene = s; | ||
321 | m_hyperlinkService = hyperService; | ||
322 | } | ||
323 | |||
324 | public override ulong GetRegionHandle(ulong handle) | ||
325 | { | ||
326 | if (m_aScene.SceneGridService is HGSceneCommunicationService) | ||
327 | { | ||
328 | if (m_hyperlinkService != null) | ||
329 | return m_hyperlinkService.FindRegionHandle(handle); | ||
330 | } | ||
331 | |||
332 | return handle; | ||
333 | } | ||
334 | |||
335 | public override bool IsHyperlink(ulong handle) | ||
336 | { | ||
337 | if (m_aScene.SceneGridService is HGSceneCommunicationService) | ||
338 | { | ||
339 | if ((m_hyperlinkService != null) && (m_hyperlinkService.GetHyperlinkRegion(handle) != null)) | ||
340 | return true; | ||
341 | } | ||
342 | return false; | ||
343 | } | ||
344 | |||
345 | public override void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit) | ||
346 | { | ||
347 | if (m_hyperlinkService != null) | ||
348 | m_hyperlinkService.SendUserInformation(regInfo, aCircuit); | ||
349 | |||
350 | } | ||
351 | |||
352 | public override void AdjustUserInformation(AgentCircuitData aCircuit) | ||
353 | { | ||
354 | if (m_hyperlinkService != null) | ||
355 | m_hyperlinkService.AdjustUserInformation(aCircuit); | ||
356 | } | ||
357 | } | ||
358 | |||
359 | } | ||
360 | } | ||