diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs new file mode 100644 index 0000000..ea205a2 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs | |||
@@ -0,0 +1,52 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Reflection; | ||
4 | |||
5 | using OpenSim.Region.Framework.Scenes; | ||
6 | using OpenSim.Services.Interfaces; | ||
7 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
8 | |||
9 | using log4net; | ||
10 | |||
11 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | ||
12 | { | ||
13 | public class RegionCache | ||
14 | { | ||
15 | private static readonly ILog m_log = | ||
16 | LogManager.GetLogger( | ||
17 | MethodBase.GetCurrentMethod().DeclaringType); | ||
18 | |||
19 | private Scene m_scene; | ||
20 | private Dictionary<ulong, GridRegion> m_neighbours = new Dictionary<ulong, GridRegion>(); | ||
21 | |||
22 | public string RegionName | ||
23 | { | ||
24 | get { return m_scene.RegionInfo.RegionName; } | ||
25 | } | ||
26 | |||
27 | public RegionCache(Scene s) | ||
28 | { | ||
29 | m_scene = s; | ||
30 | m_scene.EventManager.OnRegionUp += OnRegionUp; | ||
31 | } | ||
32 | |||
33 | private void OnRegionUp(GridRegion otherRegion) | ||
34 | { | ||
35 | m_log.DebugFormat("[REGION CACHE]: (on region {0}) Region {1} is up @ {2}-{3}", | ||
36 | m_scene.RegionInfo.RegionName, otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY); | ||
37 | |||
38 | m_neighbours[otherRegion.RegionHandle] = otherRegion; | ||
39 | } | ||
40 | |||
41 | public void Clear() | ||
42 | { | ||
43 | m_scene.EventManager.OnRegionUp -= OnRegionUp; | ||
44 | m_neighbours.Clear(); | ||
45 | } | ||
46 | |||
47 | public List<GridRegion> GetNeighbours() | ||
48 | { | ||
49 | return new List<GridRegion>(m_neighbours.Values); | ||
50 | } | ||
51 | } | ||
52 | } | ||