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
diva 2009-04-05 22:39:19 +00:00
parent f73d4f9735
commit 5b103aab89
3 changed files with 68 additions and 41 deletions

View File

@ -81,30 +81,22 @@ namespace OpenSim.Region.Communications.Hypergrid
{ {
m_RequestingInventory.Add(userID, callback); 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 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
RestSessionObjectPosterResponse<Guid, InventoryCollection> requester // = new RestSessionObjectPosterResponse<Guid, InventoryCollection>();
= 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>();
//requester.ResponseCallback = InventoryResponse; //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) 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> /// <summary>
/// Add a new folder to the user's inventory /// Add a new folder to the user's inventory
/// </summary> /// </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_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); callback(folders, items);
m_RequestingInventory.Remove(userID);
} }
else else
{ {

View File

@ -91,11 +91,11 @@ namespace OpenSim.Region.Framework.Interfaces
/// <summary> /// <summary>
/// Create an object from the user's inventory in the destination region. /// 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> /// </summary>
/// <param name="regionHandle"></param> /// <param name="regionHandle"></param>
/// <param name="sog"></param> /// <param name="userID"></param>
/// <param name="isLocalCall"></param> /// <param name="itemID"></param>
/// <returns></returns> /// <returns></returns>
bool SendCreateObject(ulong regionHandle, UUID userID, UUID itemID); bool SendCreateObject(ulong regionHandle, UUID userID, UUID itemID);

View File

@ -333,29 +333,26 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
public InventoryItemBase Get(InventoryItemBase item, UUID rootFolder, CachedUserInfo userInfo) 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; m_log.Debug("[HGScene]: Starting new InventorytClient for " + inventoryURL);
string inventoryURL = UserInventoryURL(item.Owner); invCli = new InventoryClient(inventoryURL);
if (!m_inventoryServers.TryGetValue(inventoryURL, out invCli)) 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); userInfo.RootFolder.Items[item.ID] = item;
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)
{
userInfo.RootFolder.Items[item.ID] = item;
}
}
} }
return item; return item;
} }