diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs | 319 |
1 files changed, 0 insertions, 319 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs deleted file mode 100644 index d68c683..0000000 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs +++ /dev/null | |||
@@ -1,319 +0,0 @@ | |||
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 | |||
37 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | ||
38 | { | ||
39 | public class LocalInterregionComms : ISharedRegionModule, IInterregionCommsOut, IInterregionCommsIn | ||
40 | { | ||
41 | private bool m_enabled = false; | ||
42 | |||
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
44 | private List<Scene> m_sceneList = new List<Scene>(); | ||
45 | |||
46 | #region Events | ||
47 | public event ChildAgentUpdateReceived OnChildAgentUpdate; | ||
48 | |||
49 | #endregion /* Events */ | ||
50 | |||
51 | #region IRegionModule | ||
52 | |||
53 | public void Initialise(IConfigSource config) | ||
54 | { | ||
55 | if (m_sceneList.Count == 0) | ||
56 | { | ||
57 | IConfig startupConfig = config.Configs["Communications"]; | ||
58 | |||
59 | if ((startupConfig != null) && (startupConfig.GetString("InterregionComms", "RESTComms") == "LocalComms")) | ||
60 | { | ||
61 | m_log.Debug("[LOCAL COMMS]: Enabling InterregionComms LocalComms module"); | ||
62 | m_enabled = true; | ||
63 | } | ||
64 | } | ||
65 | } | ||
66 | |||
67 | public void PostInitialise() | ||
68 | { | ||
69 | } | ||
70 | |||
71 | public void AddRegion(Scene scene) | ||
72 | { | ||
73 | } | ||
74 | |||
75 | public void RemoveRegion(Scene scene) | ||
76 | { | ||
77 | if (m_enabled) | ||
78 | { | ||
79 | RemoveScene(scene); | ||
80 | } | ||
81 | } | ||
82 | |||
83 | public void RegionLoaded(Scene scene) | ||
84 | { | ||
85 | if (m_enabled) | ||
86 | { | ||
87 | Init(scene); | ||
88 | } | ||
89 | } | ||
90 | |||
91 | public void Close() | ||
92 | { | ||
93 | } | ||
94 | |||
95 | public Type ReplaceableInterface | ||
96 | { | ||
97 | get { return null; } | ||
98 | } | ||
99 | |||
100 | public string Name | ||
101 | { | ||
102 | get { return "LocalInterregionCommsModule"; } | ||
103 | } | ||
104 | |||
105 | /// <summary> | ||
106 | /// Can be called from other modules. | ||
107 | /// </summary> | ||
108 | /// <param name="scene"></param> | ||
109 | public void RemoveScene(Scene scene) | ||
110 | { | ||
111 | lock (m_sceneList) | ||
112 | { | ||
113 | if (m_sceneList.Contains(scene)) | ||
114 | { | ||
115 | m_sceneList.Remove(scene); | ||
116 | } | ||
117 | } | ||
118 | } | ||
119 | |||
120 | /// <summary> | ||
121 | /// Can be called from other modules. | ||
122 | /// </summary> | ||
123 | /// <param name="scene"></param> | ||
124 | public void Init(Scene scene) | ||
125 | { | ||
126 | if (!m_sceneList.Contains(scene)) | ||
127 | { | ||
128 | lock (m_sceneList) | ||
129 | { | ||
130 | m_sceneList.Add(scene); | ||
131 | if (m_enabled) | ||
132 | scene.RegisterModuleInterface<IInterregionCommsOut>(this); | ||
133 | scene.RegisterModuleInterface<IInterregionCommsIn>(this); | ||
134 | } | ||
135 | |||
136 | } | ||
137 | } | ||
138 | |||
139 | #endregion /* IRegionModule */ | ||
140 | |||
141 | #region IInterregionComms | ||
142 | |||
143 | /** | ||
144 | * Agent-related communications | ||
145 | */ | ||
146 | |||
147 | public bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit, uint teleportFlags, out string reason) | ||
148 | { | ||
149 | |||
150 | foreach (Scene s in m_sceneList) | ||
151 | { | ||
152 | if (s.RegionInfo.RegionHandle == regionHandle) | ||
153 | { | ||
154 | // m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", regionHandle); | ||
155 | return s.NewUserConnection(aCircuit, teleportFlags, out reason); | ||
156 | } | ||
157 | } | ||
158 | |||
159 | // m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", regionHandle); | ||
160 | uint x = 0, y = 0; | ||
161 | Utils.LongToUInts(regionHandle, out x, out y); | ||
162 | reason = "Did not find region " + x + "-" + y; | ||
163 | return false; | ||
164 | } | ||
165 | |||
166 | public bool SendChildAgentUpdate(ulong regionHandle, AgentData cAgentData) | ||
167 | { | ||
168 | foreach (Scene s in m_sceneList) | ||
169 | { | ||
170 | if (s.RegionInfo.RegionHandle == regionHandle) | ||
171 | { | ||
172 | //m_log.DebugFormat( | ||
173 | // "[LOCAL COMMS]: Found region {0} {1} to send ChildAgentUpdate", | ||
174 | // s.RegionInfo.RegionName, regionHandle); | ||
175 | |||
176 | s.IncomingChildAgentDataUpdate(cAgentData); | ||
177 | return true; | ||
178 | } | ||
179 | } | ||
180 | |||
181 | // m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for ChildAgentUpdate", regionHandle); | ||
182 | return false; | ||
183 | } | ||
184 | |||
185 | public bool SendChildAgentUpdate(ulong regionHandle, AgentPosition cAgentData) | ||
186 | { | ||
187 | foreach (Scene s in m_sceneList) | ||
188 | { | ||
189 | if (s.RegionInfo.RegionHandle == regionHandle) | ||
190 | { | ||
191 | //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); | ||
192 | s.IncomingChildAgentDataUpdate(cAgentData); | ||
193 | return true; | ||
194 | } | ||
195 | } | ||
196 | //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); | ||
197 | return false; | ||
198 | } | ||
199 | |||
200 | public bool SendRetrieveRootAgent(ulong regionHandle, UUID id, out IAgentData agent) | ||
201 | { | ||
202 | agent = null; | ||
203 | foreach (Scene s in m_sceneList) | ||
204 | { | ||
205 | if (s.RegionInfo.RegionHandle == regionHandle) | ||
206 | { | ||
207 | //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); | ||
208 | return s.IncomingRetrieveRootAgent(id, out agent); | ||
209 | } | ||
210 | } | ||
211 | //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); | ||
212 | return false; | ||
213 | } | ||
214 | |||
215 | public bool SendReleaseAgent(ulong regionHandle, UUID id, string uri) | ||
216 | { | ||
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) | ||
223 | { | ||
224 | if (s.RegionInfo.RegionHandle == regionHandle) | ||
225 | { | ||
226 | //m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent"); | ||
227 | return s.IncomingReleaseAgent(id); | ||
228 | } | ||
229 | } | ||
230 | //m_log.Debug("[LOCAL COMMS]: region not found in SendReleaseAgent"); | ||
231 | return false; | ||
232 | } | ||
233 | |||
234 | public bool SendCloseAgent(ulong regionHandle, UUID id) | ||
235 | { | ||
236 | //uint x, y; | ||
237 | //Utils.LongToUInts(regionHandle, out x, out y); | ||
238 | //x = x / Constants.RegionSize; | ||
239 | //y = y / Constants.RegionSize; | ||
240 | //m_log.Debug("\n >>> Local SendCloseAgent " + x + "-" + y); | ||
241 | foreach (Scene s in m_sceneList) | ||
242 | { | ||
243 | if (s.RegionInfo.RegionHandle == regionHandle) | ||
244 | { | ||
245 | //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent"); | ||
246 | return s.IncomingCloseAgent(id); | ||
247 | } | ||
248 | } | ||
249 | //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent"); | ||
250 | return false; | ||
251 | } | ||
252 | |||
253 | /** | ||
254 | * Object-related communications | ||
255 | */ | ||
256 | |||
257 | public bool SendCreateObject(ulong regionHandle, SceneObjectGroup sog, bool isLocalCall) | ||
258 | { | ||
259 | foreach (Scene s in m_sceneList) | ||
260 | { | ||
261 | if (s.RegionInfo.RegionHandle == regionHandle) | ||
262 | { | ||
263 | //m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject"); | ||
264 | if (isLocalCall) | ||
265 | { | ||
266 | // We need to make a local copy of the object | ||
267 | ISceneObject sogClone = sog.CloneForNewScene(); | ||
268 | sogClone.SetState(sog.GetStateSnapshot(), s); | ||
269 | return s.IncomingCreateObject(sogClone); | ||
270 | } | ||
271 | else | ||
272 | { | ||
273 | // Use the object as it came through the wire | ||
274 | return s.IncomingCreateObject(sog); | ||
275 | } | ||
276 | } | ||
277 | } | ||
278 | return false; | ||
279 | } | ||
280 | |||
281 | public bool SendCreateObject(ulong regionHandle, UUID userID, UUID itemID) | ||
282 | { | ||
283 | foreach (Scene s in m_sceneList) | ||
284 | { | ||
285 | if (s.RegionInfo.RegionHandle == regionHandle) | ||
286 | { | ||
287 | return s.IncomingCreateObject(userID, itemID); | ||
288 | } | ||
289 | } | ||
290 | return false; | ||
291 | } | ||
292 | |||
293 | |||
294 | #endregion /* IInterregionComms */ | ||
295 | |||
296 | #region Misc | ||
297 | |||
298 | public Scene GetScene(ulong regionhandle) | ||
299 | { | ||
300 | foreach (Scene s in m_sceneList) | ||
301 | { | ||
302 | if (s.RegionInfo.RegionHandle == regionhandle) | ||
303 | return s; | ||
304 | } | ||
305 | // ? weird. should not happen | ||
306 | return m_sceneList[0]; | ||
307 | } | ||
308 | |||
309 | public bool IsLocalRegion(ulong regionhandle) | ||
310 | { | ||
311 | foreach (Scene s in m_sceneList) | ||
312 | if (s.RegionInfo.RegionHandle == regionhandle) | ||
313 | return true; | ||
314 | return false; | ||
315 | } | ||
316 | |||
317 | #endregion | ||
318 | } | ||
319 | } | ||