* Refactor: Move last commit's refactor back to AgentAssetTransactionsManager

* Push asset update (invoked when clothing is altered) down into AgentAssetTransactions from Scene.Inventory.cs to join others
* I've tested that clothing creation and update still works, but please let me know if it suddently breaks for you.
* Add/correct comments
ThreadPoolClientBranch
Justin Clarke Casey 2008-02-13 00:30:51 +00:00
parent 2018cf312b
commit 365cf8e455
4 changed files with 138 additions and 83 deletions

View File

@ -136,6 +136,15 @@ namespace OpenSim.Framework.Communications.Cache
wearableType, nextOwnerMask);
}
}
public void RequestUpdateInventoryItem(IClientAPI remoteClient, LLUUID transactionID,
InventoryItemBase item)
{
if (XferUploaders.ContainsKey(transactionID))
{
XferUploaders[transactionID].RequestUpdateInventoryItem(remoteClient, transactionID, item);
}
}
/// <summary>
/// Get an uploaded asset. If the data is successfully retrieved, the transaction will be removed.
@ -351,6 +360,44 @@ namespace OpenSim.Framework.Communications.Cache
}
}
}
public void RequestUpdateInventoryItem(IClientAPI remoteClient, LLUUID transactionID,
InventoryItemBase item)
{
if (TransactionID == transactionID)
{
CachedUserInfo userInfo =
m_userTransactions.Manager.CommsManager.UserProfileCacheService.GetUserDetails(
remoteClient.AgentId);
if (userInfo != null)
{
LLUUID assetID = LLUUID.Combine(transactionID, remoteClient.SecureSessionId);
AssetBase asset
= m_userTransactions.Manager.CommsManager.AssetCache.GetAsset(
assetID, (item.assetType == (int) AssetType.Texture ? true : false));
if (asset == null)
{
asset = m_userTransactions.GetTransactionAsset(transactionID);
}
if (asset != null && asset.FullID == assetID)
{
asset.Name = item.inventoryName;
asset.Description = item.inventoryDescription;
asset.InvType = (sbyte) item.invType;
asset.Type = (sbyte) item.assetType;
item.assetID = asset.FullID;
m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(Asset);
}
userInfo.UpdateItem(remoteClient.AgentId, item);
}
}
}
private void DoCreateItem()
{

View File

@ -34,7 +34,8 @@ using libsecondlife;
namespace OpenSim.Framework.Communications.Cache
{
/// <summary>
/// Manage the collection of agent asset transaction collections. Each agent has its own transaction collection
/// Provider handlers for processing asset transactions originating from the agent. This encompasses
/// clothing creation and update as well as asset uploads.
/// </summary>
public class AgentAssetTransactionsManager
{
@ -62,34 +63,76 @@ namespace OpenSim.Framework.Communications.Cache
}
/// <summary>
/// Add a collection of asset transactions for the given user
/// Get the collection of asset transactions for the given user. If one does not already exist, it
/// is created.
/// </summary>
/// <param name="userID"></param>
public void AddUser(LLUUID userID)
/// <returns></returns>
private AgentAssetTransactions GetUserTransactions(LLUUID userID)
{
lock (AgentTransactions)
{
if (!AgentTransactions.ContainsKey(userID))
{
AgentAssetTransactions transactions = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile);
AgentTransactions.Add(userID, transactions);
AgentAssetTransactions transactions
= new AgentAssetTransactions(userID, this, m_dumpAssetsToFile);
AgentTransactions.Add(userID, transactions);
}
}
}
/// <summary>
/// Get the collection of asset transactions for the given user.
/// </summary>
/// <param name="userID"></param>
/// <returns>null if this agent does not have an asset transactions collection</returns>
public AgentAssetTransactions GetUserTransactions(LLUUID userID)
{
if (AgentTransactions.ContainsKey(userID))
{
return AgentTransactions[userID];
}
return null;
return AgentTransactions[userID];
}
/// <summary>
/// Create an inventory item from data that has been received through a transaction.
///
/// This is called when new clothing or body parts are created. It may also be called in other
/// situations.
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="transactionID"></param>
/// <param name="folderID"></param>
/// <param name="callbackID"></param>
/// <param name="description"></param>
/// <param name="name"></param>
/// <param name="invType"></param>
/// <param name="type"></param>
/// <param name="wearableType"></param>
/// <param name="nextOwnerMask"></param>
public void HandleItemCreationFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID,
uint callbackID, string description, string name, sbyte invType,
sbyte type, byte wearableType, uint nextOwnerMask)
{
m_log.InfoFormat(
"[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name);
AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
transactions.RequestCreateInventoryItem(
remoteClient, transactionID, folderID, callbackID, description,
name, invType, type, wearableType, nextOwnerMask);
}
/// <summary>
/// Update an inventory item with data that has been received through a transaction.
///
/// This is called when clothing or body parts are updated (for instance, with new textures or
/// colours). It may also be called in other situations.
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="transactionID"></param>
/// <param name="item"></param>
public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, LLUUID transactionID,
InventoryItemBase item)
{
m_log.InfoFormat(
"[TRANSACTIONS MANAGER] Called HandleItemUpdateFromTransaction with item {0}",
item.inventoryName);
AgentAssetTransactions transactions
= CommsManager.TransactionsManager.GetUserTransactions(remoteClient.AgentId);
transactions.RequestUpdateInventoryItem(remoteClient, transactionID, item);
}
public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type,
@ -97,36 +140,39 @@ namespace OpenSim.Framework.Communications.Cache
{
// Console.WriteLine("asset upload of " + assetID);
AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
if (transactions != null)
AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction);
if (uploader != null)
{
AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction);
if (uploader != null)
// Upload has already compelted uploading...
if (uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile))
{
// Upload has already compelted uploading...
if (uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile))
//[commenting out as this removal breaks uploads]
/*lock (transactions.XferUploaders)
{
//[commenting out as this removal breaks uploads]
/*lock (transactions.XferUploaders)
{
// XXX Weak ass way of doing this by directly manipulating this public dictionary, purely temporary
transactions.XferUploaders.Remove(uploader.TransactionID);
//m_log.InfoFormat("[ASSET TRANSACTIONS] Current uploaders: {0}", transactions.XferUploaders.Count);
}*/
}
// XXX Weak ass way of doing this by directly manipulating this public dictionary, purely temporary
transactions.XferUploaders.Remove(uploader.TransactionID);
//m_log.InfoFormat("[ASSET TRANSACTIONS] Current uploaders: {0}", transactions.XferUploaders.Count);
}*/
}
}
}
/// <summary>
/// Conduct an asset transfer from the client.
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="xferID"></param>
/// <param name="packetID"></param>
/// <param name="data"></param>
public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data)
{
AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
if (transactions != null)
{
transactions.HandleXfer(xferID, packetID, data);
}
transactions.HandleXfer(xferID, packetID, data);
}
}
}

