Changed the asynchronous call to get inventory in HG, so that it properly reports problems. OGS1 should also be changed, but I'm leaving it as is for now. RestSessionObjectPosterResponse is fairly broken and should not be used.
Minor changes in Get inventory item in HGAssetMapper.0.6.5-rc1
parent
f73d4f9735
commit
5b103aab89
|
@ -81,30 +81,22 @@ namespace OpenSim.Region.Communications.Hypergrid
|
|||
{
|
||||
m_RequestingInventory.Add(userID, callback);
|
||||
|
||||
string invServer = GetUserInventoryURI(userID);
|
||||
m_log.InfoFormat(
|
||||
"[HGrid INVENTORY SERVICE]: Requesting inventory from {0}/GetInventory/ for user {1} ({2})",
|
||||
/*_inventoryServerUrl*/ invServer, userID, userID.Guid);
|
||||
|
||||
try
|
||||
{
|
||||
string invServer = GetUserInventoryURI(userID);
|
||||
m_log.InfoFormat(
|
||||
"[HGrid INVENTORY SERVICE]: Requesting inventory from {0}/GetInventory/ for user {1} ({2})",
|
||||
/*_inventoryServerUrl*/ invServer, userID, userID.Guid);
|
||||
|
||||
|
||||
RestSessionObjectPosterResponse<Guid, InventoryCollection> requester
|
||||
= new RestSessionObjectPosterResponse<Guid, InventoryCollection>();
|
||||
requester.ResponseCallback = InventoryResponse;
|
||||
|
||||
requester.BeginPostObject(invServer + "/GetInventory/", userID.Guid, session_id.ToString(), userID.ToString());
|
||||
|
||||
//Test(userID.Guid);
|
||||
|
||||
//RestObjectPosterResponse<InventoryCollection> requester
|
||||
// = new RestObjectPosterResponse<InventoryCollection>();
|
||||
//RestSessionObjectPosterResponse<Guid, InventoryCollection> requester
|
||||
// = new RestSessionObjectPosterResponse<Guid, InventoryCollection>();
|
||||
//requester.ResponseCallback = InventoryResponse;
|
||||
|
||||
//requester.BeginPostObject<Guid>(/*_inventoryServerUrl*/ invServer + "/GetInventory/", userID.Guid);
|
||||
//requester.BeginPostObject(invServer + "/GetInventory/", userID.Guid, session_id.ToString(), userID.ToString());
|
||||
GetInventoryDelegate d = GetInventoryAsync;
|
||||
d.BeginInvoke(invServer, userID, session_id, GetInventoryCompleted, d);
|
||||
|
||||
//RestClient cli = new RestClient(invServer + "/GetInventory/" + userID.Guid);
|
||||
//Stream reply = cli.Request();
|
||||
}
|
||||
catch (WebException e)
|
||||
{
|
||||
|
@ -133,6 +125,44 @@ namespace OpenSim.Region.Communications.Hypergrid
|
|||
|
||||
}
|
||||
|
||||
private delegate InventoryCollection GetInventoryDelegate(string url, UUID userID, UUID sessionID);
|
||||
|
||||
protected InventoryCollection GetInventoryAsync(string url, UUID userID, UUID sessionID)
|
||||
{
|
||||
InventoryCollection icol = null;
|
||||
try
|
||||
{
|
||||
icol = SynchronousRestSessionObjectPoster<Guid, InventoryCollection>.BeginPostObject("POST", url + "/GetInventory/",
|
||||
userID.Guid, sessionID.ToString(), userID.ToString());
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Debug("[HGrid]: Exception getting users inventory: " + e.Message);
|
||||
}
|
||||
if (icol == null)
|
||||
{
|
||||
// Well, let's synthesize one
|
||||
icol = new InventoryCollection();
|
||||
icol.UserID = userID;
|
||||
icol.Items = new List<InventoryItemBase>();
|
||||
icol.Folders = new List<InventoryFolderBase>();
|
||||
InventoryFolderBase rootFolder = new InventoryFolderBase();
|
||||
rootFolder.ID = UUID.Random();
|
||||
rootFolder.Owner = userID;
|
||||
icol.Folders.Add(rootFolder);
|
||||
}
|
||||
|
||||
return icol;
|
||||
}
|
||||
|
||||
private void GetInventoryCompleted(IAsyncResult iar)
|
||||
{
|
||||
GetInventoryDelegate icon = (GetInventoryDelegate)iar.AsyncState;
|
||||
InventoryCollection icol = icon.EndInvoke(iar);
|
||||
InventoryResponse(icol);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a new folder to the user's inventory
|
||||
/// </summary>
|
||||
|
@ -460,9 +490,9 @@ namespace OpenSim.Region.Communications.Hypergrid
|
|||
m_log.ErrorFormat("[HGrid INVENTORY SERVICE]: Did not get back an inventory containing a root folder for user {0}", userID);
|
||||
}
|
||||
|
||||
m_RequestingInventory.Remove(userID);
|
||||
callback(folders, items);
|
||||
|
||||
m_RequestingInventory.Remove(userID);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -91,11 +91,11 @@ namespace OpenSim.Region.Framework.Interfaces
|
|||
|
||||
/// <summary>
|
||||
/// Create an object from the user's inventory in the destination region.
|
||||
/// This message is used primarily for prim crossing.
|
||||
/// This message is used primarily by clients.
|
||||
/// </summary>
|
||||
/// <param name="regionHandle"></param>
|
||||
/// <param name="sog"></param>
|
||||
/// <param name="isLocalCall"></param>
|
||||
/// <param name="userID"></param>
|
||||
/// <param name="itemID"></param>
|
||||
/// <returns></returns>
|
||||
bool SendCreateObject(ulong regionHandle, UUID userID, UUID itemID);
|
||||
|
||||
|
|
|
@ -333,29 +333,26 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
|
|||
|
||||
public InventoryItemBase Get(InventoryItemBase item, UUID rootFolder, CachedUserInfo userInfo)
|
||||
{
|
||||
if (!IsLocalUser(item.Owner))
|
||||
InventoryClient invCli = null;
|
||||
string inventoryURL = UserInventoryURL(item.Owner);
|
||||
if (!m_inventoryServers.TryGetValue(inventoryURL, out invCli))
|
||||
{
|
||||
InventoryClient invCli = null;
|
||||
string inventoryURL = UserInventoryURL(item.Owner);
|
||||
if (!m_inventoryServers.TryGetValue(inventoryURL, out invCli))
|
||||
m_log.Debug("[HGScene]: Starting new InventorytClient for " + inventoryURL);
|
||||
invCli = new InventoryClient(inventoryURL);
|
||||
m_inventoryServers.Add(inventoryURL, invCli);
|
||||
}
|
||||
|
||||
item = invCli.GetInventoryItem(item);
|
||||
if (item != null)
|
||||
{
|
||||
// Change the folder, stick it in root folder, all items flattened out here in this region cache
|
||||
item.Folder = rootFolder;
|
||||
//userInfo.AddItem(item); don't use this, it calls back to the inventory server
|
||||
lock (userInfo.RootFolder.Items)
|
||||
{
|
||||
m_log.Debug("[HGScene]: Starting new InventorytClient for " + inventoryURL);
|
||||
invCli = new InventoryClient(inventoryURL);
|
||||
m_inventoryServers.Add(inventoryURL, invCli);
|
||||
userInfo.RootFolder.Items[item.ID] = item;
|
||||
}
|
||||
|
||||
item = invCli.GetInventoryItem(item);
|
||||
if (item != null)
|
||||
{
|
||||
// Change the folder, stick it in root folder, all items flattened out here in this region cache
|
||||
item.Folder = rootFolder;
|
||||
//userInfo.AddItem(item); don't use this, it calls back to the inventory server
|
||||
lock (userInfo.RootFolder.Items)
|
||||
{
|
||||
userInfo.RootFolder.Items[item.ID] = item;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue