aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml2
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs9
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs129
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs356
4 files changed, 447 insertions, 49 deletions
diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
index 8b831a5..7b9fdee 100644
--- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
+++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
@@ -56,6 +56,7 @@
56 <RegionModule id="LocalUserAccountServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts.LocalUserAccountServicesConnector" /> 56 <RegionModule id="LocalUserAccountServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts.LocalUserAccountServicesConnector" />
57 <RegionModule id="RemoteUserAccountServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts.RemoteUserAccountServicesConnector" /> 57 <RegionModule id="RemoteUserAccountServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts.RemoteUserAccountServicesConnector" />
58 <RegionModule id="LocalSimulationConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation.LocalSimulationConnectorModule" /> 58 <RegionModule id="LocalSimulationConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation.LocalSimulationConnectorModule" />
59 <RegionModule id="RemoteSimulationConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation.RemoteSimulationConnectorModule" />
59 <!-- Service connectors IN modules --> 60 <!-- Service connectors IN modules -->
60 <RegionModule id="AssetServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset.AssetServiceInConnectorModule" /> 61 <RegionModule id="AssetServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset.AssetServiceInConnectorModule" />
61 <RegionModule id="InventoryServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory.InventoryServiceInConnectorModule" /> 62 <RegionModule id="InventoryServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory.InventoryServiceInConnectorModule" />
@@ -63,6 +64,7 @@
63 <RegionModule id="NeighbourServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour.NeighbourServiceInConnectorModule" /> \ 64 <RegionModule id="NeighbourServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour.NeighbourServiceInConnectorModule" /> \
64 <RegionModule id="HypergridServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid.HypergridServiceInConnectorModule" /> \ 65 <RegionModule id="HypergridServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid.HypergridServiceInConnectorModule" /> \
65 <RegionModule id="LLLoginServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Login.LLLoginServiceInConnectorModule" /> \ 66 <RegionModule id="LLLoginServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Login.LLLoginServiceInConnectorModule" /> \
67 <RegionModule id="SimulationServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation.SimulationServiceInConnectorModule" /> \
66 68
67 </Extension> 69 </Extension>
68 70
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs
index f28a318..03a5124 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs
@@ -58,11 +58,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation
58 IConfig moduleConfig = config.Configs["Modules"]; 58 IConfig moduleConfig = config.Configs["Modules"];
59 if (moduleConfig != null) 59 if (moduleConfig != null)
60 { 60 {
61 string name = moduleConfig.GetString("SimulationService", ""); 61 m_Enabled = moduleConfig.GetBoolean("SimulationServiceInConnector", false);
62 if (name == Name) 62 if (m_Enabled)
63 { 63 {
64 m_Enabled = true; 64 m_log.Info("[SIM SERVICE]: SimulationService IN connector enabled");
65 m_log.Info("[SIM SERVICE]: SimulationService enabled");
66 65
67 } 66 }
68 } 67 }
@@ -84,7 +83,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation
84 83
85 public string Name 84 public string Name
86 { 85 {
87 get { return "SimulationService"; } 86 get { return "SimulationServiceInConnectorModule"; }
88 } 87 }
89 88
90 public void AddRegion(Scene scene) 89 public void AddRegion(Scene scene)
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
index 430cc6e..074bfb5 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
@@ -34,6 +34,7 @@ using OpenSim.Framework;
34using OpenSim.Region.Framework.Interfaces; 34using OpenSim.Region.Framework.Interfaces;
35using OpenSim.Region.Framework.Scenes; 35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Services.Interfaces; 36using OpenSim.Services.Interfaces;
37using GridRegion = OpenSim.Services.Interfaces.GridRegion;
37 38
38namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation 39namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
39{ 40{
@@ -42,13 +43,30 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 private List<Scene> m_sceneList = new List<Scene>(); 44 private List<Scene> m_sceneList = new List<Scene>();
44 45
46 private bool m_ModuleEnabled = false;
45 47
46 #region IRegionModule 48 #region IRegionModule
47 49
48 public void Initialise(IConfigSource config) 50 public void Initialise(IConfigSource config)
49 { 51 {
50 // This module is always on 52 IConfig moduleConfig = config.Configs["Modules"];
51 m_log.Debug("[LOCAL SIMULATION]: Enabling LocalSimulation module"); 53 if (moduleConfig != null)
54 {
55 string name = moduleConfig.GetString("SimulationServices", "");
56 if (name == Name)
57 {
58 //IConfig userConfig = config.Configs["SimulationService"];
59 //if (userConfig == null)
60 //{
61 // m_log.Error("[AVATAR CONNECTOR]: SimulationService missing from OpanSim.ini");
62 // return;
63 //}
64
65 m_ModuleEnabled = true;
66
67 m_log.Info("[SIMULATION CONNECTOR]: Local simulation enabled");
68 }
69 }
52 } 70 }
53 71
54 public void PostInitialise() 72 public void PostInitialise()
@@ -57,16 +75,24 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
57 75
58 public void AddRegion(Scene scene) 76 public void AddRegion(Scene scene)
59 { 77 {
78 if (!m_ModuleEnabled)
79 return;
80
81 Init(scene);
82 scene.RegisterModuleInterface<ISimulationService>(this);
60 } 83 }
61 84
62 public void RemoveRegion(Scene scene) 85 public void RemoveRegion(Scene scene)
63 { 86 {
87 if (!m_ModuleEnabled)
88 return;
89
64 RemoveScene(scene); 90 RemoveScene(scene);
91 scene.UnregisterModuleInterface<ISimulationService>(this);
65 } 92 }
66 93
67 public void RegionLoaded(Scene scene) 94 public void RegionLoaded(Scene scene)
68 { 95 {
69 Init(scene);
70 } 96 }
71 97
72 public void Close() 98 public void Close()
@@ -109,7 +135,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
109 lock (m_sceneList) 135 lock (m_sceneList)
110 { 136 {
111 m_sceneList.Add(scene); 137 m_sceneList.Add(scene);
112 scene.RegisterModuleInterface<ISimulationService>(this);
113 } 138 }
114 139
115 } 140 }
@@ -119,16 +144,33 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
119 144
120 #region ISimulation 145 #region ISimulation
121 146
147 public IScene GetScene(ulong regionhandle)
148 {
149 foreach (Scene s in m_sceneList)
150 {
151 if (s.RegionInfo.RegionHandle == regionhandle)
152 return s;
153 }
154 // ? weird. should not happen
155 return m_sceneList[0];
156 }
157
122 /** 158 /**
123 * Agent-related communications 159 * Agent-related communications
124 */ 160 */
125 161
126 public bool CreateAgent(ulong regionHandle, AgentCircuitData aCircuit, uint teleportFlags, out string reason) 162 public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason)
127 { 163 {
164 if (destination == null)
165 {
166 reason = "Given destination was null";
167 m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: CreateAgent was given a null destination");
168 return false;
169 }
128 170
129 foreach (Scene s in m_sceneList) 171 foreach (Scene s in m_sceneList)
130 { 172 {
131 if (s.RegionInfo.RegionHandle == regionHandle) 173 if (s.RegionInfo.RegionHandle == destination.RegionHandle)
132 { 174 {
133// m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", regionHandle); 175// m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", regionHandle);
134 return s.NewUserConnection(aCircuit, teleportFlags, out reason); 176 return s.NewUserConnection(aCircuit, teleportFlags, out reason);
@@ -136,17 +178,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
136 } 178 }
137 179
138// m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", regionHandle); 180// m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", regionHandle);
139 uint x = 0, y = 0; 181 reason = "Did not find region " + destination.RegionName;
140 Utils.LongToUInts(regionHandle, out x, out y);
141 reason = "Did not find region " + x + "-" + y;
142 return false; 182 return false;
143 } 183 }
144 184
145 public bool UpdateAgent(ulong regionHandle, AgentData cAgentData) 185 public bool UpdateAgent(GridRegion destination, AgentData cAgentData)
146 { 186 {
187 if (destination == null)
188 return false;
189
147 foreach (Scene s in m_sceneList) 190 foreach (Scene s in m_sceneList)
148 { 191 {
149 if (s.RegionInfo.RegionHandle == regionHandle) 192 if (s.RegionInfo.RegionHandle == destination.RegionHandle)
150 { 193 {
151 //m_log.DebugFormat( 194 //m_log.DebugFormat(
152 // "[LOCAL COMMS]: Found region {0} {1} to send ChildAgentUpdate", 195 // "[LOCAL COMMS]: Found region {0} {1} to send ChildAgentUpdate",
@@ -161,11 +204,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
161 return false; 204 return false;
162 } 205 }
163 206
164 public bool UpdateAgent(ulong regionHandle, AgentPosition cAgentData) 207 public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData)
165 { 208 {
209 if (destination == null)
210 return false;
211
166 foreach (Scene s in m_sceneList) 212 foreach (Scene s in m_sceneList)
167 { 213 {
168 if (s.RegionInfo.RegionHandle == regionHandle) 214 if (s.RegionInfo.RegionHandle == destination.RegionHandle)
169 { 215 {
170 //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); 216 //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate");
171 s.IncomingChildAgentDataUpdate(cAgentData); 217 s.IncomingChildAgentDataUpdate(cAgentData);
@@ -176,12 +222,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
176 return false; 222 return false;
177 } 223 }
178 224
179 public bool RetrieveAgent(ulong regionHandle, UUID id, out IAgentData agent) 225 public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent)
180 { 226 {
181 agent = null; 227 agent = null;
228
229 if (destination == null)
230 return false;
231
182 foreach (Scene s in m_sceneList) 232 foreach (Scene s in m_sceneList)
183 { 233 {
184 if (s.RegionInfo.RegionHandle == regionHandle) 234 if (s.RegionInfo.RegionHandle == destination.RegionHandle)
185 { 235 {
186 //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); 236 //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate");
187 return s.IncomingRetrieveRootAgent(id, out agent); 237 return s.IncomingRetrieveRootAgent(id, out agent);
@@ -191,16 +241,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
191 return false; 241 return false;
192 } 242 }
193 243
194 public bool ReleaseAgent(ulong regionHandle, UUID id, string uri) 244 public bool ReleaseAgent(GridRegion destination, UUID id, string uri)
195 { 245 {
196 //uint x, y; 246 if (destination == null)
197 //Utils.LongToUInts(regionHandle, out x, out y); 247 return false;
198 //x = x / Constants.RegionSize; 248
199 //y = y / Constants.RegionSize;
200 //m_log.Debug("\n >>> Local SendReleaseAgent " + x + "-" + y);
201 foreach (Scene s in m_sceneList) 249 foreach (Scene s in m_sceneList)
202 { 250 {
203 if (s.RegionInfo.RegionHandle == regionHandle) 251 if (s.RegionInfo.RegionHandle == destination.RegionHandle)
204 { 252 {
205 //m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent"); 253 //m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent");
206 return s.IncomingReleaseAgent(id); 254 return s.IncomingReleaseAgent(id);
@@ -210,16 +258,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
210 return false; 258 return false;
211 } 259 }
212 260
213 public bool CloseAgent(ulong regionHandle, UUID id) 261 public bool CloseAgent(GridRegion destination, UUID id)
214 { 262 {
215 //uint x, y; 263 if (destination == null)
216 //Utils.LongToUInts(regionHandle, out x, out y); 264 return false;
217 //x = x / Constants.RegionSize; 265
218 //y = y / Constants.RegionSize;
219 //m_log.Debug("\n >>> Local SendCloseAgent " + x + "-" + y);
220 foreach (Scene s in m_sceneList) 266 foreach (Scene s in m_sceneList)
221 { 267 {
222 if (s.RegionInfo.RegionHandle == regionHandle) 268 if (s.RegionInfo.RegionHandle == destination.RegionHandle)
223 { 269 {
224 //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent"); 270 //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent");
225 return s.IncomingCloseAgent(id); 271 return s.IncomingCloseAgent(id);
@@ -233,11 +279,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
233 * Object-related communications 279 * Object-related communications
234 */ 280 */
235 281
236 public bool CreateObject(ulong regionHandle, ISceneObject sog, bool isLocalCall) 282 public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall)
237 { 283 {
284 if (destination == null)
285 return false;
286
238 foreach (Scene s in m_sceneList) 287 foreach (Scene s in m_sceneList)
239 { 288 {
240 if (s.RegionInfo.RegionHandle == regionHandle) 289 if (s.RegionInfo.RegionHandle == destination.RegionHandle)
241 { 290 {
242 //m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject"); 291 //m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject");
243 if (isLocalCall) 292 if (isLocalCall)
@@ -257,11 +306,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
257 return false; 306 return false;
258 } 307 }
259 308
260 public bool CreateObject(ulong regionHandle, UUID userID, UUID itemID) 309 public bool CreateObject(GridRegion destination, UUID userID, UUID itemID)
261 { 310 {
311 if (destination == null)
312 return false;
313
262 foreach (Scene s in m_sceneList) 314 foreach (Scene s in m_sceneList)
263 { 315 {
264 if (s.RegionInfo.RegionHandle == regionHandle) 316 if (s.RegionInfo.RegionHandle == destination.RegionHandle)
265 { 317 {
266 return s.IncomingCreateObject(userID, itemID); 318 return s.IncomingCreateObject(userID, itemID);
267 } 319 }
@@ -274,17 +326,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
274 326
275 #region Misc 327 #region Misc
276 328
277 public IScene GetScene(ulong regionhandle)
278 {
279 foreach (Scene s in m_sceneList)
280 {
281 if (s.RegionInfo.RegionHandle == regionhandle)
282 return s;
283 }
284 // ? weird. should not happen
285 return m_sceneList[0];
286 }
287
288 public bool IsLocalRegion(ulong regionhandle) 329 public bool IsLocalRegion(ulong regionhandle)
289 { 330 {
290 foreach (Scene s in m_sceneList) 331 foreach (Scene s in m_sceneList)
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
new file mode 100644
index 0000000..b7dc283
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
@@ -0,0 +1,356 @@
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.IO;
31using System.Net;
32using System.Reflection;
33using System.Text;
34using log4net;
35using Nini.Config;
36using OpenMetaverse;
37using OpenMetaverse.StructuredData;
38using OpenSim.Framework;
39using OpenSim.Framework.Communications;
40using OpenSim.Framework.Communications.Clients;
41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Region.Framework.Scenes.Hypergrid;
44using OpenSim.Region.Framework.Scenes.Serialization;
45using OpenSim.Services.Interfaces;
46using OpenSim.Services.Connectors.Simulation;
47using GridRegion = OpenSim.Services.Interfaces.GridRegion;
48
49namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
50{
51 public class RemoteSimulationConnectorModule : ISharedRegionModule, ISimulationService
52 {
53 private bool initialized = false;
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55
56 protected bool m_enabled = false;
57 protected Scene m_aScene;
58 // RemoteSimulationConnector does not care about local regions; it delegates that to the Local module
59 protected LocalSimulationConnectorModule m_localBackend;
60 protected SimulationServiceConnector m_remoteConnector;
61
62 protected CommunicationsManager m_commsManager;
63
64 protected IHyperlinkService m_hyperlinkService;
65
66 protected bool m_safemode;
67 protected IPAddress m_thisIP;
68
69 #region IRegionModule
70
71 public virtual void Initialise(IConfigSource config)
72 {
73
74 IConfig moduleConfig = config.Configs["Modules"];
75 if (moduleConfig != null)
76 {
77 string name = moduleConfig.GetString("SimulationServices", "");
78 if (name == Name)
79 {
80 //IConfig userConfig = config.Configs["SimulationService"];
81 //if (userConfig == null)
82 //{
83 // m_log.Error("[AVATAR CONNECTOR]: SimulationService missing from OpanSim.ini");
84 // return;
85 //}
86
87 m_remoteConnector = new SimulationServiceConnector();
88
89 m_enabled = true;
90
91 m_log.Info("[SIMULATION CONNECTOR]: Remote simulation enabled");
92 }
93 }
94 }
95
96 public virtual void PostInitialise()
97 {
98 }
99
100 public virtual void Close()
101 {
102 }
103
104 public void AddRegion(Scene scene)
105 {
106 }
107
108 public void RemoveRegion(Scene scene)
109 {
110 if (m_enabled)
111 {
112 m_localBackend.RemoveScene(scene);
113 scene.UnregisterModuleInterface<ISimulationService>(this);
114 }
115 }
116
117 public void RegionLoaded(Scene scene)
118 {
119 if (m_enabled)
120 {
121 if (!initialized)
122 {
123 InitOnce(scene);
124 initialized = true;
125 }
126 InitEach(scene);
127 }
128 }
129
130 public Type ReplaceableInterface
131 {
132 get { return null; }
133 }
134
135 public virtual string Name
136 {
137 get { return "RemoteSimulationConnectorModule"; }
138 }
139
140 protected virtual void InitEach(Scene scene)
141 {
142 m_localBackend.Init(scene);
143 scene.RegisterModuleInterface<ISimulationService>(this);
144 }
145
146 protected virtual void InitOnce(Scene scene)
147 {
148 m_localBackend = new LocalSimulationConnectorModule();
149 m_commsManager = scene.CommsManager;
150 m_aScene = scene;
151 m_hyperlinkService = m_aScene.RequestModuleInterface<IHyperlinkService>();
152 //m_regionClient = new RegionToRegionClient(m_aScene, m_hyperlinkService);
153 m_thisIP = Util.GetHostFromDNS(scene.RegionInfo.ExternalHostName);
154 }
155
156 #endregion /* IRegionModule */
157
158 #region IInterregionComms
159
160 public IScene GetScene(ulong handle)
161 {
162 return m_localBackend.GetScene(handle);
163 }
164
165 /**
166 * Agent-related communications
167 */
168
169 public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason)
170 {
171 if (destination == null)
172 {
173 reason = "Given destination was null";
174 m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CreateAgent was given a null destination");
175 return false;
176 }
177
178 // Try local first
179 if (m_localBackend.CreateAgent(destination, aCircuit, teleportFlags, out reason))
180 return true;
181
182 // else do the remote thing
183 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
184 {
185 //m_regionClient.SendUserInformation(regInfo, aCircuit);
186 return m_remoteConnector.CreateAgent(destination, aCircuit, teleportFlags, out reason);
187 }
188 return false;
189 }
190
191 public bool UpdateAgent(GridRegion destination, AgentData cAgentData)
192 {
193 if (destination == null)
194 return false;
195
196 // Try local first
197 if (m_localBackend.UpdateAgent(destination, cAgentData))
198 return true;
199
200 // else do the remote thing
201 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
202 return m_remoteConnector.UpdateAgent(destination, cAgentData);
203
204 return false;
205
206 }
207
208 public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData)
209 {
210 if (destination == null)
211 return false;
212
213 // Try local first
214 if (m_localBackend.UpdateAgent(destination, cAgentData))
215 return true;
216
217 // else do the remote thing
218 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
219 return m_remoteConnector.UpdateAgent(destination, cAgentData);
220
221 return false;
222
223 }
224
225 public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent)
226 {
227 agent = null;
228
229 if (destination == null)
230 return false;
231
232 // Try local first
233 if (m_localBackend.RetrieveAgent(destination, id, out agent))
234 return true;
235
236 // else do the remote thing
237 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
238 return m_remoteConnector.RetrieveAgent(destination, id, out agent);
239
240 return false;
241
242 }
243
244 public bool ReleaseAgent(GridRegion destination, UUID id, string uri)
245 {
246 if (destination == null)
247 return false;
248
249 // Try local first
250 if (m_localBackend.ReleaseAgent(destination, id, uri))
251 return true;
252
253 // else do the remote thing
254 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
255 return m_remoteConnector.ReleaseAgent(destination, id, uri);
256
257 return false;
258 }
259
260
261 public bool CloseAgent(GridRegion destination, UUID id)
262 {
263 if (destination == null)
264 return false;
265
266 // Try local first
267 if (m_localBackend.CloseAgent(destination, id))
268 return true;
269
270 // else do the remote thing
271 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
272 return m_remoteConnector.CloseAgent(destination, id);
273
274 return false;
275 }
276
277 /**
278 * Object-related communications
279 */
280
281 public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall)
282 {
283 if (destination == null)
284 return false;
285
286 // Try local first
287 if (m_localBackend.CreateObject(destination, sog, true))
288 {
289 //m_log.Debug("[REST COMMS]: LocalBackEnd SendCreateObject succeeded");
290 return true;
291 }
292
293 // else do the remote thing
294 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
295 return m_remoteConnector.CreateObject(destination, sog, isLocalCall);
296
297 return false;
298 }
299
300 public bool CreateObject(GridRegion destination, UUID userID, UUID itemID)
301 {
302 // Not Implemented
303 return false;
304 }
305
306 #endregion /* IInterregionComms */
307
308
309 protected class RegionToRegionClient : RegionClient
310 {
311 Scene m_aScene = null;
312 IHyperlinkService m_hyperlinkService;
313
314 public RegionToRegionClient(Scene s, IHyperlinkService hyperService)
315 {
316 m_aScene = s;
317 m_hyperlinkService = hyperService;
318 }
319
320 public override ulong GetRegionHandle(ulong handle)
321 {
322 if (m_aScene.SceneGridService is HGSceneCommunicationService)
323 {
324 if (m_hyperlinkService != null)
325 return m_hyperlinkService.FindRegionHandle(handle);
326 }
327
328 return handle;
329 }
330
331 public override bool IsHyperlink(ulong handle)
332 {
333 if (m_aScene.SceneGridService is HGSceneCommunicationService)
334 {
335 if ((m_hyperlinkService != null) && (m_hyperlinkService.GetHyperlinkRegion(handle) != null))
336 return true;
337 }
338 return false;
339 }
340
341 public override void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit)
342 {
343 if (m_hyperlinkService != null)
344 m_hyperlinkService.SendUserInformation(regInfo, aCircuit);
345
346 }
347
348 public override void AdjustUserInformation(AgentCircuitData aCircuit)
349 {
350 if (m_hyperlinkService != null)
351 m_hyperlinkService.AdjustUserInformation(aCircuit);
352 }
353 }
354
355 }
356}