diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/ServiceConnectors/Interregion/LocalInterregionComms.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectors/Interregion/LocalInterregionComms.cs | 286 |
1 files changed, 0 insertions, 286 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectors/Interregion/LocalInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectors/Interregion/LocalInterregionComms.cs deleted file mode 100644 index d2af2db..0000000 --- a/OpenSim/Region/CoreModules/ServiceConnectors/Interregion/LocalInterregionComms.cs +++ /dev/null | |||
@@ -1,286 +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.ServiceConnectors.Interregion | ||
38 | { | ||
39 | public class LocalInterregionComms : IRegionModule, 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(Scene scene, 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 | if (!m_enabled) | ||
67 | return; | ||
68 | |||
69 | Init(scene); | ||
70 | } | ||
71 | |||
72 | public void PostInitialise() | ||
73 | { | ||
74 | } | ||
75 | |||
76 | public void Close() | ||
77 | { | ||
78 | } | ||
79 | |||
80 | public string Name | ||
81 | { | ||
82 | get { return "LocalInterregionCommsModule"; } | ||
83 | } | ||
84 | |||
85 | public bool IsSharedModule | ||
86 | { | ||
87 | get { return true; } | ||
88 | } | ||
89 | /// <summary> | ||
90 | /// Can be called from other modules. | ||
91 | /// </summary> | ||
92 | /// <param name="scene"></param> | ||
93 | public void Init(Scene scene) | ||
94 | { | ||
95 | if (!m_sceneList.Contains(scene)) | ||
96 | { | ||
97 | lock (m_sceneList) | ||
98 | { | ||
99 | m_sceneList.Add(scene); | ||
100 | if (m_enabled) | ||
101 | scene.RegisterModuleInterface<IInterregionCommsOut>(this); | ||
102 | scene.RegisterModuleInterface<IInterregionCommsIn>(this); | ||
103 | } | ||
104 | |||
105 | } | ||
106 | } | ||
107 | |||
108 | #endregion /* IRegionModule */ | ||
109 | |||
110 | #region IInterregionComms | ||
111 | |||
112 | /** | ||
113 | * Agent-related communications | ||
114 | */ | ||
115 | |||
116 | public bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit, out string reason) | ||
117 | { | ||
118 | foreach (Scene s in m_sceneList) | ||
119 | { | ||
120 | if (s.RegionInfo.RegionHandle == regionHandle) | ||
121 | { | ||
122 | // m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", regionHandle); | ||
123 | return s.NewUserConnection(aCircuit, out reason); | ||
124 | } | ||
125 | } | ||
126 | |||
127 | // m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", regionHandle); | ||
128 | reason = "Did not find region."; | ||
129 | return false; | ||
130 | } | ||
131 | |||
132 | public bool SendChildAgentUpdate(ulong regionHandle, AgentData cAgentData) | ||
133 | { | ||
134 | foreach (Scene s in m_sceneList) | ||
135 | { | ||
136 | if (s.RegionInfo.RegionHandle == regionHandle) | ||
137 | { | ||
138 | //m_log.DebugFormat( | ||
139 | // "[LOCAL COMMS]: Found region {0} {1} to send ChildAgentUpdate", | ||
140 | // s.RegionInfo.RegionName, regionHandle); | ||
141 | |||
142 | s.IncomingChildAgentDataUpdate(cAgentData); | ||
143 | return true; | ||
144 | } | ||
145 | } | ||
146 | |||
147 | // m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for ChildAgentUpdate", regionHandle); | ||
148 | return false; | ||
149 | } | ||
150 | |||
151 | public bool SendChildAgentUpdate(ulong regionHandle, AgentPosition cAgentData) | ||
152 | { | ||
153 | foreach (Scene s in m_sceneList) | ||
154 | { | ||
155 | if (s.RegionInfo.RegionHandle == regionHandle) | ||
156 | { | ||
157 | //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); | ||
158 | s.IncomingChildAgentDataUpdate(cAgentData); | ||
159 | return true; | ||
160 | } | ||
161 | } | ||
162 | //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); | ||
163 | return false; | ||
164 | } | ||
165 | |||
166 | public bool SendRetrieveRootAgent(ulong regionHandle, UUID id, out IAgentData agent) | ||
167 | { | ||
168 | agent = null; | ||
169 | foreach (Scene s in m_sceneList) | ||
170 | { | ||
171 | if (s.RegionInfo.RegionHandle == regionHandle) | ||
172 | { | ||
173 | //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); | ||
174 | return s.IncomingRetrieveRootAgent(id, out agent); | ||
175 | } | ||
176 | } | ||
177 | //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); | ||
178 | return false; | ||
179 | } | ||
180 | |||
181 | public bool SendReleaseAgent(ulong regionHandle, UUID id, string uri) | ||
182 | { | ||
183 | //uint x, y; | ||
184 | //Utils.LongToUInts(regionHandle, out x, out y); | ||
185 | //x = x / Constants.RegionSize; | ||
186 | //y = y / Constants.RegionSize; | ||
187 | //m_log.Debug("\n >>> Local SendReleaseAgent " + x + "-" + y); | ||
188 | foreach (Scene s in m_sceneList) | ||
189 | { | ||
190 | if (s.RegionInfo.RegionHandle == regionHandle) | ||
191 | { | ||
192 | //m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent"); | ||
193 | return s.IncomingReleaseAgent(id); | ||
194 | } | ||
195 | } | ||
196 | //m_log.Debug("[LOCAL COMMS]: region not found in SendReleaseAgent"); | ||
197 | return false; | ||
198 | } | ||
199 | |||
200 | public bool SendCloseAgent(ulong regionHandle, UUID id) | ||
201 | { | ||
202 | //uint x, y; | ||
203 | //Utils.LongToUInts(regionHandle, out x, out y); | ||
204 | //x = x / Constants.RegionSize; | ||
205 | //y = y / Constants.RegionSize; | ||
206 | //m_log.Debug("\n >>> Local SendCloseAgent " + x + "-" + y); | ||
207 | foreach (Scene s in m_sceneList) | ||
208 | { | ||
209 | if (s.RegionInfo.RegionHandle == regionHandle) | ||
210 | { | ||
211 | //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent"); | ||
212 | return s.IncomingCloseAgent(id); | ||
213 | } | ||
214 | } | ||
215 | //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent"); | ||
216 | return false; | ||
217 | } | ||
218 | |||
219 | /** | ||
220 | * Object-related communications | ||
221 | */ | ||
222 | |||
223 | public bool SendCreateObject(ulong regionHandle, SceneObjectGroup sog, bool isLocalCall) | ||
224 | { | ||
225 | foreach (Scene s in m_sceneList) | ||
226 | { | ||
227 | if (s.RegionInfo.RegionHandle == regionHandle) | ||
228 | { | ||
229 | //m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject"); | ||
230 | if (isLocalCall) | ||
231 | { | ||
232 | // We need to make a local copy of the object | ||
233 | ISceneObject sogClone = sog.CloneForNewScene(); | ||
234 | sogClone.SetState(sog.GetStateSnapshot(), | ||
235 | s.RegionInfo.RegionID); | ||
236 | return s.IncomingCreateObject(sogClone); | ||
237 | } | ||
238 | else | ||
239 | { | ||
240 | // Use the object as it came through the wire | ||
241 | return s.IncomingCreateObject(sog); | ||
242 | } | ||
243 | } | ||
244 | } | ||
245 | return false; | ||
246 | } | ||
247 | |||
248 | public bool SendCreateObject(ulong regionHandle, UUID userID, UUID itemID) | ||
249 | { | ||
250 | foreach (Scene s in m_sceneList) | ||
251 | { | ||
252 | if (s.RegionInfo.RegionHandle == regionHandle) | ||
253 | { | ||
254 | return s.IncomingCreateObject(userID, itemID); | ||
255 | } | ||
256 | } | ||
257 | return false; | ||
258 | } | ||
259 | |||
260 | |||
261 | #endregion /* IInterregionComms */ | ||
262 | |||
263 | #region Misc | ||
264 | |||
265 | public UUID GetRegionID(ulong regionhandle) | ||
266 | { | ||
267 | foreach (Scene s in m_sceneList) | ||
268 | { | ||
269 | if (s.RegionInfo.RegionHandle == regionhandle) | ||
270 | return s.RegionInfo.RegionID; | ||
271 | } | ||
272 | // ? weird. should not happen | ||
273 | return m_sceneList[0].RegionInfo.RegionID; | ||
274 | } | ||
275 | |||
276 | public bool IsLocalRegion(ulong regionhandle) | ||
277 | { | ||
278 | foreach (Scene s in m_sceneList) | ||
279 | if (s.RegionInfo.RegionHandle == regionhandle) | ||
280 | return true; | ||
281 | return false; | ||
282 | } | ||
283 | |||
284 | #endregion | ||
285 | } | ||
286 | } | ||