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);
|
m_RequestingInventory.Add(userID, callback);
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
string invServer = GetUserInventoryURI(userID);
|
string invServer = GetUserInventoryURI(userID);
|
||||||
m_log.InfoFormat(
|
m_log.InfoFormat(
|
||||||
"[HGrid INVENTORY SERVICE]: Requesting inventory from {0}/GetInventory/ for user {1} ({2})",
|
"[HGrid INVENTORY SERVICE]: Requesting inventory from {0}/GetInventory/ for user {1} ({2})",
|
||||||
/*_inventoryServerUrl*/ invServer, userID, userID.Guid);
|
/*_inventoryServerUrl*/ invServer, userID, userID.Guid);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
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
|
||||||
{
|
{
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
|
|
@ -332,8 +332,6 @@ 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;
|
InventoryClient invCli = null;
|
||||||
string inventoryURL = UserInventoryURL(item.Owner);
|
string inventoryURL = UserInventoryURL(item.Owner);
|
||||||
|
@ -356,7 +354,6 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue