diff options
author | Diva Canto | 2010-01-03 09:35:12 -0800 |
---|---|---|
committer | Diva Canto | 2010-01-03 09:35:12 -0800 |
commit | c268e342d19b6cc5969b1c1d94f20a3f4eb844ef (patch) | |
tree | 713af45648bd51675b087af23b0ea0df9ab0f72c | |
parent | Applied fix for avatar connectors similar to yesterday's fix of user account ... (diff) | |
download | opensim-SC-c268e342d19b6cc5969b1c1d94f20a3f4eb844ef.zip opensim-SC-c268e342d19b6cc5969b1c1d94f20a3f4eb844ef.tar.gz opensim-SC-c268e342d19b6cc5969b1c1d94f20a3f4eb844ef.tar.bz2 opensim-SC-c268e342d19b6cc5969b1c1d94f20a3f4eb844ef.tar.xz |
* Changed ISimulation interface to take a GridRegion as input arg instead of a regionHandle.
* Added the RemoteSimulationConnectorModule, which is the replacement for RESTComms. Scenes is not using this yet, only (standalone) Login uses these region modules for now.
* Completed SimulationServiceConnector and corresponding handlers.
12 files changed, 763 insertions, 289 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; | |||
34 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
35 | using OpenSim.Region.Framework.Scenes; | 35 | using OpenSim.Region.Framework.Scenes; |
36 | using OpenSim.Services.Interfaces; | 36 | using OpenSim.Services.Interfaces; |
37 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
37 | 38 | ||
38 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | 39 | namespace 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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.IO; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Text; | ||
34 | using log4net; | ||
35 | using Nini.Config; | ||
36 | using OpenMetaverse; | ||
37 | using OpenMetaverse.StructuredData; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Framework.Communications; | ||
40 | using OpenSim.Framework.Communications.Clients; | ||
41 | using OpenSim.Region.Framework.Interfaces; | ||
42 | using OpenSim.Region.Framework.Scenes; | ||
43 | using OpenSim.Region.Framework.Scenes.Hypergrid; | ||
44 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
45 | using OpenSim.Services.Interfaces; | ||
46 | using OpenSim.Services.Connectors.Simulation; | ||
47 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
48 | |||
49 | namespace 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 | } | ||
diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index 4966f66..f4f3eea 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | |||
@@ -35,6 +35,7 @@ using System.Text; | |||
35 | using OpenSim.Server.Base; | 35 | using OpenSim.Server.Base; |
36 | using OpenSim.Server.Handlers.Base; | 36 | using OpenSim.Server.Handlers.Base; |
37 | using OpenSim.Services.Interfaces; | 37 | using OpenSim.Services.Interfaces; |
38 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
38 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
39 | using OpenSim.Framework.Servers.HttpServer; | 40 | using OpenSim.Framework.Servers.HttpServer; |
40 | 41 | ||
@@ -72,9 +73,9 @@ namespace OpenSim.Server.Handlers.Simulation | |||
72 | 73 | ||
73 | 74 | ||
74 | UUID agentID; | 75 | UUID agentID; |
76 | UUID regionID; | ||
75 | string action; | 77 | string action; |
76 | ulong regionHandle; | 78 | if (!Utils.GetParams((string)request["uri"], out agentID, out regionID, out action)) |
77 | if (!Utils.GetParams((string)request["uri"], out agentID, out regionHandle, out action)) | ||
78 | { | 79 | { |
79 | m_log.InfoFormat("[AGENT HANDLER]: Invalid parameters for agent message {0}", request["uri"]); | 80 | m_log.InfoFormat("[AGENT HANDLER]: Invalid parameters for agent message {0}", request["uri"]); |
80 | responsedata["int_response_code"] = 404; | 81 | responsedata["int_response_code"] = 404; |
@@ -97,12 +98,12 @@ namespace OpenSim.Server.Handlers.Simulation | |||
97 | } | 98 | } |
98 | else if (method.Equals("GET")) | 99 | else if (method.Equals("GET")) |
99 | { | 100 | { |
100 | DoAgentGet(request, responsedata, agentID, regionHandle); | 101 | DoAgentGet(request, responsedata, agentID, regionID); |
101 | return responsedata; | 102 | return responsedata; |
102 | } | 103 | } |
103 | else if (method.Equals("DELETE")) | 104 | else if (method.Equals("DELETE")) |
104 | { | 105 | { |
105 | DoAgentDelete(request, responsedata, agentID, action, regionHandle); | 106 | DoAgentDelete(request, responsedata, agentID, action, regionID); |
106 | return responsedata; | 107 | return responsedata; |
107 | } | 108 | } |
108 | else | 109 | else |
@@ -126,10 +127,27 @@ namespace OpenSim.Server.Handlers.Simulation | |||
126 | return; | 127 | return; |
127 | } | 128 | } |
128 | 129 | ||
129 | // retrieve the regionhandle | 130 | // retrieve the input arguments |
130 | ulong regionhandle = 0; | 131 | int x = 0, y = 0; |
131 | if (args["destination_handle"] != null) | 132 | UUID uuid = UUID.Zero; |
132 | UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle); | 133 | string regionname = string.Empty; |
134 | uint teleportFlags = 0; | ||
135 | if (args.ContainsKey("destination_x") && args["destination_x"] != null) | ||
136 | Int32.TryParse(args["destination_x"].AsString(), out x); | ||
137 | if (args.ContainsKey("destination_y") && args["destination_y"] != null) | ||
138 | Int32.TryParse(args["destination_y"].AsString(), out y); | ||
139 | if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null) | ||
140 | UUID.TryParse(args["destination_uuid"].AsString(), out uuid); | ||
141 | if (args.ContainsKey("destination_name") && args["destination_name"] != null) | ||
142 | regionname = args["destination_name"].ToString(); | ||
143 | if (args.ContainsKey("teleport_flags") && args["teleport_flags"] != null) | ||
144 | teleportFlags = args["teleport_flags"].AsUInteger(); | ||
145 | |||
146 | GridRegion destination = new GridRegion(); | ||
147 | destination.RegionID = uuid; | ||
148 | destination.RegionLocX = x; | ||
149 | destination.RegionLocY = y; | ||
150 | destination.RegionName = regionname; | ||
133 | 151 | ||
134 | AgentCircuitData aCircuit = new AgentCircuitData(); | 152 | AgentCircuitData aCircuit = new AgentCircuitData(); |
135 | try | 153 | try |
@@ -146,15 +164,10 @@ namespace OpenSim.Server.Handlers.Simulation | |||
146 | 164 | ||
147 | OSDMap resp = new OSDMap(2); | 165 | OSDMap resp = new OSDMap(2); |
148 | string reason = String.Empty; | 166 | string reason = String.Empty; |
149 | uint teleportFlags = 0; | ||
150 | if (args.ContainsKey("teleport_flags")) | ||
151 | { | ||
152 | teleportFlags = args["teleport_flags"].AsUInteger(); | ||
153 | } | ||
154 | 167 | ||
155 | // This is the meaning of POST agent | 168 | // This is the meaning of POST agent |
156 | //m_regionClient.AdjustUserInformation(aCircuit); | 169 | //m_regionClient.AdjustUserInformation(aCircuit); |
157 | bool result = m_SimulationService.CreateAgent(regionhandle, aCircuit, teleportFlags, out reason); | 170 | bool result = m_SimulationService.CreateAgent(destination, aCircuit, teleportFlags, out reason); |
158 | 171 | ||
159 | resp["reason"] = OSD.FromString(reason); | 172 | resp["reason"] = OSD.FromString(reason); |
160 | resp["success"] = OSD.FromBoolean(result); | 173 | resp["success"] = OSD.FromBoolean(result); |
@@ -174,10 +187,24 @@ namespace OpenSim.Server.Handlers.Simulation | |||
174 | return; | 187 | return; |
175 | } | 188 | } |
176 | 189 | ||
177 | // retrieve the regionhandle | 190 | // retrieve the input arguments |
178 | ulong regionhandle = 0; | 191 | int x = 0, y = 0; |
179 | if (args["destination_handle"] != null) | 192 | UUID uuid = UUID.Zero; |
180 | UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle); | 193 | string regionname = string.Empty; |
194 | if (args.ContainsKey("destination_x") && args["destination_x"] != null) | ||
195 | Int32.TryParse(args["destination_x"].AsString(), out x); | ||
196 | if (args.ContainsKey("destination_y") && args["destination_y"] != null) | ||
197 | Int32.TryParse(args["destination_y"].AsString(), out y); | ||
198 | if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null) | ||
199 | UUID.TryParse(args["destination_uuid"].AsString(), out uuid); | ||
200 | if (args.ContainsKey("destination_name") && args["destination_name"] != null) | ||
201 | regionname = args["destination_name"].ToString(); | ||
202 | |||
203 | GridRegion destination = new GridRegion(); | ||
204 | destination.RegionID = uuid; | ||
205 | destination.RegionLocX = x; | ||
206 | destination.RegionLocY = y; | ||
207 | destination.RegionName = regionname; | ||
181 | 208 | ||
182 | string messageType; | 209 | string messageType; |
183 | if (args["message_type"] != null) | 210 | if (args["message_type"] != null) |
@@ -206,7 +233,7 @@ namespace OpenSim.Server.Handlers.Simulation | |||
206 | 233 | ||
207 | //agent.Dump(); | 234 | //agent.Dump(); |
208 | // This is one of the meanings of PUT agent | 235 | // This is one of the meanings of PUT agent |
209 | result = m_SimulationService.UpdateAgent(regionhandle, agent); | 236 | result = m_SimulationService.UpdateAgent(destination, agent); |
210 | 237 | ||
211 | } | 238 | } |
212 | else if ("AgentPosition".Equals(messageType)) | 239 | else if ("AgentPosition".Equals(messageType)) |
@@ -223,7 +250,7 @@ namespace OpenSim.Server.Handlers.Simulation | |||
223 | } | 250 | } |
224 | //agent.Dump(); | 251 | //agent.Dump(); |
225 | // This is one of the meanings of PUT agent | 252 | // This is one of the meanings of PUT agent |
226 | result = m_SimulationService.UpdateAgent(regionhandle, agent); | 253 | result = m_SimulationService.UpdateAgent(destination, agent); |
227 | 254 | ||
228 | } | 255 | } |
229 | 256 | ||
@@ -232,10 +259,13 @@ namespace OpenSim.Server.Handlers.Simulation | |||
232 | //responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); ??? instead | 259 | //responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); ??? instead |
233 | } | 260 | } |
234 | 261 | ||
235 | protected virtual void DoAgentGet(Hashtable request, Hashtable responsedata, UUID id, ulong regionHandle) | 262 | protected virtual void DoAgentGet(Hashtable request, Hashtable responsedata, UUID id, UUID regionID) |
236 | { | 263 | { |
264 | GridRegion destination = new GridRegion(); | ||
265 | destination.RegionID = regionID; | ||
266 | |||
237 | IAgentData agent = null; | 267 | IAgentData agent = null; |
238 | bool result = m_SimulationService.RetrieveAgent(regionHandle, id, out agent); | 268 | bool result = m_SimulationService.RetrieveAgent(destination, id, out agent); |
239 | OSDMap map = null; | 269 | OSDMap map = null; |
240 | if (result) | 270 | if (result) |
241 | { | 271 | { |
@@ -271,14 +301,17 @@ namespace OpenSim.Server.Handlers.Simulation | |||
271 | } | 301 | } |
272 | } | 302 | } |
273 | 303 | ||
274 | protected virtual void DoAgentDelete(Hashtable request, Hashtable responsedata, UUID id, string action, ulong regionHandle) | 304 | protected virtual void DoAgentDelete(Hashtable request, Hashtable responsedata, UUID id, string action, UUID regionID) |
275 | { | 305 | { |
276 | //m_log.Debug(" >>> DoDelete action:" + action + "; regionHandle:" + regionHandle); | 306 | //m_log.Debug(" >>> DoDelete action:" + action + "; regionHandle:" + regionHandle); |
277 | 307 | ||
308 | GridRegion destination = new GridRegion(); | ||
309 | destination.RegionID = regionID; | ||
310 | |||
278 | if (action.Equals("release")) | 311 | if (action.Equals("release")) |
279 | m_SimulationService.ReleaseAgent(regionHandle, id, ""); | 312 | m_SimulationService.ReleaseAgent(destination, id, ""); |
280 | else | 313 | else |
281 | m_SimulationService.CloseAgent(regionHandle, id); | 314 | m_SimulationService.CloseAgent(destination, id); |
282 | 315 | ||
283 | responsedata["int_response_code"] = HttpStatusCode.OK; | 316 | responsedata["int_response_code"] = HttpStatusCode.OK; |
284 | responsedata["str_response_string"] = "OpenSim agent " + id.ToString(); | 317 | responsedata["str_response_string"] = "OpenSim agent " + id.ToString(); |
@@ -287,165 +320,4 @@ namespace OpenSim.Server.Handlers.Simulation | |||
287 | } | 320 | } |
288 | } | 321 | } |
289 | 322 | ||
290 | public class AgentGetHandler : BaseStreamHandler | ||
291 | { | ||
292 | // TODO: unused: private ISimulationService m_SimulationService; | ||
293 | // TODO: unused: private IAuthenticationService m_AuthenticationService; | ||
294 | |||
295 | public AgentGetHandler(ISimulationService service, IAuthenticationService authentication) : | ||
296 | base("GET", "/agent") | ||
297 | { | ||
298 | // TODO: unused: m_SimulationService = service; | ||
299 | // TODO: unused: m_AuthenticationService = authentication; | ||
300 | } | ||
301 | |||
302 | public override byte[] Handle(string path, Stream request, | ||
303 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
304 | { | ||
305 | // Not implemented yet | ||
306 | httpResponse.StatusCode = (int)HttpStatusCode.NotImplemented; | ||
307 | return new byte[] { }; | ||
308 | } | ||
309 | } | ||
310 | |||
311 | public class AgentPostHandler : BaseStreamHandler | ||
312 | { | ||
313 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
314 | private ISimulationService m_SimulationService; | ||
315 | private IAuthenticationService m_AuthenticationService; | ||
316 | // TODO: unused: private bool m_AllowForeignGuests; | ||
317 | |||
318 | public AgentPostHandler(ISimulationService service, IAuthenticationService authentication, bool foreignGuests) : | ||
319 | base("POST", "/agent") | ||
320 | { | ||
321 | m_SimulationService = service; | ||
322 | m_AuthenticationService = authentication; | ||
323 | // TODO: unused: m_AllowForeignGuests = foreignGuests; | ||
324 | } | ||
325 | |||
326 | public override byte[] Handle(string path, Stream request, | ||
327 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
328 | { | ||
329 | byte[] result = new byte[0]; | ||
330 | |||
331 | UUID agentID; | ||
332 | string action; | ||
333 | ulong regionHandle; | ||
334 | if (!RestHandlerUtils.GetParams(path, out agentID, out regionHandle, out action)) | ||
335 | { | ||
336 | m_log.InfoFormat("[AgentPostHandler]: Invalid parameters for agent message {0}", path); | ||
337 | httpResponse.StatusCode = (int)HttpStatusCode.BadRequest; | ||
338 | httpResponse.StatusDescription = "Invalid parameters for agent message " + path; | ||
339 | |||
340 | return result; | ||
341 | } | ||
342 | |||
343 | if (m_AuthenticationService != null) | ||
344 | { | ||
345 | // Authentication | ||
346 | string authority = string.Empty; | ||
347 | string authToken = string.Empty; | ||
348 | if (!RestHandlerUtils.GetAuthentication(httpRequest, out authority, out authToken)) | ||
349 | { | ||
350 | m_log.InfoFormat("[AgentPostHandler]: Authentication failed for agent message {0}", path); | ||
351 | httpResponse.StatusCode = (int)HttpStatusCode.Unauthorized; | ||
352 | return result; | ||
353 | } | ||
354 | // TODO: Rethink this | ||
355 | //if (!m_AuthenticationService.VerifyKey(agentID, authToken)) | ||
356 | //{ | ||
357 | // m_log.InfoFormat("[AgentPostHandler]: Authentication failed for agent message {0}", path); | ||
358 | // httpResponse.StatusCode = (int)HttpStatusCode.Forbidden; | ||
359 | // return result; | ||
360 | //} | ||
361 | m_log.DebugFormat("[AgentPostHandler]: Authentication succeeded for {0}", agentID); | ||
362 | } | ||
363 | |||
364 | OSDMap args = Util.GetOSDMap(request, (int)httpRequest.ContentLength); | ||
365 | if (args == null) | ||
366 | { | ||
367 | httpResponse.StatusCode = (int)HttpStatusCode.BadRequest; | ||
368 | httpResponse.StatusDescription = "Unable to retrieve data"; | ||
369 | m_log.DebugFormat("[AgentPostHandler]: Unable to retrieve data for post {0}", path); | ||
370 | return result; | ||
371 | } | ||
372 | |||
373 | // retrieve the regionhandle | ||
374 | ulong regionhandle = 0; | ||
375 | if (args["destination_handle"] != null) | ||
376 | UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle); | ||
377 | |||
378 | AgentCircuitData aCircuit = new AgentCircuitData(); | ||
379 | try | ||
380 | { | ||
381 | aCircuit.UnpackAgentCircuitData(args); | ||
382 | } | ||
383 | catch (Exception ex) | ||
384 | { | ||
385 | m_log.InfoFormat("[AgentPostHandler]: exception on unpacking CreateAgent message {0}", ex.Message); | ||
386 | httpResponse.StatusCode = (int)HttpStatusCode.BadRequest; | ||
387 | httpResponse.StatusDescription = "Problems with data deserialization"; | ||
388 | return result; | ||
389 | } | ||
390 | |||
391 | string reason = string.Empty; | ||
392 | |||
393 | // We need to clean up a few things in the user service before I can do this | ||
394 | //if (m_AllowForeignGuests) | ||
395 | // m_regionClient.AdjustUserInformation(aCircuit); | ||
396 | |||
397 | // Finally! | ||
398 | bool success = m_SimulationService.CreateAgent(regionhandle, aCircuit, /*!!!*/0, out reason); | ||
399 | |||
400 | OSDMap resp = new OSDMap(1); | ||
401 | |||
402 | resp["success"] = OSD.FromBoolean(success); | ||
403 | |||
404 | httpResponse.StatusCode = (int)HttpStatusCode.OK; | ||
405 | |||
406 | return Util.UTF8.GetBytes(OSDParser.SerializeJsonString(resp)); | ||
407 | } | ||
408 | } | ||
409 | |||
410 | public class AgentPutHandler : BaseStreamHandler | ||
411 | { | ||
412 | // TODO: unused: private ISimulationService m_SimulationService; | ||
413 | // TODO: unused: private IAuthenticationService m_AuthenticationService; | ||
414 | |||
415 | public AgentPutHandler(ISimulationService service, IAuthenticationService authentication) : | ||
416 | base("PUT", "/agent") | ||
417 | { | ||
418 | // TODO: unused: m_SimulationService = service; | ||
419 | // TODO: unused: m_AuthenticationService = authentication; | ||
420 | } | ||
421 | |||
422 | public override byte[] Handle(string path, Stream request, | ||
423 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
424 | { | ||
425 | // Not implemented yet | ||
426 | httpResponse.StatusCode = (int)HttpStatusCode.NotImplemented; | ||
427 | return new byte[] { }; | ||
428 | } | ||
429 | } | ||
430 | |||
431 | public class AgentDeleteHandler : BaseStreamHandler | ||
432 | { | ||
433 | // TODO: unused: private ISimulationService m_SimulationService; | ||
434 | // TODO: unused: private IAuthenticationService m_AuthenticationService; | ||
435 | |||
436 | public AgentDeleteHandler(ISimulationService service, IAuthenticationService authentication) : | ||
437 | base("DELETE", "/agent") | ||
438 | { | ||
439 | // TODO: unused: m_SimulationService = service; | ||
440 | // TODO: unused: m_AuthenticationService = authentication; | ||
441 | } | ||
442 | |||
443 | public override byte[] Handle(string path, Stream request, | ||
444 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
445 | { | ||
446 | // Not implemented yet | ||
447 | httpResponse.StatusCode = (int)HttpStatusCode.NotImplemented; | ||
448 | return new byte[] { }; | ||
449 | } | ||
450 | } | ||
451 | } | 323 | } |
diff --git a/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs b/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs index 8c3af72..995a3c4 100644 --- a/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs | |||
@@ -35,6 +35,7 @@ using System.Text; | |||
35 | using OpenSim.Server.Base; | 35 | using OpenSim.Server.Base; |
36 | using OpenSim.Server.Handlers.Base; | 36 | using OpenSim.Server.Handlers.Base; |
37 | using OpenSim.Services.Interfaces; | 37 | using OpenSim.Services.Interfaces; |
38 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
38 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
39 | using OpenSim.Framework.Servers.HttpServer; | 40 | using OpenSim.Framework.Servers.HttpServer; |
40 | 41 | ||
@@ -70,9 +71,9 @@ namespace OpenSim.Server.Handlers.Simulation | |||
70 | responsedata["content_type"] = "text/html"; | 71 | responsedata["content_type"] = "text/html"; |
71 | 72 | ||
72 | UUID objectID; | 73 | UUID objectID; |
74 | UUID regionID; | ||
73 | string action; | 75 | string action; |
74 | ulong regionHandle; | 76 | if (!Utils.GetParams((string)request["uri"], out objectID, out regionID, out action)) |
75 | if (!Utils.GetParams((string)request["uri"], out objectID, out regionHandle, out action)) | ||
76 | { | 77 | { |
77 | m_log.InfoFormat("[REST COMMS]: Invalid parameters for object message {0}", request["uri"]); | 78 | m_log.InfoFormat("[REST COMMS]: Invalid parameters for object message {0}", request["uri"]); |
78 | responsedata["int_response_code"] = 404; | 79 | responsedata["int_response_code"] = 404; |
@@ -85,12 +86,12 @@ namespace OpenSim.Server.Handlers.Simulation | |||
85 | string method = (string)request["http-method"]; | 86 | string method = (string)request["http-method"]; |
86 | if (method.Equals("POST")) | 87 | if (method.Equals("POST")) |
87 | { | 88 | { |
88 | DoObjectPost(request, responsedata, regionHandle); | 89 | DoObjectPost(request, responsedata, regionID); |
89 | return responsedata; | 90 | return responsedata; |
90 | } | 91 | } |
91 | else if (method.Equals("PUT")) | 92 | else if (method.Equals("PUT")) |
92 | { | 93 | { |
93 | DoObjectPut(request, responsedata, regionHandle); | 94 | DoObjectPut(request, responsedata, regionID); |
94 | return responsedata; | 95 | return responsedata; |
95 | } | 96 | } |
96 | //else if (method.Equals("DELETE")) | 97 | //else if (method.Equals("DELETE")) |
@@ -109,7 +110,7 @@ namespace OpenSim.Server.Handlers.Simulation | |||
109 | 110 | ||
110 | } | 111 | } |
111 | 112 | ||
112 | protected virtual void DoObjectPost(Hashtable request, Hashtable responsedata, ulong regionhandle) | 113 | protected virtual void DoObjectPost(Hashtable request, Hashtable responsedata, UUID regionID) |
113 | { | 114 | { |
114 | OSDMap args = Utils.GetOSDMap((string)request["body"]); | 115 | OSDMap args = Utils.GetOSDMap((string)request["body"]); |
115 | if (args == null) | 116 | if (args == null) |
@@ -118,14 +119,32 @@ namespace OpenSim.Server.Handlers.Simulation | |||
118 | responsedata["str_response_string"] = "false"; | 119 | responsedata["str_response_string"] = "false"; |
119 | return; | 120 | return; |
120 | } | 121 | } |
122 | // retrieve the input arguments | ||
123 | int x = 0, y = 0; | ||
124 | UUID uuid = UUID.Zero; | ||
125 | string regionname = string.Empty; | ||
126 | if (args.ContainsKey("destination_x") && args["destination_x"] != null) | ||
127 | Int32.TryParse(args["destination_x"].AsString(), out x); | ||
128 | if (args.ContainsKey("destination_y") && args["destination_y"] != null) | ||
129 | Int32.TryParse(args["destination_y"].AsString(), out y); | ||
130 | if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null) | ||
131 | UUID.TryParse(args["destination_uuid"].AsString(), out uuid); | ||
132 | if (args.ContainsKey("destination_name") && args["destination_name"] != null) | ||
133 | regionname = args["destination_name"].ToString(); | ||
134 | |||
135 | GridRegion destination = new GridRegion(); | ||
136 | destination.RegionID = uuid; | ||
137 | destination.RegionLocX = x; | ||
138 | destination.RegionLocY = y; | ||
139 | destination.RegionName = regionname; | ||
121 | 140 | ||
122 | string sogXmlStr = "", extraStr = "", stateXmlStr = ""; | 141 | string sogXmlStr = "", extraStr = "", stateXmlStr = ""; |
123 | if (args["sog"] != null) | 142 | if (args.ContainsKey("sog") && args["sog"] != null) |
124 | sogXmlStr = args["sog"].AsString(); | 143 | sogXmlStr = args["sog"].AsString(); |
125 | if (args["extra"] != null) | 144 | if (args.ContainsKey("extra") && args["extra"] != null) |
126 | extraStr = args["extra"].AsString(); | 145 | extraStr = args["extra"].AsString(); |
127 | 146 | ||
128 | IScene s = m_SimulationService.GetScene(regionhandle); | 147 | IScene s = m_SimulationService.GetScene(destination.RegionHandle); |
129 | ISceneObject sog = null; | 148 | ISceneObject sog = null; |
130 | try | 149 | try |
131 | { | 150 | { |
@@ -158,13 +177,13 @@ namespace OpenSim.Server.Handlers.Simulation | |||
158 | } | 177 | } |
159 | } | 178 | } |
160 | // This is the meaning of POST object | 179 | // This is the meaning of POST object |
161 | bool result = m_SimulationService.CreateObject(regionhandle, sog, false); | 180 | bool result = m_SimulationService.CreateObject(destination, sog, false); |
162 | 181 | ||
163 | responsedata["int_response_code"] = HttpStatusCode.OK; | 182 | responsedata["int_response_code"] = HttpStatusCode.OK; |
164 | responsedata["str_response_string"] = result.ToString(); | 183 | responsedata["str_response_string"] = result.ToString(); |
165 | } | 184 | } |
166 | 185 | ||
167 | protected virtual void DoObjectPut(Hashtable request, Hashtable responsedata, ulong regionhandle) | 186 | protected virtual void DoObjectPut(Hashtable request, Hashtable responsedata, UUID regionID) |
168 | { | 187 | { |
169 | OSDMap args = Utils.GetOSDMap((string)request["body"]); | 188 | OSDMap args = Utils.GetOSDMap((string)request["body"]); |
170 | if (args == null) | 189 | if (args == null) |
@@ -174,14 +193,33 @@ namespace OpenSim.Server.Handlers.Simulation | |||
174 | return; | 193 | return; |
175 | } | 194 | } |
176 | 195 | ||
196 | // retrieve the input arguments | ||
197 | int x = 0, y = 0; | ||
198 | UUID uuid = UUID.Zero; | ||
199 | string regionname = string.Empty; | ||
200 | if (args.ContainsKey("destination_x") && args["destination_x"] != null) | ||
201 | Int32.TryParse(args["destination_x"].AsString(), out x); | ||
202 | if (args.ContainsKey("destination_y") && args["destination_y"] != null) | ||
203 | Int32.TryParse(args["destination_y"].AsString(), out y); | ||
204 | if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null) | ||
205 | UUID.TryParse(args["destination_uuid"].AsString(), out uuid); | ||
206 | if (args.ContainsKey("destination_name") && args["destination_name"] != null) | ||
207 | regionname = args["destination_name"].ToString(); | ||
208 | |||
209 | GridRegion destination = new GridRegion(); | ||
210 | destination.RegionID = uuid; | ||
211 | destination.RegionLocX = x; | ||
212 | destination.RegionLocY = y; | ||
213 | destination.RegionName = regionname; | ||
214 | |||
177 | UUID userID = UUID.Zero, itemID = UUID.Zero; | 215 | UUID userID = UUID.Zero, itemID = UUID.Zero; |
178 | if (args["userid"] != null) | 216 | if (args.ContainsKey("userid") && args["userid"] != null) |
179 | userID = args["userid"].AsUUID(); | 217 | userID = args["userid"].AsUUID(); |
180 | if (args["itemid"] != null) | 218 | if (args.ContainsKey("itemid") && args["itemid"] != null) |
181 | itemID = args["itemid"].AsUUID(); | 219 | itemID = args["itemid"].AsUUID(); |
182 | 220 | ||
183 | // This is the meaning of PUT object | 221 | // This is the meaning of PUT object |
184 | bool result = m_SimulationService.CreateObject(regionhandle, userID, itemID); | 222 | bool result = m_SimulationService.CreateObject(destination, userID, itemID); |
185 | 223 | ||
186 | responsedata["int_response_code"] = 200; | 224 | responsedata["int_response_code"] = 200; |
187 | responsedata["str_response_string"] = result.ToString(); | 225 | responsedata["str_response_string"] = result.ToString(); |
diff --git a/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs b/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs index 8611228..55a575c 100644 --- a/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs +++ b/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs | |||
@@ -43,9 +43,9 @@ namespace OpenSim.Server.Handlers.Simulation | |||
43 | public SimulationServiceInConnector(IConfigSource config, IHttpServer server, IScene scene) : | 43 | public SimulationServiceInConnector(IConfigSource config, IHttpServer server, IScene scene) : |
44 | base(config, server, String.Empty) | 44 | base(config, server, String.Empty) |
45 | { | 45 | { |
46 | IConfig serverConfig = config.Configs["SimulationService"]; | 46 | //IConfig serverConfig = config.Configs["SimulationService"]; |
47 | if (serverConfig == null) | 47 | //if (serverConfig == null) |
48 | throw new Exception("No section 'SimulationService' in config file"); | 48 | // throw new Exception("No section 'SimulationService' in config file"); |
49 | 49 | ||
50 | //string simService = serverConfig.GetString("LocalServiceModule", | 50 | //string simService = serverConfig.GetString("LocalServiceModule", |
51 | // String.Empty); | 51 | // String.Empty); |
diff --git a/OpenSim/Server/Handlers/Simulation/Utils.cs b/OpenSim/Server/Handlers/Simulation/Utils.cs index 1f2f851..ed379da 100644 --- a/OpenSim/Server/Handlers/Simulation/Utils.cs +++ b/OpenSim/Server/Handlers/Simulation/Utils.cs | |||
@@ -46,11 +46,11 @@ namespace OpenSim.Server.Handlers.Simulation | |||
46 | /// <param name="uri">Something like this: /agent/uuid/ or /agent/uuid/handle/release</param> | 46 | /// <param name="uri">Something like this: /agent/uuid/ or /agent/uuid/handle/release</param> |
47 | /// <param name="uri">uuid on uuid field</param> | 47 | /// <param name="uri">uuid on uuid field</param> |
48 | /// <param name="action">optional action</param> | 48 | /// <param name="action">optional action</param> |
49 | public static bool GetParams(string uri, out UUID uuid, out ulong regionHandle, out string action) | 49 | public static bool GetParams(string uri, out UUID uuid, out UUID regionID, out string action) |
50 | { | 50 | { |
51 | uuid = UUID.Zero; | 51 | uuid = UUID.Zero; |
52 | regionID = UUID.Zero; | ||
52 | action = ""; | 53 | action = ""; |
53 | regionHandle = 0; | ||
54 | 54 | ||
55 | uri = uri.Trim(new char[] { '/' }); | 55 | uri = uri.Trim(new char[] { '/' }); |
56 | string[] parts = uri.Split('/'); | 56 | string[] parts = uri.Split('/'); |
@@ -64,7 +64,7 @@ namespace OpenSim.Server.Handlers.Simulation | |||
64 | return false; | 64 | return false; |
65 | 65 | ||
66 | if (parts.Length >= 3) | 66 | if (parts.Length >= 3) |
67 | UInt64.TryParse(parts[2], out regionHandle); | 67 | UUID.TryParse(parts[2], out regionID); |
68 | if (parts.Length >= 4) | 68 | if (parts.Length >= 4) |
69 | action = parts[3]; | 69 | action = parts[3]; |
70 | 70 | ||
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index 6f71197..fcf07c7 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs | |||
@@ -46,7 +46,7 @@ namespace OpenSim.Services.Connectors.Simulation | |||
46 | { | 46 | { |
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | 48 | ||
49 | private GridRegion m_Region; | 49 | //private GridRegion m_Region; |
50 | 50 | ||
51 | public SimulationServiceConnector() | 51 | public SimulationServiceConnector() |
52 | { | 52 | { |
@@ -54,7 +54,7 @@ namespace OpenSim.Services.Connectors.Simulation | |||
54 | 54 | ||
55 | public SimulationServiceConnector(GridRegion region) | 55 | public SimulationServiceConnector(GridRegion region) |
56 | { | 56 | { |
57 | m_Region = region; | 57 | //m_Region = region; |
58 | } | 58 | } |
59 | 59 | ||
60 | public IScene GetScene(ulong regionHandle) | 60 | public IScene GetScene(ulong regionHandle) |
@@ -64,7 +64,7 @@ namespace OpenSim.Services.Connectors.Simulation | |||
64 | 64 | ||
65 | #region Agents | 65 | #region Agents |
66 | 66 | ||
67 | public bool CreateAgent(ulong regionHandle, AgentCircuitData aCircuit, uint flags, out string reason) | 67 | public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason) |
68 | { | 68 | { |
69 | reason = String.Empty; | 69 | reason = String.Empty; |
70 | 70 | ||
@@ -72,11 +72,11 @@ namespace OpenSim.Services.Connectors.Simulation | |||
72 | string uri = string.Empty; | 72 | string uri = string.Empty; |
73 | try | 73 | try |
74 | { | 74 | { |
75 | uri = "http://" + m_Region.ExternalEndPoint.Address + ":" + m_Region.HttpPort + "/agent/" + aCircuit.AgentID + "/"; | 75 | uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/agent/" + aCircuit.AgentID + "/"; |
76 | } | 76 | } |
77 | catch (Exception e) | 77 | catch (Exception e) |
78 | { | 78 | { |
79 | m_log.Debug("[REST COMMS]: Unable to resolve external endpoint on agent create. Reason: " + e.Message); | 79 | m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Unable to resolve external endpoint on agent create. Reason: " + e.Message); |
80 | reason = e.Message; | 80 | reason = e.Message; |
81 | return false; | 81 | return false; |
82 | } | 82 | } |
@@ -98,11 +98,13 @@ namespace OpenSim.Services.Connectors.Simulation | |||
98 | } | 98 | } |
99 | catch (Exception e) | 99 | catch (Exception e) |
100 | { | 100 | { |
101 | m_log.Debug("[REST COMMS]: PackAgentCircuitData failed with exception: " + e.Message); | 101 | m_log.Debug("[REMOTE SIMULATION CONNECTOR]: PackAgentCircuitData failed with exception: " + e.Message); |
102 | } | 102 | } |
103 | // Add the regionhandle and the name of the destination region | 103 | // Add the input arguments |
104 | args["destination_handle"] = OSD.FromString(m_Region.RegionHandle.ToString()); | 104 | args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString()); |
105 | args["destination_name"] = OSD.FromString(m_Region.RegionName); | 105 | args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); |
106 | args["destination_name"] = OSD.FromString(destination.RegionName); | ||
107 | args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); | ||
106 | args["teleport_flags"] = OSD.FromString(flags.ToString()); | 108 | args["teleport_flags"] = OSD.FromString(flags.ToString()); |
107 | 109 | ||
108 | string strBuffer = ""; | 110 | string strBuffer = ""; |
@@ -116,7 +118,7 @@ namespace OpenSim.Services.Connectors.Simulation | |||
116 | } | 118 | } |
117 | catch (Exception e) | 119 | catch (Exception e) |
118 | { | 120 | { |
119 | m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of ChildCreate: {0}", e.Message); | 121 | m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR]: Exception thrown on serialization of ChildCreate: {0}", e.Message); |
120 | // ignore. buffer will be empty, caller should check. | 122 | // ignore. buffer will be empty, caller should check. |
121 | } | 123 | } |
122 | 124 | ||
@@ -126,12 +128,12 @@ namespace OpenSim.Services.Connectors.Simulation | |||
126 | AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send | 128 | AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send |
127 | os = AgentCreateRequest.GetRequestStream(); | 129 | os = AgentCreateRequest.GetRequestStream(); |
128 | os.Write(buffer, 0, strBuffer.Length); //Send it | 130 | os.Write(buffer, 0, strBuffer.Length); //Send it |
129 | //m_log.InfoFormat("[REST COMMS]: Posted CreateChildAgent request to remote sim {0}", uri); | 131 | //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Posted CreateChildAgent request to remote sim {0}", uri); |
130 | } | 132 | } |
131 | //catch (WebException ex) | 133 | //catch (WebException ex) |
132 | catch | 134 | catch |
133 | { | 135 | { |
134 | //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message); | 136 | //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Bad send on ChildAgentUpdate {0}", ex.Message); |
135 | reason = "cannot contact remote region"; | 137 | reason = "cannot contact remote region"; |
136 | return false; | 138 | return false; |
137 | } | 139 | } |
@@ -142,7 +144,7 @@ namespace OpenSim.Services.Connectors.Simulation | |||
142 | } | 144 | } |
143 | 145 | ||
144 | // Let's wait for the response | 146 | // Let's wait for the response |
145 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); | 147 | //m_log.Info("[REMOTE SIMULATION CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall"); |
146 | 148 | ||
147 | WebResponse webResponse = null; | 149 | WebResponse webResponse = null; |
148 | StreamReader sr = null; | 150 | StreamReader sr = null; |
@@ -151,14 +153,14 @@ namespace OpenSim.Services.Connectors.Simulation | |||
151 | webResponse = AgentCreateRequest.GetResponse(); | 153 | webResponse = AgentCreateRequest.GetResponse(); |
152 | if (webResponse == null) | 154 | if (webResponse == null) |
153 | { | 155 | { |
154 | m_log.Info("[REST COMMS]: Null reply on DoCreateChildAgentCall post"); | 156 | m_log.Info("[REMOTE SIMULATION CONNECTOR]: Null reply on DoCreateChildAgentCall post"); |
155 | } | 157 | } |
156 | else | 158 | else |
157 | { | 159 | { |
158 | 160 | ||
159 | sr = new StreamReader(webResponse.GetResponseStream()); | 161 | sr = new StreamReader(webResponse.GetResponseStream()); |
160 | string response = sr.ReadToEnd().Trim(); | 162 | string response = sr.ReadToEnd().Trim(); |
161 | m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", response); | 163 | m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response); |
162 | 164 | ||
163 | if (!String.IsNullOrEmpty(response)) | 165 | if (!String.IsNullOrEmpty(response)) |
164 | { | 166 | { |
@@ -172,7 +174,7 @@ namespace OpenSim.Services.Connectors.Simulation | |||
172 | } | 174 | } |
173 | catch (NullReferenceException e) | 175 | catch (NullReferenceException e) |
174 | { | 176 | { |
175 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", e.Message); | 177 | m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message); |
176 | 178 | ||
177 | // check for old style response | 179 | // check for old style response |
178 | if (response.ToLower().StartsWith("true")) | 180 | if (response.ToLower().StartsWith("true")) |
@@ -185,7 +187,7 @@ namespace OpenSim.Services.Connectors.Simulation | |||
185 | } | 187 | } |
186 | catch (WebException ex) | 188 | catch (WebException ex) |
187 | { | 189 | { |
188 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); | 190 | m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); |
189 | // ignore, really | 191 | // ignore, really |
190 | } | 192 | } |
191 | finally | 193 | finally |
@@ -197,28 +199,189 @@ namespace OpenSim.Services.Connectors.Simulation | |||
197 | return true; | 199 | return true; |
198 | } | 200 | } |
199 | 201 | ||
200 | public bool UpdateAgent(ulong regionHandle, AgentData data) | 202 | public bool UpdateAgent(GridRegion destination, AgentData data) |
201 | { | 203 | { |
202 | return false; | 204 | return UpdateAgent(destination, data); |
203 | } | 205 | } |
204 | 206 | ||
205 | public bool UpdateAgent(ulong regionHandle, AgentPosition data) | 207 | public bool UpdateAgent(GridRegion destination, AgentPosition data) |
206 | { | 208 | { |
207 | return false; | 209 | return UpdateAgent(destination, data); |
208 | } | 210 | } |
209 | 211 | ||
210 | public bool RetrieveAgent(ulong regionHandle, UUID id, out IAgentData agent) | 212 | private bool UpdateAgent(GridRegion destination, IAgentData cAgentData) |
213 | { | ||
214 | // Eventually, we want to use a caps url instead of the agentID | ||
215 | string uri = string.Empty; | ||
216 | try | ||
217 | { | ||
218 | uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/agent/" + cAgentData.AgentID + "/"; | ||
219 | } | ||
220 | catch (Exception e) | ||
221 | { | ||
222 | m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Unable to resolve external endpoint on agent update. Reason: " + e.Message); | ||
223 | return false; | ||
224 | } | ||
225 | //Console.WriteLine(" >>> DoChildAgentUpdateCall <<< " + uri); | ||
226 | |||
227 | HttpWebRequest ChildUpdateRequest = (HttpWebRequest)WebRequest.Create(uri); | ||
228 | ChildUpdateRequest.Method = "PUT"; | ||
229 | ChildUpdateRequest.ContentType = "application/json"; | ||
230 | ChildUpdateRequest.Timeout = 10000; | ||
231 | //ChildUpdateRequest.KeepAlive = false; | ||
232 | |||
233 | // Fill it in | ||
234 | OSDMap args = null; | ||
235 | try | ||
236 | { | ||
237 | args = cAgentData.Pack(); | ||
238 | } | ||
239 | catch (Exception e) | ||
240 | { | ||
241 | m_log.Debug("[REMOTE SIMULATION CONNECTOR]: PackUpdateMessage failed with exception: " + e.Message); | ||
242 | } | ||
243 | // Add the input arguments | ||
244 | args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString()); | ||
245 | args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); | ||
246 | args["destination_name"] = OSD.FromString(destination.RegionName); | ||
247 | args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); | ||
248 | |||
249 | string strBuffer = ""; | ||
250 | byte[] buffer = new byte[1]; | ||
251 | try | ||
252 | { | ||
253 | strBuffer = OSDParser.SerializeJsonString(args); | ||
254 | Encoding str = Util.UTF8; | ||
255 | buffer = str.GetBytes(strBuffer); | ||
256 | |||
257 | } | ||
258 | catch (Exception e) | ||
259 | { | ||
260 | m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR]: Exception thrown on serialization of ChildUpdate: {0}", e.Message); | ||
261 | // ignore. buffer will be empty, caller should check. | ||
262 | } | ||
263 | |||
264 | Stream os = null; | ||
265 | try | ||
266 | { // send the Post | ||
267 | ChildUpdateRequest.ContentLength = buffer.Length; //Count bytes to send | ||
268 | os = ChildUpdateRequest.GetRequestStream(); | ||
269 | os.Write(buffer, 0, strBuffer.Length); //Send it | ||
270 | //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Posted ChildAgentUpdate request to remote sim {0}", uri); | ||
271 | } | ||
272 | //catch (WebException ex) | ||
273 | catch | ||
274 | { | ||
275 | //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Bad send on ChildAgentUpdate {0}", ex.Message); | ||
276 | |||
277 | return false; | ||
278 | } | ||
279 | finally | ||
280 | { | ||
281 | if (os != null) | ||
282 | os.Close(); | ||
283 | } | ||
284 | |||
285 | // Let's wait for the response | ||
286 | //m_log.Info("[REMOTE SIMULATION CONNECTOR]: Waiting for a reply after ChildAgentUpdate"); | ||
287 | |||
288 | WebResponse webResponse = null; | ||
289 | StreamReader sr = null; | ||
290 | try | ||
291 | { | ||
292 | webResponse = ChildUpdateRequest.GetResponse(); | ||
293 | if (webResponse == null) | ||
294 | { | ||
295 | m_log.Info("[REMOTE SIMULATION CONNECTOR]: Null reply on ChilAgentUpdate post"); | ||
296 | } | ||
297 | |||
298 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
299 | //reply = sr.ReadToEnd().Trim(); | ||
300 | sr.ReadToEnd().Trim(); | ||
301 | sr.Close(); | ||
302 | //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: ChilAgentUpdate reply was {0} ", reply); | ||
303 | |||
304 | } | ||
305 | catch (WebException ex) | ||
306 | { | ||
307 | m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of ChilAgentUpdate {0}", ex.Message); | ||
308 | // ignore, really | ||
309 | } | ||
310 | finally | ||
311 | { | ||
312 | if (sr != null) | ||
313 | sr.Close(); | ||
314 | } | ||
315 | |||
316 | return true; | ||
317 | } | ||
318 | |||
319 | public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) | ||
211 | { | 320 | { |
212 | agent = null; | 321 | agent = null; |
322 | // Eventually, we want to use a caps url instead of the agentID | ||
323 | string uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/agent/" + id + "/" + destination.RegionID.ToString() + "/"; | ||
324 | //Console.WriteLine(" >>> DoRetrieveRootAgentCall <<< " + uri); | ||
325 | |||
326 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); | ||
327 | request.Method = "GET"; | ||
328 | request.Timeout = 10000; | ||
329 | //request.Headers.Add("authorization", ""); // coming soon | ||
330 | |||
331 | HttpWebResponse webResponse = null; | ||
332 | string reply = string.Empty; | ||
333 | StreamReader sr = null; | ||
334 | try | ||
335 | { | ||
336 | webResponse = (HttpWebResponse)request.GetResponse(); | ||
337 | if (webResponse == null) | ||
338 | { | ||
339 | m_log.Info("[REMOTE SIMULATION CONNECTOR]: Null reply on agent get "); | ||
340 | } | ||
341 | |||
342 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
343 | reply = sr.ReadToEnd().Trim(); | ||
344 | |||
345 | //Console.WriteLine("[REMOTE SIMULATION CONNECTOR]: ChilAgentUpdate reply was " + reply); | ||
346 | |||
347 | } | ||
348 | catch (WebException ex) | ||
349 | { | ||
350 | m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of agent get {0}", ex.Message); | ||
351 | // ignore, really | ||
352 | return false; | ||
353 | } | ||
354 | finally | ||
355 | { | ||
356 | if (sr != null) | ||
357 | sr.Close(); | ||
358 | } | ||
359 | |||
360 | if (webResponse.StatusCode == HttpStatusCode.OK) | ||
361 | { | ||
362 | // we know it's jason | ||
363 | OSDMap args = Util.GetOSDMap(reply); | ||
364 | if (args == null) | ||
365 | { | ||
366 | //Console.WriteLine("[REMOTE SIMULATION CONNECTOR]: Error getting OSDMap from reply"); | ||
367 | return false; | ||
368 | } | ||
369 | |||
370 | agent = new CompleteAgentData(); | ||
371 | agent.Unpack(args); | ||
372 | return true; | ||
373 | } | ||
374 | |||
375 | //Console.WriteLine("[REMOTE SIMULATION CONNECTOR]: DoRetrieveRootAgentCall returned status " + webResponse.StatusCode); | ||
213 | return false; | 376 | return false; |
214 | } | 377 | } |
215 | 378 | ||
216 | public bool ReleaseAgent(ulong regionHandle, UUID id, string uri) | 379 | public bool ReleaseAgent(GridRegion destination, UUID id, string uri) |
217 | { | 380 | { |
218 | return false; | 381 | return false; |
219 | } | 382 | } |
220 | 383 | ||
221 | public bool CloseAgent(ulong regionHandle, UUID id) | 384 | public bool CloseAgent(GridRegion destination, UUID id) |
222 | { | 385 | { |
223 | return false; | 386 | return false; |
224 | } | 387 | } |
@@ -227,12 +390,12 @@ namespace OpenSim.Services.Connectors.Simulation | |||
227 | 390 | ||
228 | #region Objects | 391 | #region Objects |
229 | 392 | ||
230 | public bool CreateObject(ulong regionHandle, ISceneObject sog, bool isLocalCall) | 393 | public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) |
231 | { | 394 | { |
232 | return false; | 395 | return false; |
233 | } | 396 | } |
234 | 397 | ||
235 | public bool CreateObject(ulong regionHandle, UUID userID, UUID itemID) | 398 | public bool CreateObject(GridRegion destination, UUID userID, UUID itemID) |
236 | { | 399 | { |
237 | return false; | 400 | return false; |
238 | } | 401 | } |
diff --git a/OpenSim/Services/Interfaces/ISimulationService.cs b/OpenSim/Services/Interfaces/ISimulationService.cs index 7ba3e66..14f462c 100644 --- a/OpenSim/Services/Interfaces/ISimulationService.cs +++ b/OpenSim/Services/Interfaces/ISimulationService.cs | |||
@@ -29,6 +29,8 @@ using System; | |||
29 | using OpenSim.Framework; | 29 | using OpenSim.Framework; |
30 | using OpenMetaverse; | 30 | using OpenMetaverse; |
31 | 31 | ||
32 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
33 | |||
32 | namespace OpenSim.Services.Interfaces | 34 | namespace OpenSim.Services.Interfaces |
33 | { | 35 | { |
34 | public interface ISimulationService | 36 | public interface ISimulationService |
@@ -37,7 +39,7 @@ namespace OpenSim.Services.Interfaces | |||
37 | 39 | ||
38 | #region Agents | 40 | #region Agents |
39 | 41 | ||
40 | bool CreateAgent(ulong regionHandle, AgentCircuitData aCircuit, uint flags, out string reason); | 42 | bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason); |
41 | 43 | ||
42 | /// <summary> | 44 | /// <summary> |
43 | /// Full child agent update. | 45 | /// Full child agent update. |
@@ -45,7 +47,7 @@ namespace OpenSim.Services.Interfaces | |||
45 | /// <param name="regionHandle"></param> | 47 | /// <param name="regionHandle"></param> |
46 | /// <param name="data"></param> | 48 | /// <param name="data"></param> |
47 | /// <returns></returns> | 49 | /// <returns></returns> |
48 | bool UpdateAgent(ulong regionHandle, AgentData data); | 50 | bool UpdateAgent(GridRegion destination, AgentData data); |
49 | 51 | ||
50 | /// <summary> | 52 | /// <summary> |
51 | /// Short child agent update, mostly for position. | 53 | /// Short child agent update, mostly for position. |
@@ -53,9 +55,9 @@ namespace OpenSim.Services.Interfaces | |||
53 | /// <param name="regionHandle"></param> | 55 | /// <param name="regionHandle"></param> |
54 | /// <param name="data"></param> | 56 | /// <param name="data"></param> |
55 | /// <returns></returns> | 57 | /// <returns></returns> |
56 | bool UpdateAgent(ulong regionHandle, AgentPosition data); | 58 | bool UpdateAgent(GridRegion destination, AgentPosition data); |
57 | 59 | ||
58 | bool RetrieveAgent(ulong regionHandle, UUID id, out IAgentData agent); | 60 | bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent); |
59 | 61 | ||
60 | /// <summary> | 62 | /// <summary> |
61 | /// Message from receiving region to departing region, telling it got contacted by the client. | 63 | /// Message from receiving region to departing region, telling it got contacted by the client. |
@@ -65,7 +67,7 @@ namespace OpenSim.Services.Interfaces | |||
65 | /// <param name="id"></param> | 67 | /// <param name="id"></param> |
66 | /// <param name="uri"></param> | 68 | /// <param name="uri"></param> |
67 | /// <returns></returns> | 69 | /// <returns></returns> |
68 | bool ReleaseAgent(ulong regionHandle, UUID id, string uri); | 70 | bool ReleaseAgent(GridRegion destination, UUID id, string uri); |
69 | 71 | ||
70 | /// <summary> | 72 | /// <summary> |
71 | /// Close agent. | 73 | /// Close agent. |
@@ -73,7 +75,7 @@ namespace OpenSim.Services.Interfaces | |||
73 | /// <param name="regionHandle"></param> | 75 | /// <param name="regionHandle"></param> |
74 | /// <param name="id"></param> | 76 | /// <param name="id"></param> |
75 | /// <returns></returns> | 77 | /// <returns></returns> |
76 | bool CloseAgent(ulong regionHandle, UUID id); | 78 | bool CloseAgent(GridRegion destination, UUID id); |
77 | 79 | ||
78 | #endregion Agents | 80 | #endregion Agents |
79 | 81 | ||
@@ -86,7 +88,7 @@ namespace OpenSim.Services.Interfaces | |||
86 | /// <param name="sog"></param> | 88 | /// <param name="sog"></param> |
87 | /// <param name="isLocalCall"></param> | 89 | /// <param name="isLocalCall"></param> |
88 | /// <returns></returns> | 90 | /// <returns></returns> |
89 | bool CreateObject(ulong regionHandle, ISceneObject sog, bool isLocalCall); | 91 | bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall); |
90 | 92 | ||
91 | /// <summary> | 93 | /// <summary> |
92 | /// Create an object from the user's inventory in the destination region. | 94 | /// Create an object from the user's inventory in the destination region. |
@@ -96,7 +98,7 @@ namespace OpenSim.Services.Interfaces | |||
96 | /// <param name="userID"></param> | 98 | /// <param name="userID"></param> |
97 | /// <param name="itemID"></param> | 99 | /// <param name="itemID"></param> |
98 | /// <returns></returns> | 100 | /// <returns></returns> |
99 | bool CreateObject(ulong regionHandle, UUID userID, UUID itemID); | 101 | bool CreateObject(GridRegion destination, UUID userID, UUID itemID); |
100 | 102 | ||
101 | #endregion Objects | 103 | #endregion Objects |
102 | 104 | ||
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs index 82e5ba4..638fa9f 100644 --- a/OpenSim/Services/LLLoginService/LLLoginService.cs +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs | |||
@@ -370,7 +370,7 @@ namespace OpenSim.Services.LLLoginService | |||
370 | aCircuit.SessionID = session; | 370 | aCircuit.SessionID = session; |
371 | aCircuit.startpos = position; | 371 | aCircuit.startpos = position; |
372 | 372 | ||
373 | if (simConnector.CreateAgent(region.RegionHandle, aCircuit, 0, out reason)) | 373 | if (simConnector.CreateAgent(region, aCircuit, 0, out reason)) |
374 | return aCircuit; | 374 | return aCircuit; |
375 | 375 | ||
376 | return null; | 376 | return null; |
diff --git a/bin/config-include/StandaloneHypergrid.ini b/bin/config-include/StandaloneHypergrid.ini index d89029f..5e54cde 100644 --- a/bin/config-include/StandaloneHypergrid.ini +++ b/bin/config-include/StandaloneHypergrid.ini | |||
@@ -19,6 +19,7 @@ | |||
19 | GridServices = "HGGridServicesConnector" | 19 | GridServices = "HGGridServicesConnector" |
20 | PresenceServices = "LocalPresenceServicesConnector" | 20 | PresenceServices = "LocalPresenceServicesConnector" |
21 | UserAccountServices = "LocalUserAccountServicesConnector" | 21 | UserAccountServices = "LocalUserAccountServicesConnector" |
22 | SimulationServices = "RemoteSimulationConnectorModule" | ||
22 | InventoryServiceInConnector = true | 23 | InventoryServiceInConnector = true |
23 | AssetServiceInConnector = true | 24 | AssetServiceInConnector = true |
24 | HGAuthServiceInConnector = true | 25 | HGAuthServiceInConnector = true |