View File

@ -253,6 +253,7 @@ namespace OpenSim.Region.Environment.Scenes
if (userInfo != null && userInfo.RootFolder != null)
{
InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
if (item != null)
{
if (LLUUID.Zero == transactionID)
@ -265,34 +266,8 @@ namespace OpenSim.Region.Environment.Scenes
}
else
{
AgentAssetTransactions transactions
= CommsManager.TransactionsManager.GetUserTransactions(remoteClient.AgentId);
if (transactions != null)
{
LLUUID assetID = LLUUID.Combine(transactionID, remoteClient.SecureSessionId);
AssetBase asset
= AssetCache.GetAsset(
assetID, (item.assetType == (int) AssetType.Texture ? true : false));
if (asset == null)
{
asset = transactions.GetTransactionAsset(transactionID);
}
if (asset != null && asset.FullID == assetID)
{
asset.Name = item.inventoryName;
asset.Description = item.inventoryDescription;
asset.InvType = (sbyte) item.invType;
asset.Type = (sbyte) item.assetType;
item.assetID = asset.FullID;
AssetCache.AddAsset(asset);
}
userInfo.UpdateItem(remoteClient.AgentId, item);
}
CommsManager.TransactionsManager.HandleItemUpdateFromTransaction(
remoteClient, transactionID, item);
}
}
else
@ -484,21 +459,9 @@ namespace OpenSim.Region.Environment.Scenes
}
else
{
AgentAssetTransactions transactions
= CommsManager.TransactionsManager.GetUserTransactions(remoteClient.AgentId);
if (transactions != null)
{
transactions.RequestCreateInventoryItem(
remoteClient, transactionID, folderID, callbackID, description,
name, invType, assetType, wearableType, nextOwnerMask);
}
else
{
m_log.ErrorFormat(
"Agent asset transactions for agent {0} uuid {1} in transaction uuid {2} unexpectedly null!",
remoteClient.Name, remoteClient.AgentId, transactionID);
}
CommsManager.TransactionsManager.HandleItemCreationFromTransaction(
remoteClient, transactionID, folderID, callbackID, description,
name, invType, assetType, wearableType, nextOwnerMask);
}
}

View File

@ -1311,7 +1311,6 @@ namespace OpenSim.Region.Environment.Scenes
m_LandManager.sendParcelOverlay(client);
CommsManager.UserProfileCacheService.AddNewUser(client.AgentId);
CommsManager.TransactionsManager.AddUser(client.AgentId);
}
protected virtual void SubscribeToClientEvents(IClientAPI client)