aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Communications/Local/LocalBackEndServices.cs
diff options
context:
space:
mode:
authorDiva Canto2009-09-26 21:29:54 -0700
committerDiva Canto2009-09-26 21:29:54 -0700
commit68e40a87cafcab580ab484956f187068c098e84e (patch)
tree8896a15fa3c170f5163d4272f28674e44996aa02 /OpenSim/Region/Communications/Local/LocalBackEndServices.cs
parentPoof! on OGS1 GridServices. (diff)
downloadopensim-SC_OLD-68e40a87cafcab580ab484956f187068c098e84e.zip
opensim-SC_OLD-68e40a87cafcab580ab484956f187068c098e84e.tar.gz
opensim-SC_OLD-68e40a87cafcab580ab484956f187068c098e84e.tar.bz2
opensim-SC_OLD-68e40a87cafcab580ab484956f187068c098e84e.tar.xz
Poof! on LocalBackend. CommsManager.GridServices deleted.
Diffstat (limited to 'OpenSim/Region/Communications/Local/LocalBackEndServices.cs')
-rw-r--r--OpenSim/Region/Communications/Local/LocalBackEndServices.cs410
1 files changed, 0 insertions, 410 deletions
diff --git a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs
deleted file mode 100644
index 0ab9374..0000000
--- a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs
+++ /dev/null
@@ -1,410 +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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using log4net;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36
37namespace OpenSim.Region.Communications.Local
38{
39 public class LocalBackEndServices : IGridServices
40 {
41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42
43 protected Dictionary<ulong, RegionInfo> m_regions = new Dictionary<ulong, RegionInfo>();
44
45 protected Dictionary<ulong, RegionCommsListener> m_regionListeners =
46 new Dictionary<ulong, RegionCommsListener>();
47
48 // private Dictionary<ulong, RegionInfo> m_remoteRegionInfoCache = new Dictionary<ulong, RegionInfo>();
49
50 private Dictionary<string, string> m_queuedGridSettings = new Dictionary<string, string>();
51
52 public string _gdebugRegionName = String.Empty;
53
54 public bool RegionLoginsEnabled
55 {
56 get { return m_regionLoginsEnabled; }
57 set { m_regionLoginsEnabled = value; }
58 }
59 private bool m_regionLoginsEnabled;
60
61 public bool CheckRegion(string address, uint port)
62 {
63 return true;
64 }
65
66 public string gdebugRegionName
67 {
68 get { return _gdebugRegionName; }
69 set { _gdebugRegionName = value; }
70 }
71
72 public string _rdebugRegionName = String.Empty;
73
74 public string rdebugRegionName
75 {
76 get { return _rdebugRegionName; }
77 set { _rdebugRegionName = value; }
78 }
79
80 /// <summary>
81 /// Register a region method with the BackEnd Services.
82 /// </summary>
83 /// <param name="regionInfo"></param>
84 /// <returns></returns>
85 public RegionCommsListener RegisterRegion(RegionInfo regionInfo)
86 {
87 //m_log.Debug("CommsManager - Region " + regionInfo.RegionHandle + " , " + regionInfo.RegionLocX + " , "+ regionInfo.RegionLocY +" is registering");
88 if (!m_regions.ContainsKey(regionInfo.RegionHandle))
89 {
90 //m_log.Debug("CommsManager - Adding Region " + regionInfo.RegionHandle);
91 m_regions.Add(regionInfo.RegionHandle, regionInfo);
92
93 RegionCommsListener regionHost = new RegionCommsListener();
94 if (m_regionListeners.ContainsKey(regionInfo.RegionHandle))
95 {
96 m_log.Error("[INTERREGION STANDALONE]: " +
97 "Error:Region registered twice as an Events listener for Interregion Communications but not as a listed region. " +
98 "In Standalone mode this will cause BIG issues. In grid mode, it means a region went down and came back up.");
99 m_regionListeners.Remove(regionInfo.RegionHandle);
100 }
101 m_regionListeners.Add(regionInfo.RegionHandle, regionHost);
102
103 return regionHost;
104 }
105 else
106 {
107 // Already in our list, so the region went dead and restarted.
108 // don't replace the old regioninfo.. this might be a locking issue.. however we need to
109 // remove it and let it add normally below or we get extremely strange and intermittant
110 // connectivity errors.
111 // Don't change this line below to 'm_regions[regionInfo.RegionHandle] = regionInfo' unless you
112 // *REALLY* know what you are doing here.
113 m_regions[regionInfo.RegionHandle] = regionInfo;
114
115 m_log.Warn("[INTERREGION STANDALONE]: Region registered twice. Region went down and came back up.");
116
117 RegionCommsListener regionHost = new RegionCommsListener();
118 if (m_regionListeners.ContainsKey(regionInfo.RegionHandle))
119 {
120 m_regionListeners.Remove(regionInfo.RegionHandle);
121 }
122 m_regionListeners.Add(regionInfo.RegionHandle, regionHost);
123
124 return regionHost;
125 }
126 }
127
128 public bool DeregisterRegion(RegionInfo regionInfo)
129 {
130 if (m_regions.ContainsKey(regionInfo.RegionHandle))
131 {
132 m_regions.Remove(regionInfo.RegionHandle);
133 if (m_regionListeners.ContainsKey(regionInfo.RegionHandle))
134 {
135 m_regionListeners.Remove(regionInfo.RegionHandle);
136 }
137 return true;
138 }
139 return false;
140 }
141
142 /// <summary>
143 /// </summary>
144 /// <param name="regionInfo"></param>
145 /// <returns></returns>
146 public List<SimpleRegionInfo> RequestNeighbours(uint x, uint y)
147 {
148 // m_log.Debug("Finding Neighbours to " + regionInfo.RegionHandle);
149 List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>();
150
151 foreach (RegionInfo reg in m_regions.Values)
152 {
153 // m_log.Debug("CommsManager- RequestNeighbours() checking region " + reg.RegionLocX + " , "+ reg.RegionLocY);
154 if (reg.RegionLocX != x || reg.RegionLocY != y)
155 {
156 //m_log.Debug("CommsManager- RequestNeighbours() - found a different region in list, checking location");
157 if ((reg.RegionLocX > (x - 2)) && (reg.RegionLocX < (x + 2)))
158 {
159 if ((reg.RegionLocY > (y - 2)) && (reg.RegionLocY < (y + 2)))
160 {
161 neighbours.Add(reg);
162 }
163 }
164 }
165 }
166 return neighbours;
167 }
168
169 /// <summary>
170 /// Get information about a neighbouring region
171 /// </summary>
172 /// <param name="regionHandle"></param>
173 /// <returns></returns>
174 public RegionInfo RequestNeighbourInfo(ulong regionHandle)
175 {
176 if (m_regions.ContainsKey(regionHandle))
177 {
178 return m_regions[regionHandle];
179 }
180
181 return null;
182 }
183
184 /// <summary>
185 /// Get information about a neighbouring region
186 /// </summary>
187 /// <param name="regionHandle"></param>
188 /// <returns></returns>
189 public RegionInfo RequestNeighbourInfo(UUID regionID)
190 {
191 // TODO add a dictionary for faster lookup
192 foreach (RegionInfo info in m_regions.Values)
193 {
194 if (info.RegionID == regionID)
195 return info;
196 }
197
198 return null;
199 }
200
201 /// <summary>
202 /// Get information about a neighbouring region
203 /// </summary>
204 /// <param name="regionHandle"></param>
205 /// <returns></returns>
206 public RegionInfo RequestNeighbourInfo(string name)
207 {
208 foreach (RegionInfo info in m_regions.Values)
209 {
210 if (info.RegionName == name)
211 return info;
212 }
213
214 return null;
215 }
216
217 /// <summary>
218 /// Get information about a neighbouring region
219 /// </summary>
220 /// <param name="regionHandle"></param>
221 /// <returns></returns>
222 public RegionInfo RequestNeighbourInfo(string host, uint port)
223 {
224 foreach (RegionInfo info in m_regions.Values)
225 {
226 if ((info.ExternalHostName == host) && (info.HttpPort == port))
227 return info;
228 }
229
230 return null;
231 }
232
233 /// <summary>
234 /// Get information about the closet region given a region name.
235 /// </summary>
236 /// <param name="regionName"></param>
237 /// <returns></returns>
238 public RegionInfo RequestClosestRegion(string regionName)
239 {
240 foreach (RegionInfo regInfo in m_regions.Values)
241 {
242 if (regInfo.RegionName == regionName)
243 return regInfo;
244 }
245 return null;
246 }
247
248 /// <summary>
249 ///
250 /// </summary>
251 /// <param name="minX"></param>
252 /// <param name="minY"></param>
253 /// <param name="maxX"></param>
254 /// <param name="maxY"></param>
255 /// <returns></returns>
256 public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
257 {
258 List<MapBlockData> mapBlocks = new List<MapBlockData>();
259 foreach (RegionInfo regInfo in m_regions.Values)
260 {
261 if (((regInfo.RegionLocX >= minX) && (regInfo.RegionLocX <= maxX)) &&
262 ((regInfo.RegionLocY >= minY) && (regInfo.RegionLocY <= maxY)))
263 {
264 MapBlockData map = new MapBlockData();
265 map.Name = regInfo.RegionName;
266 map.X = (ushort) regInfo.RegionLocX;
267 map.Y = (ushort) regInfo.RegionLocY;
268 map.WaterHeight = (byte) regInfo.RegionSettings.WaterHeight;
269 map.MapImageId = regInfo.RegionSettings.TerrainImageID;
270 map.Agents = 1;
271 map.RegionFlags = 72458694;
272 map.Access = regInfo.AccessLevel;
273 mapBlocks.Add(map);
274 }
275 }
276 return mapBlocks;
277 }
278
279 // This function is only here to keep this class in line with the Grid Interface.
280 // It never gets called.
281 public virtual Dictionary<string, string> GetGridSettings()
282 {
283 Dictionary<string, string> returnGridSettings = new Dictionary<string, string>();
284 lock (m_queuedGridSettings)
285 {
286 returnGridSettings = m_queuedGridSettings;
287 m_queuedGridSettings.Clear();
288 }
289
290 return returnGridSettings;
291 }
292
293 public virtual void SetForcefulBanlistsDisallowed()
294 {
295 m_queuedGridSettings.Add("allow_forceful_banlines", "FALSE");
296 }
297
298
299 /// <summary>
300 /// Is a Sandbox mode method, used by the local Login server to inform a region of a connection user/session
301 /// </summary>
302 /// <param name="regionHandle"></param>
303 /// <param name="loginData"></param>
304 /// <returns></returns>
305 public void AddNewSession(ulong regionHandle, Login loginData)
306 {
307 AgentCircuitData agent = new AgentCircuitData();
308 agent.AgentID = loginData.Agent;
309 agent.firstname = loginData.First;
310 agent.lastname = loginData.Last;
311 agent.SessionID = loginData.Session;
312 agent.SecureSessionID = loginData.SecureSession;
313 agent.circuitcode = loginData.CircuitCode;
314 agent.BaseFolder = loginData.BaseFolder;
315 agent.InventoryFolder = loginData.InventoryFolder;
316 agent.startpos = loginData.StartPos;
317 agent.CapsPath = loginData.CapsPath;
318 if (loginData.Appearance != null)
319 agent.Appearance = loginData.Appearance;
320 else
321 {
322 m_log.WarnFormat("[INTER]: Appearance not found for {0} {1}. Creating default.", agent.firstname, agent.lastname);
323 agent.Appearance = new AvatarAppearance(agent.AgentID);
324 }
325
326 TriggerExpectUser(regionHandle, agent);
327 }
328
329 public void TriggerExpectUser(ulong regionHandle, AgentCircuitData agent)
330 {
331 //m_log.Info("[INTER]: " + rdebugRegionName + ":Local BackEnd: Other region is sending child agent our way: " + agent.firstname + " " + agent.lastname);
332
333 if (m_regionListeners.ContainsKey(regionHandle))
334 {
335 //m_log.Info("[INTER]: " + rdebugRegionName + ":Local BackEnd: FoundLocalRegion To send it to: " + agent.firstname + " " + agent.lastname);
336
337 m_regionListeners[regionHandle].TriggerExpectUser(agent);
338 }
339 }
340
341 public void TriggerLogOffUser(ulong regionHandle, UUID agentID, UUID RegionSecret, string message)
342 {
343 if (m_regionListeners.ContainsKey(regionHandle))
344 {
345 //m_log.Info("[INTER]: " + rdebugRegionName + ":Local BackEnd: FoundLocalRegion To send it to: " + agent.firstname + " " + agent.lastname);
346
347 m_regionListeners[regionHandle].TriggerLogOffUser(agentID, RegionSecret, message);
348 }
349 }
350
351 public void PingCheckReply(Hashtable respData)
352 {
353 foreach (ulong region in m_regions.Keys)
354 {
355 Hashtable regData = new Hashtable();
356 RegionInfo reg = m_regions[region];
357 regData["status"] = "active";
358 regData["handle"] = region.ToString();
359
360 respData[reg.RegionID.ToString()] = regData;
361 }
362 }
363
364
365 public LandData RequestLandData (ulong regionHandle, uint x, uint y)
366 {
367 m_log.DebugFormat("[INTERREGION STANDALONE] requests land data in {0}, at {1}, {2}",
368 regionHandle, x, y);
369
370 if (m_regionListeners.ContainsKey(regionHandle))
371 {
372 LandData land = m_regionListeners[regionHandle].TriggerGetLandData(x, y);
373 return land;
374 }
375
376 m_log.Debug("[INTERREGION STANDALONE] didn't find land data locally.");
377 return null;
378 }
379
380 public List<RegionInfo> RequestNamedRegions (string name, int maxNumber)
381 {
382 List<RegionInfo> lowercase_regions = new List<RegionInfo>();
383 List<RegionInfo> regions = new List<RegionInfo>();
384 foreach (RegionInfo info in m_regions.Values)
385 {
386 // Prioritizes exact match
387 if (info.RegionName.StartsWith(name))
388 {
389 regions.Add(info);
390 if (regions.Count >= maxNumber) break;
391 }
392 // But still saves lower case matches
393 else if (info.RegionName.ToLower().StartsWith(name))
394 {
395 if (lowercase_regions.Count < maxNumber)
396 {
397 lowercase_regions.Add(info);
398 }
399 }
400 }
401
402 // If no exact matches found, return lowercase matches (libOMV compatiblity)
403 if (regions.Count == 0 && lowercase_regions.Count != 0)
404 {
405 return lowercase_regions;
406 }
407 return regions;
408 }
409 }
410}