aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs')
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs183
1 files changed, 183 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
new file mode 100644
index 0000000..91a808b
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
@@ -0,0 +1,183 @@
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 log4net;
29using System;
30using System.Collections.Generic;
31using System.Reflection;
32using Nini.Config;
33using OpenMetaverse;
34
35using OpenSim.Framework;
36using OpenSim.Services.Connectors;
37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Services.Interfaces;
40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41
42namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
43{
44 public class RemoteGridServicesConnector :
45 GridServicesConnector, ISharedRegionModule, IGridService
46 {
47 private static readonly ILog m_log =
48 LogManager.GetLogger(
49 MethodBase.GetCurrentMethod().DeclaringType);
50
51 private bool m_Enabled = false;
52
53 private IGridService m_LocalGridService;
54
55 public RemoteGridServicesConnector()
56 {
57 }
58
59 public RemoteGridServicesConnector(IConfigSource source)
60 {
61 InitialiseServices(source);
62 }
63
64 #region ISharedRegionmodule
65
66 public Type ReplaceableInterface
67 {
68 get { return null; }
69 }
70
71 public string Name
72 {
73 get { return "RemoteGridServicesConnector"; }
74 }
75
76 public override void Initialise(IConfigSource source)
77 {
78 IConfig moduleConfig = source.Configs["Modules"];
79 if (moduleConfig != null)
80 {
81 string name = moduleConfig.GetString("GridServices", "");
82 if (name == Name)
83 {
84 InitialiseServices(source);
85 m_Enabled = true;
86 m_log.Info("[REMOTE GRID CONNECTOR]: Remote grid enabled");
87 }
88 }
89 }
90
91 private void InitialiseServices(IConfigSource source)
92 {
93 IConfig gridConfig = source.Configs["GridService"];
94 if (gridConfig == null)
95 {
96 m_log.Error("[REMOTE GRID CONNECTOR]: GridService missing from OpenSim.ini");
97 return;
98 }
99
100 base.Initialise(source);
101
102 m_LocalGridService = new LocalGridServicesConnector(source);
103 }
104
105 public void PostInitialise()
106 {
107 }
108
109 public void Close()
110 {
111 }
112
113 public void AddRegion(Scene scene)
114 {
115 if (!m_Enabled)
116 return;
117
118 scene.RegisterModuleInterface<IGridService>(this);
119 }
120
121 public void RemoveRegion(Scene scene)
122 {
123 }
124
125 public void RegionLoaded(Scene scene)
126 {
127 }
128
129 #endregion
130
131 #region IGridService
132
133 public override bool RegisterRegion(UUID scopeID, GridRegion regionInfo)
134 {
135 if (m_LocalGridService.RegisterRegion(scopeID, regionInfo))
136 return base.RegisterRegion(scopeID, regionInfo);
137
138 return false;
139 }
140
141 public override bool DeregisterRegion(UUID regionID)
142 {
143 if (m_LocalGridService.DeregisterRegion(regionID))
144 return base.DeregisterRegion(regionID);
145
146 return false;
147 }
148
149 // Let's not override GetNeighbours -- let's get them all from the grid server
150
151 public override GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
152 {
153 GridRegion rinfo = m_LocalGridService.GetRegionByUUID(scopeID, regionID);
154 if (rinfo == null)
155 rinfo = base.GetRegionByUUID(scopeID, regionID);
156
157 return rinfo;
158 }
159
160 public override GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
161 {
162 GridRegion rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y);
163 if (rinfo == null)
164 rinfo = base.GetRegionByPosition(scopeID, x, y);
165
166 return rinfo;
167 }
168
169 public override GridRegion GetRegionByName(UUID scopeID, string regionName)
170 {
171 GridRegion rinfo = m_LocalGridService.GetRegionByName(scopeID, regionName);
172 if (rinfo == null)
173 rinfo = base.GetRegionByName(scopeID, regionName);
174
175 return rinfo;
176 }
177
178 // Let's not override GetRegionsByName -- let's get them all from the grid server
179 // Let's not override GetRegionRange -- let's get them all from the grid server
180
181 #endregion
182 }
183}