diff options
author | Justin Clark-Casey (justincc) | 2009-08-11 16:45:16 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2009-08-11 16:45:16 +0100 |
commit | 226c082ed417f4a5f2295595e45eca2fcb1e42c9 (patch) | |
tree | 4bbe2f59176589e497a2f4fd16b3adfe3989c5cd | |
parent | Added some needed comments to SceneSetupHelper (actually just retriggering pa... (diff) | |
download | opensim-SC_OLD-226c082ed417f4a5f2295595e45eca2fcb1e42c9.zip opensim-SC_OLD-226c082ed417f4a5f2295595e45eca2fcb1e42c9.tar.gz opensim-SC_OLD-226c082ed417f4a5f2295595e45eca2fcb1e42c9.tar.bz2 opensim-SC_OLD-226c082ed417f4a5f2295595e45eca2fcb1e42c9.tar.xz |
Establish CachedUserInfo.OnInventoryReceived event so that region/test inventory code can be written with the async inventory fetch
4 files changed, 140 insertions, 63 deletions
diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 10aff42..8ee1b1a 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | |||
@@ -49,16 +49,24 @@ namespace OpenSim.Framework.Communications.Cache | |||
49 | IClientAPI client, UUID folderID, bool fetchFolders, bool fetchItems); | 49 | IClientAPI client, UUID folderID, bool fetchFolders, bool fetchItems); |
50 | 50 | ||
51 | public delegate void OnItemReceivedDelegate(UUID itemID); | 51 | public delegate void OnItemReceivedDelegate(UUID itemID); |
52 | public delegate void OnInventoryReceivedDelegate(UUID userID); | ||
52 | 53 | ||
53 | /// <summary> | 54 | /// <summary> |
54 | /// Stores user profile and inventory data received from backend services for a particular user. | 55 | /// Stores user profile and inventory data received from backend services for a particular user. |
55 | /// </summary> | 56 | /// </summary> |
56 | public class CachedUserInfo | 57 | public class CachedUserInfo |
57 | { | 58 | { |
59 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
60 | |||
61 | //// <value> | ||
62 | /// Fired when a particular item has been received from the inventory service | ||
63 | /// </value> | ||
58 | public event OnItemReceivedDelegate OnItemReceived; | 64 | public event OnItemReceivedDelegate OnItemReceived; |
59 | 65 | ||
60 | private static readonly ILog m_log | 66 | /// <value> |
61 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 67 | /// Fired once the entire inventory has been received for the user |
68 | /// </value> | ||
69 | public event OnInventoryReceivedDelegate OnInventoryReceived; | ||
62 | 70 | ||
63 | /// <summary> | 71 | /// <summary> |
64 | /// The comms manager holds references to services (user, grid, inventory, etc.) | 72 | /// The comms manager holds references to services (user, grid, inventory, etc.) |
@@ -133,7 +141,9 @@ namespace OpenSim.Framework.Communications.Cache | |||
133 | UUID parentFolderId = folder.ParentID; | 141 | UUID parentFolderId = folder.ParentID; |
134 | 142 | ||
135 | if (dictionary.ContainsKey(parentFolderId)) | 143 | if (dictionary.ContainsKey(parentFolderId)) |
144 | { | ||
136 | dictionary[parentFolderId].Add(folder); | 145 | dictionary[parentFolderId].Add(folder); |
146 | } | ||
137 | else | 147 | else |
138 | { | 148 | { |
139 | IList<InventoryFolderImpl> folders = new List<InventoryFolderImpl>(); | 149 | IList<InventoryFolderImpl> folders = new List<InventoryFolderImpl>(); |
@@ -299,6 +309,9 @@ namespace OpenSim.Framework.Communications.Cache | |||
299 | request.Execute(); | 309 | request.Execute(); |
300 | } | 310 | } |
301 | } | 311 | } |
312 | |||
313 | if (OnInventoryReceived != null) | ||
314 | OnInventoryReceived(UserProfile.ID); | ||
302 | } | 315 | } |
303 | 316 | ||
304 | /// <summary> | 317 | /// <summary> |
diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 0402883..fe88cf5 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs | |||
@@ -43,6 +43,18 @@ namespace OpenSim.Framework.Communications.Tests | |||
43 | [TestFixture] | 43 | [TestFixture] |
44 | public class UserProfileCacheServiceTests | 44 | public class UserProfileCacheServiceTests |
45 | { | 45 | { |
46 | /// <value>Used by tests to indicate whether an async operation timed out</value> | ||
47 | private bool timedOut; | ||
48 | |||
49 | private void InventoryReceived(UUID userId) | ||
50 | { | ||
51 | lock (this) | ||
52 | { | ||
53 | timedOut = false; | ||
54 | Monitor.PulseAll(this); | ||
55 | } | ||
56 | } | ||
57 | |||
46 | [Test] | 58 | [Test] |
47 | public void TestGetUserDetails() | 59 | public void TestGetUserDetails() |
48 | { | 60 | { |
@@ -118,14 +130,15 @@ namespace OpenSim.Framework.Communications.Tests | |||
118 | TestHelper.InMethod(); | 130 | TestHelper.InMethod(); |
119 | 131 | ||
120 | Scene myScene = SceneSetupHelpers.SetupScene("inventory"); | 132 | Scene myScene = SceneSetupHelpers.SetupScene("inventory"); |
121 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); | 133 | |
122 | for (int i = 0 ; i < 50 ; i++) | 134 | timedOut = true; |
123 | { | 135 | lock (this) |
124 | if (userInfo.HasReceivedInventory == true) | 136 | { |
125 | break; | 137 | UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); |
126 | Thread.Sleep(200); | 138 | Monitor.Wait(this, 60000); |
127 | } | 139 | } |
128 | Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); | 140 | |
141 | Assert.That(timedOut, Is.False, "Timed out"); | ||
129 | } | 142 | } |
130 | 143 | ||
131 | [Test] | 144 | [Test] |
@@ -134,14 +147,13 @@ namespace OpenSim.Framework.Communications.Tests | |||
134 | TestHelper.InMethod(); | 147 | TestHelper.InMethod(); |
135 | 148 | ||
136 | Scene myScene = SceneSetupHelpers.SetupScene("inventory"); | 149 | Scene myScene = SceneSetupHelpers.SetupScene("inventory"); |
137 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); | 150 | CachedUserInfo userInfo; |
138 | for (int i = 0 ; i < 50 ; i++) | 151 | |
139 | { | 152 | lock (this) |
140 | if (userInfo.HasReceivedInventory == true) | 153 | { |
141 | break; | 154 | userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); |
142 | Thread.Sleep(200); | 155 | Monitor.Wait(this, 60000); |
143 | } | 156 | } |
144 | Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); | ||
145 | 157 | ||
146 | UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011"); | 158 | UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011"); |
147 | Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null); | 159 | Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null); |
@@ -156,14 +168,13 @@ namespace OpenSim.Framework.Communications.Tests | |||
156 | TestHelper.InMethod(); | 168 | TestHelper.InMethod(); |
157 | 169 | ||
158 | Scene myScene = SceneSetupHelpers.SetupScene("inventory"); | 170 | Scene myScene = SceneSetupHelpers.SetupScene("inventory"); |
159 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); | 171 | CachedUserInfo userInfo; |
160 | for (int i = 0 ; i < 50 ; i++) | 172 | |
161 | { | 173 | lock (this) |
162 | if (userInfo.HasReceivedInventory == true) | 174 | { |
163 | break; | 175 | userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); |
164 | Thread.Sleep(200); | 176 | Monitor.Wait(this, 60000); |
165 | } | 177 | } |
166 | Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); | ||
167 | 178 | ||
168 | UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010"); | 179 | UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010"); |
169 | Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False); | 180 | Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False); |
@@ -192,14 +203,13 @@ namespace OpenSim.Framework.Communications.Tests | |||
192 | TestHelper.InMethod(); | 203 | TestHelper.InMethod(); |
193 | 204 | ||
194 | Scene myScene = SceneSetupHelpers.SetupScene("inventory"); | 205 | Scene myScene = SceneSetupHelpers.SetupScene("inventory"); |
195 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); | 206 | CachedUserInfo userInfo; |
196 | for (int i = 0 ; i < 50 ; i++) | 207 | |
197 | { | 208 | lock (this) |
198 | if (userInfo.HasReceivedInventory == true) | 209 | { |
199 | break; | 210 | userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); |
200 | Thread.Sleep(200); | 211 | Monitor.Wait(this, 60000); |
201 | } | 212 | } |
202 | Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); | ||
203 | 213 | ||
204 | UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | 214 | UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); |
205 | InventoryFolderImpl rootFolder = userInfo.RootFolder; | 215 | InventoryFolderImpl rootFolder = userInfo.RootFolder; |
@@ -258,14 +268,13 @@ namespace OpenSim.Framework.Communications.Tests | |||
258 | TestHelper.InMethod(); | 268 | TestHelper.InMethod(); |
259 | 269 | ||
260 | Scene myScene = SceneSetupHelpers.SetupScene("inventory"); | 270 | Scene myScene = SceneSetupHelpers.SetupScene("inventory"); |
261 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); | 271 | CachedUserInfo userInfo; |
262 | for (int i = 0 ; i < 50 ; i++) | 272 | |
263 | { | 273 | lock (this) |
264 | if (userInfo.HasReceivedInventory == true) | 274 | { |
265 | break; | 275 | userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); |
266 | Thread.Sleep(200); | 276 | Monitor.Wait(this, 60000); |
267 | } | 277 | } |
268 | Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); | ||
269 | 278 | ||
270 | UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020"); | 279 | UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020"); |
271 | UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000021"); | 280 | UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000021"); |
@@ -299,14 +308,13 @@ namespace OpenSim.Framework.Communications.Tests | |||
299 | //log4net.Config.XmlConfigurator.Configure(); | 308 | //log4net.Config.XmlConfigurator.Configure(); |
300 | 309 | ||
301 | Scene myScene = SceneSetupHelpers.SetupScene("inventory"); | 310 | Scene myScene = SceneSetupHelpers.SetupScene("inventory"); |
302 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); | 311 | CachedUserInfo userInfo; |
303 | for (int i = 0 ; i < 50 ; i++) | 312 | |
304 | { | 313 | lock (this) |
305 | if (userInfo.HasReceivedInventory == true) | 314 | { |
306 | break; | 315 | userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); |
307 | Thread.Sleep(200); | 316 | Monitor.Wait(this, 60000); |
308 | } | 317 | } |
309 | Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); | ||
310 | 318 | ||
311 | UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070"); | 319 | UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070"); |
312 | InventoryFolderImpl rootFolder = userInfo.RootFolder; | 320 | InventoryFolderImpl rootFolder = userInfo.RootFolder; |
@@ -323,4 +331,4 @@ namespace OpenSim.Framework.Communications.Tests | |||
323 | Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Null); | 331 | Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Null); |
324 | } | 332 | } |
325 | } | 333 | } |
326 | } | 334 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 1480512..8ac9b1f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |||
@@ -54,6 +54,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
54 | [TestFixture] | 54 | [TestFixture] |
55 | public class InventoryArchiverTests | 55 | public class InventoryArchiverTests |
56 | { | 56 | { |
57 | private void InventoryReceived(UUID userId) | ||
58 | { | ||
59 | lock (this) | ||
60 | { | ||
61 | Monitor.PulseAll(this); | ||
62 | } | ||
63 | } | ||
64 | |||
57 | private void SaveCompleted( | 65 | private void SaveCompleted( |
58 | bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, Exception reportedException) | 66 | bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, Exception reportedException) |
59 | { | 67 | { |
@@ -61,7 +69,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
61 | { | 69 | { |
62 | Monitor.PulseAll(this); | 70 | Monitor.PulseAll(this); |
63 | } | 71 | } |
64 | } | 72 | } |
65 | 73 | ||
66 | /// <summary> | 74 | /// <summary> |
67 | /// Test saving a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet). | 75 | /// Test saving a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet). |
@@ -82,8 +90,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
82 | string userFirstName = "Jock"; | 90 | string userFirstName = "Jock"; |
83 | string userLastName = "Stirrup"; | 91 | string userLastName = "Stirrup"; |
84 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); | 92 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); |
93 | CachedUserInfo userInfo; | ||
94 | |||
95 | lock (this) | ||
96 | { | ||
97 | userInfo | ||
98 | = UserProfileTestUtils.CreateUserWithInventory( | ||
99 | cm, userFirstName, userLastName, userId, InventoryReceived); | ||
100 | Monitor.Wait(this, 60000); | ||
101 | } | ||
102 | |||
103 | /* | ||
85 | cm.UserAdminService.AddUser(userFirstName, userLastName, string.Empty, string.Empty, 1000, 1000, userId); | 104 | cm.UserAdminService.AddUser(userFirstName, userLastName, string.Empty, string.Empty, 1000, 1000, userId); |
86 | CachedUserInfo userInfo = cm.UserProfileCacheService.GetUserDetails(userId); | 105 | CachedUserInfo userInfo = cm.UserProfileCacheService.GetUserDetails(userId, InventoryReceived); |
87 | userInfo.FetchInventory(); | 106 | userInfo.FetchInventory(); |
88 | for (int i = 0 ; i < 50 ; i++) | 107 | for (int i = 0 ; i < 50 ; i++) |
89 | { | 108 | { |
@@ -92,6 +111,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
92 | Thread.Sleep(200); | 111 | Thread.Sleep(200); |
93 | } | 112 | } |
94 | Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); | 113 | Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); |
114 | */ | ||
95 | 115 | ||
96 | // Create asset | 116 | // Create asset |
97 | SceneObjectGroup object1; | 117 | SceneObjectGroup object1; |
@@ -337,15 +357,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
337 | Assert.That(user2Profile.SurName == user2LastName); | 357 | Assert.That(user2Profile.SurName == user2LastName); |
338 | 358 | ||
339 | CachedUserInfo userInfo | 359 | CachedUserInfo userInfo |
340 | = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); | 360 | = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); |
341 | userInfo.FetchInventory(); | 361 | userInfo.OnInventoryReceived += InventoryReceived; |
342 | for (int i = 0 ; i < 50 ; i++) | 362 | |
363 | lock (this) | ||
343 | { | 364 | { |
344 | if (userInfo.HasReceivedInventory == true) | 365 | userInfo.FetchInventory(); |
345 | break; | 366 | Monitor.Wait(this, 60000); |
346 | Thread.Sleep(200); | ||
347 | } | 367 | } |
348 | Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); | 368 | |
349 | InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName); | 369 | InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName); |
350 | 370 | ||
351 | Assert.That(foundItem.CreatorId, Is.EqualTo(item1.CreatorId)); | 371 | Assert.That(foundItem.CreatorId, Is.EqualTo(item1.CreatorId)); |
@@ -365,8 +385,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
365 | TestHelper.InMethod(); | 385 | TestHelper.InMethod(); |
366 | Scene scene = SceneSetupHelpers.SetupScene(""); | 386 | Scene scene = SceneSetupHelpers.SetupScene(""); |
367 | CommunicationsManager commsManager = scene.CommsManager; | 387 | CommunicationsManager commsManager = scene.CommsManager; |
388 | CachedUserInfo userInfo; | ||
368 | 389 | ||
369 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); | 390 | lock (this) |
391 | { | ||
392 | userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, InventoryReceived); | ||
393 | Monitor.Wait(this, 60000); | ||
394 | } | ||
395 | |||
370 | //userInfo.FetchInventory(); | 396 | //userInfo.FetchInventory(); |
371 | /* | 397 | /* |
372 | for (int i = 0 ; i < 50 ; i++) | 398 | for (int i = 0 ; i < 50 ; i++) |
diff --git a/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs b/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs index fc41166..f146a15 100644 --- a/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs +++ b/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs | |||
@@ -41,28 +41,58 @@ namespace OpenSim.Tests.Common.Setup | |||
41 | /// Create a test user with a standard inventory | 41 | /// Create a test user with a standard inventory |
42 | /// </summary> | 42 | /// </summary> |
43 | /// <param name="commsManager"></param> | 43 | /// <param name="commsManager"></param> |
44 | /// <param name="callback"> | ||
45 | /// Callback to invoke when inventory has been loaded. This is required because | ||
46 | /// loading may be asynchronous, even on standalone | ||
47 | /// </param> | ||
44 | /// <returns></returns> | 48 | /// <returns></returns> |
45 | public static CachedUserInfo CreateUserWithInventory(CommunicationsManager commsManager) | 49 | public static CachedUserInfo CreateUserWithInventory( |
50 | CommunicationsManager commsManager, OnInventoryReceivedDelegate callback) | ||
46 | { | 51 | { |
47 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099"); | 52 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099"); |
48 | return CreateUserWithInventory(commsManager, userId); | 53 | return CreateUserWithInventory(commsManager, userId, callback); |
49 | } | 54 | } |
50 | 55 | ||
51 | /// <summary> | 56 | /// <summary> |
52 | /// Create a test user with a standard inventory | 57 | /// Create a test user with a standard inventory |
53 | /// </summary> | 58 | /// </summary> |
54 | /// <param name="commsManager"></param> | 59 | /// <param name="commsManager"></param> |
55 | /// <param name="userId">Explicit user id to use for user creation</param> | 60 | /// <param name="userId">User ID</param> |
61 | /// <param name="callback"> | ||
62 | /// Callback to invoke when inventory has been loaded. This is required because | ||
63 | /// loading may be asynchronous, even on standalone | ||
64 | /// </param> | ||
56 | /// <returns></returns> | 65 | /// <returns></returns> |
57 | public static CachedUserInfo CreateUserWithInventory(CommunicationsManager commsManager, UUID userId) | 66 | public static CachedUserInfo CreateUserWithInventory( |
67 | CommunicationsManager commsManager, UUID userId, OnInventoryReceivedDelegate callback) | ||
68 | { | ||
69 | return CreateUserWithInventory(commsManager, "Bill", "Bailey", userId, callback); | ||
70 | } | ||
71 | |||
72 | /// <summary> | ||
73 | /// Create a test user with a standard inventory | ||
74 | /// </summary> | ||
75 | /// <param name="commsManager"></param> | ||
76 | /// <param name="firstName">First name of user</param> | ||
77 | /// <param name="lastName">Last name of user</param> | ||
78 | /// <param name="userId">User ID</param> | ||
79 | /// <param name="callback"> | ||
80 | /// Callback to invoke when inventory has been loaded. This is required because | ||
81 | /// loading may be asynchronous, even on standalone | ||
82 | /// </param> | ||
83 | /// <returns></returns> | ||
84 | public static CachedUserInfo CreateUserWithInventory( | ||
85 | CommunicationsManager commsManager, string firstName, string lastName, | ||
86 | UUID userId, OnInventoryReceivedDelegate callback) | ||
58 | { | 87 | { |
59 | LocalUserServices lus = (LocalUserServices)commsManager.UserService; | 88 | LocalUserServices lus = (LocalUserServices)commsManager.UserService; |
60 | lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, userId); | 89 | lus.AddUser(firstName, lastName, "troll", "bill@bailey.com", 1000, 1000, userId); |
61 | 90 | ||
62 | CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); | 91 | CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); |
92 | userInfo.OnInventoryReceived += callback; | ||
63 | userInfo.FetchInventory(); | 93 | userInfo.FetchInventory(); |
64 | 94 | ||
65 | return userInfo; | 95 | return userInfo; |
66 | } | 96 | } |
67 | } | 97 | } |
68 | } | 98 | } |