* Refactor: Remove redundant userID from further up the inventory request chain

0.6.0-stable
Justin Clarke Casey 2008-05-01 21:22:03 +00:00
parent 1de6cffa28
commit a81edef2b9
4 changed files with 13 additions and 23 deletions

View File

@ -158,7 +158,7 @@ namespace OpenSim.Framework.Communications.Cache
/// </summary> /// </summary>
/// <param name="userID"></param> /// <param name="userID"></param>
/// <param name="inventoryCollection"></param> /// <param name="inventoryCollection"></param>
public void InventoryReceive(LLUUID userID, ICollection<InventoryFolderImpl> folders, ICollection<InventoryItemBase> items) public void InventoryReceive(ICollection<InventoryFolderImpl> folders, ICollection<InventoryItemBase> items)
{ {
// FIXME: Exceptions thrown upwards never appear on the console. Could fix further up if these // FIXME: Exceptions thrown upwards never appear on the console. Could fix further up if these
// are simply being swallowed // are simply being swallowed

View File

@ -34,7 +34,8 @@ namespace OpenSim.Framework.Communications
/// <summary> /// <summary>
/// Callback used when a user's inventory is received from the inventory service /// Callback used when a user's inventory is received from the inventory service
/// </summary> /// </summary>
public delegate void InventoryReceiptCallback(LLUUID userId, ICollection<InventoryFolderImpl> folders, ICollection<InventoryItemBase> items); public delegate void InventoryReceiptCallback(
ICollection<InventoryFolderImpl> folders, ICollection<InventoryItemBase> items);
/// <summary> /// <summary>
/// Defines all the operations one can perform on a user's inventory. /// Defines all the operations one can perform on a user's inventory.

View File

@ -77,7 +77,11 @@ namespace OpenSim.Region.Communications.Local
} }
} }
callback(userID, folders, items); m_log.InfoFormat(
"[LOCAL1 INVENTORY SERVICE]: Received inventory response for user {0} containing {1} folders and {2} items",
userID, folders.Count, items.Count);
callback(folders, items);
} }
public override bool HasInventoryForUser(LLUUID userID) public override bool HasInventoryForUser(LLUUID userID)

View File

@ -44,7 +44,8 @@ namespace OpenSim.Region.Communications.OGS1
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private string _inventoryServerUrl; private string _inventoryServerUrl;
private Dictionary<LLUUID, InventoryRequest> m_RequestingInventory = new Dictionary<LLUUID, InventoryRequest>(); private Dictionary<LLUUID, InventoryReceiptCallback> m_RequestingInventory
= new Dictionary<LLUUID, InventoryReceiptCallback>();
public OGS1InventoryService(string inventoryServerUrl) public OGS1InventoryService(string inventoryServerUrl)
{ {
@ -62,8 +63,7 @@ namespace OpenSim.Region.Communications.OGS1
{ {
if (!m_RequestingInventory.ContainsKey(userID)) if (!m_RequestingInventory.ContainsKey(userID))
{ {
InventoryRequest request = new InventoryRequest(userID, callback); m_RequestingInventory.Add(userID, callback);
m_RequestingInventory.Add(userID, request);
try try
{ {
@ -103,7 +103,7 @@ namespace OpenSim.Region.Communications.OGS1
userID, response.Folders.Count, response.Items.Count); userID, response.Folders.Count, response.Items.Count);
InventoryFolderImpl rootFolder = null; InventoryFolderImpl rootFolder = null;
InventoryRequest request = m_RequestingInventory[userID]; InventoryReceiptCallback callback = m_RequestingInventory[userID];
ICollection<InventoryFolderImpl> folders = new List<InventoryFolderImpl>(); ICollection<InventoryFolderImpl> folders = new List<InventoryFolderImpl>();
ICollection<InventoryItemBase> items = new List<InventoryItemBase>(); ICollection<InventoryItemBase> items = new List<InventoryItemBase>();
@ -139,7 +139,7 @@ namespace OpenSim.Region.Communications.OGS1
m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Did not get back an inventory containing a root folder for user {0}", userID); m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Did not get back an inventory containing a root folder for user {0}", userID);
} }
request.Callback(userID, folders, items); callback(folders, items);
m_RequestingInventory.Remove(userID); m_RequestingInventory.Remove(userID);
} }
@ -289,20 +289,5 @@ namespace OpenSim.Region.Communications.OGS1
} }
#endregion #endregion
/// <summary>
/// Caches a pending inventory request that has yet to be satisfied by the inventory service
/// </summary>
public class InventoryRequest
{
public LLUUID UserID;
public InventoryReceiptCallback Callback;
public InventoryRequest(LLUUID userId, InventoryReceiptCallback callback)
{
UserID = userId;
Callback = callback;
}
}
} }
} }