mirror of
https://github.com/opensim/opensim.git
synced 2026-08-07 17:55:48 +08:00
* Change inventory async response deliver to deliver all items and folders at once, rather than each individual
* This is required in order to work towards eliminating some inventory race conditions and to better deal with situations where a grid inventory server is slow or not responding.
This commit is contained in:
@@ -118,64 +118,82 @@ namespace OpenSim.Framework.Communications.Cache
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Callback invoked when the inventory is received from an async request to the inventory service
|
||||
/// </summary>
|
||||
/// <param name="userID"></param>
|
||||
/// <param name="inventoryCollection"></param>
|
||||
public void InventoryReceive(LLUUID userID, ICollection<InventoryFolderImpl> folders, ICollection<InventoryItemBase> items)
|
||||
{
|
||||
// FIXME: Exceptions thrown upwards never appear on the console. Could fix further up if these
|
||||
// are simply being swallowed
|
||||
try
|
||||
{
|
||||
foreach (InventoryFolderImpl folder in folders)
|
||||
{
|
||||
FolderReceive(userID, folder);
|
||||
}
|
||||
|
||||
foreach (InventoryItemBase item in items)
|
||||
{
|
||||
ItemReceive(userID, item);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[INVENTORY CACHE]: {0}", e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Callback invoked when a folder is received from an async request to the inventory service.
|
||||
/// </summary>
|
||||
/// <param name="userID"></param>
|
||||
/// <param name="folderInfo"></param>
|
||||
public void FolderReceive(LLUUID userID, InventoryFolderImpl folderInfo)
|
||||
private void FolderReceive(LLUUID userID, InventoryFolderImpl folderInfo)
|
||||
{
|
||||
// FIXME: Exceptions thrown upwards never appear on the console. Could fix further up if these
|
||||
// are simply being swallowed
|
||||
try
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[INVENTORY CACHE]: Received folder {0} {1} for user {2}",
|
||||
// folderInfo.name, folderInfo.folderID, userID);
|
||||
|
||||
if (userID == UserProfile.ID)
|
||||
|
||||
if (userID == UserProfile.ID)
|
||||
{
|
||||
if (RootFolder == null)
|
||||
{
|
||||
if (RootFolder == null)
|
||||
if (folderInfo.ParentID == LLUUID.Zero)
|
||||
{
|
||||
if (folderInfo.ParentID == LLUUID.Zero)
|
||||
{
|
||||
m_rootFolder = folderInfo;
|
||||
}
|
||||
m_rootFolder = folderInfo;
|
||||
}
|
||||
else if (RootFolder.ID == folderInfo.ParentID)
|
||||
}
|
||||
else if (RootFolder.ID == folderInfo.ParentID)
|
||||
{
|
||||
if (!RootFolder.SubFolders.ContainsKey(folderInfo.ID))
|
||||
{
|
||||
if (!RootFolder.SubFolders.ContainsKey(folderInfo.ID))
|
||||
{
|
||||
RootFolder.SubFolders.Add(folderInfo.ID, folderInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddPendingFolder(folderInfo);
|
||||
}
|
||||
RootFolder.SubFolders.Add(folderInfo.ID, folderInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
InventoryFolderImpl folder = RootFolder.HasSubFolder(folderInfo.ParentID);
|
||||
if (folder != null)
|
||||
AddPendingFolder(folderInfo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
InventoryFolderImpl folder = RootFolder.HasSubFolder(folderInfo.ParentID);
|
||||
if (folder != null)
|
||||
{
|
||||
if (!folder.SubFolders.ContainsKey(folderInfo.ID))
|
||||
{
|
||||
if (!folder.SubFolders.ContainsKey(folderInfo.ID))
|
||||
{
|
||||
folder.SubFolders.Add(folderInfo.ID, folderInfo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AddPendingFolder(folderInfo);
|
||||
folder.SubFolders.Add(folderInfo.ID, folderInfo);
|
||||
}
|
||||
}
|
||||
|
||||
ResolvePendingFolders(folderInfo);
|
||||
else
|
||||
{
|
||||
AddPendingFolder(folderInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[INVENTORY CACHE] {0}", e);
|
||||
|
||||
ResolvePendingFolders(folderInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +205,7 @@ namespace OpenSim.Framework.Communications.Cache
|
||||
/// </summary>
|
||||
/// <param name="userID"></param>
|
||||
/// <param name="folderInfo"></param>
|
||||
public void ItemReceive(LLUUID userID, InventoryItemBase itemInfo)
|
||||
private void ItemReceive(LLUUID userID, InventoryItemBase itemInfo)
|
||||
{
|
||||
if ((userID == UserProfile.ID) && (RootFolder != null))
|
||||
{
|
||||
@@ -212,6 +230,11 @@ namespace OpenSim.Framework.Communications.Cache
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add an item to the user's inventory
|
||||
/// </summary>
|
||||
/// <param name="userID"></param>
|
||||
/// <param name="itemInfo"></param>
|
||||
public void AddItem(LLUUID userID, InventoryItemBase itemInfo)
|
||||
{
|
||||
if ((userID == UserProfile.ID) && HasInventory)
|
||||
@@ -221,6 +244,11 @@ namespace OpenSim.Framework.Communications.Cache
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update an item in the user's inventory
|
||||
/// </summary>
|
||||
/// <param name="userID"></param>
|
||||
/// <param name="itemInfo"></param>
|
||||
public void UpdateItem(LLUUID userID, InventoryItemBase itemInfo)
|
||||
{
|
||||
if ((userID == UserProfile.ID) && HasInventory)
|
||||
@@ -229,6 +257,12 @@ namespace OpenSim.Framework.Communications.Cache
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete an item from the user's inventory
|
||||
/// </summary>
|
||||
/// <param name="userID"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
public bool DeleteItem(LLUUID userID, InventoryItemBase item)
|
||||
{
|
||||
bool result = false;
|
||||
@@ -240,6 +274,7 @@ namespace OpenSim.Framework.Communications.Cache
|
||||
m_commsManager.InventoryService.DeleteInventoryItem(userID, item);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace OpenSim.Framework.Communications.Cache
|
||||
CachedUserInfo userInfo = GetUserDetails(userID);
|
||||
if (userInfo != null)
|
||||
{
|
||||
m_commsManager.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive);
|
||||
m_commsManager.InventoryService.RequestInventoryForUser(userID, userInfo.InventoryReceive);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -118,6 +118,14 @@ namespace OpenSim.Framework.Communications.Cache
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle an inventory folder creation request from the client.
|
||||
/// </summary>
|
||||
/// <param name="remoteClient"></param>
|
||||
/// <param name="folderID"></param>
|
||||
/// <param name="folderType"></param>
|
||||
/// <param name="folderName"></param>
|
||||
/// <param name="parentID"></param>
|
||||
public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType,
|
||||
string folderName, LLUUID parentID)
|
||||
{
|
||||
@@ -189,6 +197,12 @@ namespace OpenSim.Framework.Communications.Cache
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle an inventory folder move request from the client.
|
||||
/// </summary>
|
||||
/// <param name="remoteClient"></param>
|
||||
/// <param name="folderID"></param>
|
||||
/// <param name="parentID"></param>
|
||||
public void HandleMoveInventoryFolder(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID)
|
||||
{
|
||||
CachedUserInfo userProfile;
|
||||
|
||||
@@ -26,21 +26,34 @@
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
using libsecondlife;
|
||||
|
||||
using OpenSim.Framework.Communications.Cache;
|
||||
|
||||
namespace OpenSim.Framework.Communications
|
||||
{
|
||||
public delegate void InventoryFolderInfo(LLUUID userID, InventoryFolderImpl folderInfo);
|
||||
/// <summary>
|
||||
/// Callback used when a user's inventory is received from the inventory service
|
||||
/// </summary>
|
||||
public delegate void InventoryReceiptCallback(LLUUID userId, ICollection<InventoryFolderImpl> folders, ICollection<InventoryItemBase> items);
|
||||
|
||||
//public delegate void InventoryFolderInfo(LLUUID userID, InventoryFolderImpl folderInfo);
|
||||
|
||||
public delegate void InventoryItemInfo(LLUUID userID, InventoryItemBase itemInfo);
|
||||
//public delegate void InventoryItemInfo(LLUUID userID, InventoryItemBase itemInfo);
|
||||
|
||||
/// <summary>
|
||||
/// Defines all the operations one can perform on a user's inventory.
|
||||
/// </summary>
|
||||
public interface IInventoryServices
|
||||
{
|
||||
void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack);
|
||||
/// <summary>
|
||||
/// Request the inventory for a user. This is an asynchronous operation that will call the callback when the
|
||||
/// inventory has been received
|
||||
/// </summary>
|
||||
/// <param name="userID"></param>
|
||||
/// <param name="callback"></param>
|
||||
void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback);
|
||||
|
||||
/// <summary>
|
||||
/// Add a new folder to the given user's inventory
|
||||
|
||||
@@ -158,8 +158,9 @@ namespace OpenSim.Framework.Communications
|
||||
return false;
|
||||
}
|
||||
|
||||
public abstract void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack,
|
||||
InventoryItemInfo itemCallBack);
|
||||
// See IInventoryServices
|
||||
public abstract void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback);
|
||||
|
||||
public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder);
|
||||
public abstract void MoveExistingInventoryFolder(InventoryFolderBase folder);
|
||||
public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item);
|
||||
|
||||
@@ -32,6 +32,9 @@ using libsecondlife;
|
||||
|
||||
namespace OpenSim.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to serialize a whole inventory for transfer over the network.
|
||||
/// </summary>
|
||||
public class InventoryCollection
|
||||
{
|
||||
public List<InventoryFolderBase> _folders;
|
||||
|
||||
Reference in New Issue
Block a user