aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Tests/Common/Helpers/SceneHelpers.cs292
1 files changed, 197 insertions, 95 deletions
diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
index 318758d..dc24418 100644
--- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
@@ -58,57 +58,74 @@ namespace OpenSim.Tests.Common
58 /// </summary> 58 /// </summary>
59 public class SceneHelpers 59 public class SceneHelpers
60 { 60 {
61 public static TestScene SetupScene() 61 /// <summary>
62 /// We need a scene manager so that test clients can retrieve a scene when performing teleport tests.
63 /// </summary>
64 public SceneManager SceneManager { get; private set; }
65
66 private AgentCircuitManager m_acm = new AgentCircuitManager();
67 private ISimulationDataService m_simDataService
68 = OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null);
69 private IEstateDataService m_estateDataService;
70
71 private LocalAssetServicesConnector m_assetService;
72 private LocalAuthenticationServicesConnector m_authenticationService;
73 private LocalInventoryServicesConnector m_inventoryService;
74 private LocalGridServicesConnector m_gridService;
75 private LocalUserAccountServicesConnector m_userAccountService;
76 private LocalPresenceServicesConnector m_presenceService;
77
78 private CoreAssetCache m_cache;
79
80 public SceneHelpers() : this(null) {}
81
82 public SceneHelpers(CoreAssetCache cache)
62 { 83 {
63 return SetupScene(null); 84 SceneManager = new SceneManager();
85
86 m_assetService = StartAssetService(cache);
87 m_authenticationService = StartAuthenticationService();
88 m_inventoryService = StartInventoryService();
89 m_gridService = StartGridService();
90 m_userAccountService = StartUserAccountService();
91 m_presenceService = StartPresenceService();
92
93 m_inventoryService.PostInitialise();
94 m_assetService.PostInitialise();
95 m_userAccountService.PostInitialise();
96 m_presenceService.PostInitialise();
97
98 m_cache = cache;
64 } 99 }
65 100
66 /// <summary> 101 /// <summary>
67 /// Set up a test scene 102 /// Set up a test scene
68 /// </summary> 103 /// </summary>
69 /// <remarks> 104 /// <remarks>
70 /// Automatically starts service threads, as would the normal runtime. 105 /// Automatically starts services, as would the normal runtime.
71 /// </remarks> 106 /// </remarks>
72 /// <returns></returns> 107 /// <returns></returns>
73 public static TestScene SetupScene(CoreAssetCache cache) 108 public TestScene SetupScene()
74 { 109 {
75 return SetupScene("Unit test region", UUID.Random(), 1000, 1000, cache); 110 return SetupScene("Unit test region", UUID.Random(), 1000, 1000);
76 } 111 }
77 112
78 public static TestScene SetupScene(string name, UUID id, uint x, uint y) 113 public TestScene SetupScene(string name, UUID id, uint x, uint y)
79 { 114 {
80 return SetupScene(name, id, x, y, null); 115 return SetupScene(name, id, x, y, new IniConfigSource());
81 } 116 }
82 117
83 /// <summary> 118 /// <summary>
84 /// Set up a scene. If it's more then one scene, use the same CommunicationsManager to link regions 119 /// Set up a scene.
85 /// or a different, to get a brand new scene with new shared region modules.
86 /// </summary> 120 /// </summary>
87 /// <param name="name">Name of the region</param> 121 /// <param name="name">Name of the region</param>
88 /// <param name="id">ID of the region</param> 122 /// <param name="id">ID of the region</param>
89 /// <param name="x">X co-ordinate of the region</param> 123 /// <param name="x">X co-ordinate of the region</param>
90 /// <param name="y">Y co-ordinate of the region</param> 124 /// <param name="y">Y co-ordinate of the region</param>
91 /// <param name="cache"></param>
92 /// <returns></returns>
93 public static TestScene SetupScene(
94 string name, UUID id, uint x, uint y, CoreAssetCache cache)
95 {
96 return SetupScene(name, id, x, y, cache, new IniConfigSource());
97 }
98
99 /// <summary>
100 /// Set up a scene. If it's more then one scene, use the same CommunicationsManager to link regions
101 /// or a different, to get a brand new scene with new shared region modules.
102 /// </summary>
103 /// <param name="name">Name of the region</param>
104 /// <param name="id">ID of the region</param>
105 /// <param name="x">X co-ordinate of the region</param>
106 /// <param name="y">Y co-ordinate of the region</param>
107 /// <param name="cache"></param>
108 /// <param name="configSource"></param> 125 /// <param name="configSource"></param>
109 /// <returns></returns> 126 /// <returns></returns>
110 public static TestScene SetupScene( 127 public TestScene SetupScene(
111 string name, UUID id, uint x, uint y, CoreAssetCache cache, IConfigSource configSource) 128 string name, UUID id, uint x, uint y, IConfigSource configSource)
112 { 129 {
113 Console.WriteLine("Setting up test scene {0}", name); 130 Console.WriteLine("Setting up test scene {0}", name);
114 131
@@ -119,30 +136,47 @@ namespace OpenSim.Tests.Common
119 regInfo.RegionName = name; 136 regInfo.RegionName = name;
120 regInfo.RegionID = id; 137 regInfo.RegionID = id;
121 138
122 AgentCircuitManager acm = new AgentCircuitManager();
123 SceneCommunicationService scs = new SceneCommunicationService(); 139 SceneCommunicationService scs = new SceneCommunicationService();
124 140
125 ISimulationDataService simDataService = OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null);
126 IEstateDataService estateDataService = null;
127
128 TestScene testScene = new TestScene( 141 TestScene testScene = new TestScene(
129 regInfo, acm, scs, simDataService, estateDataService, null, false, configSource, null); 142 regInfo, m_acm, scs, m_simDataService, m_estateDataService, null, false, configSource, null);
130 143
131 IRegionModule godsModule = new GodsModule(); 144 IRegionModule godsModule = new GodsModule();
132 godsModule.Initialise(testScene, new IniConfigSource()); 145 godsModule.Initialise(testScene, new IniConfigSource());
133 testScene.AddModule(godsModule.Name, godsModule); 146 testScene.AddModule(godsModule.Name, godsModule);
134 147
135 LocalAssetServicesConnector assetService = StartAssetService(testScene, cache); 148 // Add scene to services
136 StartAuthenticationService(testScene); 149 m_assetService.AddRegion(testScene);
137 LocalInventoryServicesConnector inventoryService = StartInventoryService(testScene); 150
138 StartGridService(testScene); 151 if (m_cache != null)
139 LocalUserAccountServicesConnector userAccountService = StartUserAccountService(testScene); 152 {
140 LocalPresenceServicesConnector presenceService = StartPresenceService(testScene); 153 m_cache.AddRegion(testScene);
141 154 m_cache.RegionLoaded(testScene);
142 inventoryService.PostInitialise(); 155 testScene.AddRegionModule(m_cache.Name, m_cache);
143 assetService.PostInitialise(); 156 }
144 userAccountService.PostInitialise(); 157
145 presenceService.PostInitialise(); 158 m_assetService.RegionLoaded(testScene);
159 testScene.AddRegionModule(m_assetService.Name, m_assetService);
160
161 m_authenticationService.AddRegion(testScene);
162 m_authenticationService.RegionLoaded(testScene);
163 testScene.AddRegionModule(m_authenticationService.Name, m_authenticationService);
164
165 m_inventoryService.AddRegion(testScene);
166 m_inventoryService.RegionLoaded(testScene);
167 testScene.AddRegionModule(m_inventoryService.Name, m_inventoryService);
168
169 m_gridService.AddRegion(testScene);
170 m_gridService.RegionLoaded(testScene);
171 testScene.AddRegionModule(m_gridService.Name, m_gridService);
172
173 m_userAccountService.AddRegion(testScene);
174 m_userAccountService.RegionLoaded(testScene);
175 testScene.AddRegionModule(m_userAccountService.Name, m_userAccountService);
176
177 m_presenceService.AddRegion(testScene);
178 m_presenceService.RegionLoaded(testScene);
179 testScene.AddRegionModule(m_presenceService.Name, m_presenceService);
146 180
147 testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random(); 181 testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random();
148 testScene.SetModuleInterfaces(); 182 testScene.SetModuleInterfaces();
@@ -153,28 +187,28 @@ namespace OpenSim.Tests.Common
153 PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager(); 187 PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager();
154 physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll"); 188 physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll");
155 testScene.PhysicsScene 189 testScene.PhysicsScene
156 = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test"); 190 = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test");
157 191
158 testScene.RegionInfo.EstateSettings = new EstateSettings(); 192 testScene.RegionInfo.EstateSettings = new EstateSettings();
159 testScene.LoginsDisabled = false; 193 testScene.LoginsDisabled = false;
160 testScene.RegisterRegionWithGrid(); 194 testScene.RegisterRegionWithGrid();
161 195
196 SceneManager.Add(testScene);
197
162 return testScene; 198 return testScene;
163 } 199 }
164 200
165 private static LocalAssetServicesConnector StartAssetService(Scene testScene, CoreAssetCache cache) 201 private static LocalAssetServicesConnector StartAssetService(CoreAssetCache cache)
166 { 202 {
167 LocalAssetServicesConnector assetService = new LocalAssetServicesConnector();
168 IConfigSource config = new IniConfigSource(); 203 IConfigSource config = new IniConfigSource();
169
170 config.AddConfig("Modules"); 204 config.AddConfig("Modules");
171 config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector"); 205 config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector");
172 config.AddConfig("AssetService"); 206 config.AddConfig("AssetService");
173 config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); 207 config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService");
174 config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); 208 config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");
175 209
210 LocalAssetServicesConnector assetService = new LocalAssetServicesConnector();
176 assetService.Initialise(config); 211 assetService.Initialise(config);
177 assetService.AddRegion(testScene);
178 212
179 if (cache != null) 213 if (cache != null)
180 { 214 {
@@ -184,56 +218,43 @@ namespace OpenSim.Tests.Common
184 cacheConfig.AddConfig("AssetCache"); 218 cacheConfig.AddConfig("AssetCache");
185 219
186 cache.Initialise(cacheConfig); 220 cache.Initialise(cacheConfig);
187 cache.AddRegion(testScene);
188 cache.RegionLoaded(testScene);
189 testScene.AddRegionModule(cache.Name, cache);
190 } 221 }
191
192 assetService.RegionLoaded(testScene);
193 testScene.AddRegionModule(assetService.Name, assetService);
194 222
195 return assetService; 223 return assetService;
196 } 224 }
197 225
198 private static void StartAuthenticationService(Scene testScene) 226 private static LocalAuthenticationServicesConnector StartAuthenticationService()
199 { 227 {
200 ISharedRegionModule service = new LocalAuthenticationServicesConnector();
201 IConfigSource config = new IniConfigSource(); 228 IConfigSource config = new IniConfigSource();
202
203 config.AddConfig("Modules"); 229 config.AddConfig("Modules");
204 config.AddConfig("AuthenticationService"); 230 config.AddConfig("AuthenticationService");
205 config.Configs["Modules"].Set("AuthenticationServices", "LocalAuthenticationServicesConnector"); 231 config.Configs["Modules"].Set("AuthenticationServices", "LocalAuthenticationServicesConnector");
206 config.Configs["AuthenticationService"].Set( 232 config.Configs["AuthenticationService"].Set(
207 "LocalServiceModule", "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService"); 233 "LocalServiceModule", "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService");
208 config.Configs["AuthenticationService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); 234 config.Configs["AuthenticationService"].Set("StorageProvider", "OpenSim.Data.Null.dll");
209 235
236 LocalAuthenticationServicesConnector service = new LocalAuthenticationServicesConnector();
210 service.Initialise(config); 237 service.Initialise(config);
211 service.AddRegion(testScene); 238
212 service.RegionLoaded(testScene); 239 return service;
213 testScene.AddRegionModule(service.Name, service);
214 //m_authenticationService = service;
215 } 240 }
216 241
217 private static LocalInventoryServicesConnector StartInventoryService(Scene testScene) 242 private static LocalInventoryServicesConnector StartInventoryService()
218 { 243 {
219 LocalInventoryServicesConnector inventoryService = new LocalInventoryServicesConnector();
220
221 IConfigSource config = new IniConfigSource(); 244 IConfigSource config = new IniConfigSource();
222 config.AddConfig("Modules"); 245 config.AddConfig("Modules");
223 config.AddConfig("InventoryService"); 246 config.AddConfig("InventoryService");
224 config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector"); 247 config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector");
225 config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:InventoryService"); 248 config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:InventoryService");
226 config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); 249 config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");
227 250
251 LocalInventoryServicesConnector inventoryService = new LocalInventoryServicesConnector();
228 inventoryService.Initialise(config); 252 inventoryService.Initialise(config);
229 inventoryService.AddRegion(testScene);
230 inventoryService.RegionLoaded(testScene);
231 testScene.AddRegionModule(inventoryService.Name, inventoryService);
232 253
233 return inventoryService; 254 return inventoryService;
234 } 255 }
235 256
236 private static LocalGridServicesConnector StartGridService(Scene testScene) 257 private static LocalGridServicesConnector StartGridService()
237 { 258 {
238 IConfigSource config = new IniConfigSource(); 259 IConfigSource config = new IniConfigSource();
239 config.AddConfig("Modules"); 260 config.AddConfig("Modules");
@@ -245,8 +266,6 @@ namespace OpenSim.Tests.Common
245 266
246 LocalGridServicesConnector gridService = new LocalGridServicesConnector(); 267 LocalGridServicesConnector gridService = new LocalGridServicesConnector();
247 gridService.Initialise(config); 268 gridService.Initialise(config);
248 gridService.AddRegion(testScene);
249 gridService.RegionLoaded(testScene);
250 269
251 return gridService; 270 return gridService;
252 } 271 }
@@ -256,7 +275,7 @@ namespace OpenSim.Tests.Common
256 /// </summary> 275 /// </summary>
257 /// <param name="testScene"></param> 276 /// <param name="testScene"></param>
258 /// <returns></returns> 277 /// <returns></returns>
259 private static LocalUserAccountServicesConnector StartUserAccountService(Scene testScene) 278 private static LocalUserAccountServicesConnector StartUserAccountService()
260 { 279 {
261 IConfigSource config = new IniConfigSource(); 280 IConfigSource config = new IniConfigSource();
262 config.AddConfig("Modules"); 281 config.AddConfig("Modules");
@@ -268,10 +287,6 @@ namespace OpenSim.Tests.Common
268 287
269 LocalUserAccountServicesConnector userAccountService = new LocalUserAccountServicesConnector(); 288 LocalUserAccountServicesConnector userAccountService = new LocalUserAccountServicesConnector();
270 userAccountService.Initialise(config); 289 userAccountService.Initialise(config);
271
272 userAccountService.AddRegion(testScene);
273 userAccountService.RegionLoaded(testScene);
274 testScene.AddRegionModule(userAccountService.Name, userAccountService);
275 290
276 return userAccountService; 291 return userAccountService;
277 } 292 }
@@ -280,7 +295,7 @@ namespace OpenSim.Tests.Common
280 /// Start a presence service 295 /// Start a presence service
281 /// </summary> 296 /// </summary>
282 /// <param name="testScene"></param> 297 /// <param name="testScene"></param>
283 private static LocalPresenceServicesConnector StartPresenceService(Scene testScene) 298 private static LocalPresenceServicesConnector StartPresenceService()
284 { 299 {
285 IConfigSource config = new IniConfigSource(); 300 IConfigSource config = new IniConfigSource();
286 config.AddConfig("Modules"); 301 config.AddConfig("Modules");
@@ -292,10 +307,6 @@ namespace OpenSim.Tests.Common
292 307
293 LocalPresenceServicesConnector presenceService = new LocalPresenceServicesConnector(); 308 LocalPresenceServicesConnector presenceService = new LocalPresenceServicesConnector();
294 presenceService.Initialise(config); 309 presenceService.Initialise(config);
295
296 presenceService.AddRegion(testScene);
297 presenceService.RegionLoaded(testScene);
298 testScene.AddRegionModule(presenceService.Name, presenceService);
299 310
300 return presenceService; 311 return presenceService;
301 } 312 }
@@ -313,19 +324,52 @@ namespace OpenSim.Tests.Common
313 /// <summary> 324 /// <summary>
314 /// Setup modules for a scene. 325 /// Setup modules for a scene.
315 /// </summary> 326 /// </summary>
316 /// <param name="scene"></param> 327 /// <remarks>
328 /// If called directly, then all the modules must be shared modules.
329 /// </remarks>
330 /// <param name="scenes"></param>
317 /// <param name="config"></param> 331 /// <param name="config"></param>
318 /// <param name="modules"></param> 332 /// <param name="modules"></param>
319 public static void SetupSceneModules(Scene scene, IConfigSource config, params object[] modules) 333 public static void SetupSceneModules(Scene scene, IConfigSource config, params object[] modules)
320 { 334 {
335 SetupSceneModules(new Scene[] { scene }, config, modules);
336 }
337
338 /// <summary>
339 /// Setup modules for a scene using their default settings.
340 /// </summary>
341 /// <param name="scenes"></param>
342 /// <param name="modules"></param>
343 public static void SetupSceneModules(Scene[] scenes, params object[] modules)
344 {
345 SetupSceneModules(scenes, new IniConfigSource(), modules);
346 }
347
348 /// <summary>
349 /// Setup modules for scenes.
350 /// </summary>
351 /// <remarks>
352 /// If called directly, then all the modules must be shared modules.
353 /// </remarks>
354 /// <param name="scenes"></param>
355 /// <param name="config"></param>
356 /// <param name="modules"></param>
357 public static void SetupSceneModules(Scene[] scenes, IConfigSource config, params object[] modules)
358 {
321 List<IRegionModuleBase> newModules = new List<IRegionModuleBase>(); 359 List<IRegionModuleBase> newModules = new List<IRegionModuleBase>();
322 foreach (object module in modules) 360 foreach (object module in modules)
323 { 361 {
362// Console.WriteLine("MODULE RAW {0}", module);
324 if (module is IRegionModule) 363 if (module is IRegionModule)
325 { 364 {
326 IRegionModule m = (IRegionModule)module; 365 IRegionModule m = (IRegionModule)module;
327 m.Initialise(scene, config); 366
328 scene.AddModule(m.Name, m); 367 foreach (Scene scene in scenes)
368 {
369 m.Initialise(scene, config);
370 scene.AddModule(m.Name, m);
371 }
372
329 m.PostInitialise(); 373 m.PostInitialise();
330 } 374 }
331 else if (module is IRegionModuleBase) 375 else if (module is IRegionModuleBase)
@@ -333,6 +377,7 @@ namespace OpenSim.Tests.Common
333 // for the new system, everything has to be initialised first, 377 // for the new system, everything has to be initialised first,
334 // shared modules have to be post-initialised, then all get an AddRegion with the scene 378 // shared modules have to be post-initialised, then all get an AddRegion with the scene
335 IRegionModuleBase m = (IRegionModuleBase)module; 379 IRegionModuleBase m = (IRegionModuleBase)module;
380// Console.WriteLine("MODULE {0}", m.Name);
336 m.Initialise(config); 381 m.Initialise(config);
337 newModules.Add(m); 382 newModules.Add(m);
338 } 383 }
@@ -345,15 +390,19 @@ namespace OpenSim.Tests.Common
345 390
346 foreach (IRegionModuleBase module in newModules) 391 foreach (IRegionModuleBase module in newModules)
347 { 392 {
348 module.AddRegion(scene); 393 foreach (Scene scene in scenes)
349 scene.AddRegionModule(module.Name, module); 394 {
395 module.AddRegion(scene);
396 scene.AddRegionModule(module.Name, module);
397 }
350 } 398 }
351 399
352 // RegionLoaded is fired after all modules have been appropriately added to all scenes 400 // RegionLoaded is fired after all modules have been appropriately added to all scenes
353 foreach (IRegionModuleBase module in newModules) 401 foreach (IRegionModuleBase module in newModules)
354 module.RegionLoaded(scene); 402 foreach (Scene scene in scenes)
403 module.RegionLoaded(scene);
355 404
356 scene.SetModuleInterfaces(); 405 foreach (Scene scene in scenes) { scene.SetModuleInterfaces(); }
357 } 406 }
358 407
359 /// <summary> 408 /// <summary>
@@ -388,6 +437,10 @@ namespace OpenSim.Tests.Common
388 /// <summary> 437 /// <summary>
389 /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test 438 /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test
390 /// </summary> 439 /// </summary>
440 /// <remarks>
441 /// This can be used for tests where there is only one region or where there are multiple non-neighbour regions
442 /// and teleport doesn't take place.
443 /// </remarks>
391 /// <param name="scene"></param> 444 /// <param name="scene"></param>
392 /// <param name="agentId"></param> 445 /// <param name="agentId"></param>
393 /// <returns></returns> 446 /// <returns></returns>
@@ -397,6 +450,18 @@ namespace OpenSim.Tests.Common
397 } 450 }
398 451
399 /// <summary> 452 /// <summary>
453 /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test
454 /// </summary>
455 /// <param name="scene"></param>
456 /// <param name="agentId"></param>
457 /// <param name="sceneManager"></param>
458 /// <returns></returns>
459 public static ScenePresence AddScenePresence(Scene scene, UUID agentId, SceneManager sceneManager)
460 {
461 return AddScenePresence(scene, GenerateAgentData(agentId), sceneManager);
462 }
463
464 /// <summary>
400 /// Add a root agent. 465 /// Add a root agent.
401 /// </summary> 466 /// </summary>
402 /// <remarks> 467 /// <remarks>
@@ -416,6 +481,30 @@ namespace OpenSim.Tests.Common
416 /// <returns></returns> 481 /// <returns></returns>
417 public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData) 482 public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData)
418 { 483 {
484 return AddScenePresence(scene, agentData, null);
485 }
486
487 /// <summary>
488 /// Add a root agent.
489 /// </summary>
490 /// <remarks>
491 /// This function
492 ///
493 /// 1) Tells the scene that an agent is coming. Normally, the login service (local if standalone, from the
494 /// userserver if grid) would give initial login data back to the client and separately tell the scene that the
495 /// agent was coming.
496 ///
497 /// 2) Connects the agent with the scene
498 ///
499 /// This function performs actions equivalent with notifying the scene that an agent is
500 /// coming and then actually connecting the agent to the scene. The one step missed out is the very first
501 /// </remarks>
502 /// <param name="scene"></param>
503 /// <param name="agentData"></param>
504 /// <param name="sceneManager"></param>
505 /// <returns></returns>
506 public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData, SceneManager sceneManager)
507 {
419 // We emulate the proper login sequence here by doing things in four stages 508 // We emulate the proper login sequence here by doing things in four stages
420 509
421 // Stage 0: login 510 // Stage 0: login
@@ -425,7 +514,7 @@ namespace OpenSim.Tests.Common
425 lpsc.m_PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID); 514 lpsc.m_PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID);
426 515
427 // Stages 1 & 2 516 // Stages 1 & 2
428 ScenePresence sp = IntroduceClientToScene(scene, agentData, TeleportFlags.ViaLogin); 517 ScenePresence sp = IntroduceClientToScene(scene, sceneManager, agentData, TeleportFlags.ViaLogin);
429 518
430 // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent. 519 // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent.
431 sp.CompleteMovement(sp.ControllingClient, true); 520 sp.CompleteMovement(sp.ControllingClient, true);
@@ -433,7 +522,20 @@ namespace OpenSim.Tests.Common
433 return sp; 522 return sp;
434 } 523 }
435 524
436 private static ScenePresence IntroduceClientToScene(Scene scene, AgentCircuitData agentData, TeleportFlags tf) 525 /// <summary>
526 /// Introduce an agent into the scene by adding a new client.
527 /// </summary>
528 /// <returns>The scene presence added</returns>
529 /// <param name='sceneManager'>
530 /// Scene manager. Can be null if there is only one region in the test or multiple regions that are not
531 /// neighbours and where no teleporting takes place.
532 /// </param>
533 /// <param name='scene'></param>
534 /// <param name='sceneManager></param>
535 /// <param name='agentData'></param>
536 /// <param name='tf'></param>
537 private static ScenePresence IntroduceClientToScene(
538 Scene scene, SceneManager sceneManager, AgentCircuitData agentData, TeleportFlags tf)
437 { 539 {
438 string reason; 540 string reason;
439 541
@@ -442,7 +544,7 @@ namespace OpenSim.Tests.Common
442 Console.WriteLine("NewUserConnection failed: " + reason); 544 Console.WriteLine("NewUserConnection failed: " + reason);
443 545
444 // Stage 2: add the new client as a child agent to the scene 546 // Stage 2: add the new client as a child agent to the scene
445 TestClient client = new TestClient(agentData, scene); 547 TestClient client = new TestClient(agentData, scene, sceneManager);
446 scene.AddNewClient(client, PresenceType.User); 548 scene.AddNewClient(client, PresenceType.User);
447 549
448 return scene.GetScenePresence(agentData.AgentID); 550 return scene.GetScenePresence(agentData.AgentID);
@@ -454,7 +556,7 @@ namespace OpenSim.Tests.Common
454 acd.child = true; 556 acd.child = true;
455 557
456 // XXX: ViaLogin may not be correct for child agents 558 // XXX: ViaLogin may not be correct for child agents
457 return IntroduceClientToScene(scene, acd, TeleportFlags.ViaLogin); 559 return IntroduceClientToScene(scene, null, acd, TeleportFlags.ViaLogin);
458 } 560 }
459 561
460 /// <summary> 562 /// <summary>