Implement the FetchInventoryDescendents2 capability using the same code as WebFetchInventoryDescendents.

Enabling this by setting Cap_FetchInventoryDescendents2 = "localhost" in the [ClientStack.LindenCaps] section of OpenSim.ini downloads inventory via http rather than udp in later viewers.
iar_mods
Justin Clark-Casey (justincc) 2011-11-25 22:46:42 +00:00
parent b785f204ce
commit 676d32974a
3 changed files with 47 additions and 23 deletions

View File

@ -117,7 +117,6 @@ namespace OpenSim.Capabilities.Handlers
response += inventoryitemstr;
}
if (response.Length == 0)
{
// Ter-guess: If requests fail a lot, the client seems to stop requesting descendants.
@ -135,6 +134,7 @@ namespace OpenSim.Capabilities.Handlers
//m_log.Debug("[CAPS] "+response);
}
return response;
}

View File

@ -42,18 +42,24 @@ using OpenSim.Capabilities.Handlers;
namespace OpenSim.Region.ClientStack.Linden
{
/// <summary>
/// This module implements both WebFetchInventoryDescendents and FetchInventoryDescendents2 capabilities.
/// </summary>
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
public class WebFetchInvDescModule : INonSharedRegionModule
{
private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
private IInventoryService m_InventoryService;
private ILibraryService m_LibraryService;
private bool m_Enabled = false;
private string m_URL;
private bool m_Enabled;
private string m_fetchInventoryDescendents2Url;
private string m_webFetchInventoryDescendentsUrl;
#region ISharedRegionModule Members
@ -63,9 +69,10 @@ namespace OpenSim.Region.ClientStack.Linden
if (config == null)
return;
m_URL = config.GetString("Cap_WebFetchInventoryDescendents", string.Empty);
// Cap doesn't exist
if (m_URL != string.Empty)
m_fetchInventoryDescendents2Url = config.GetString("Cap_FetchInventoryDescendents2", string.Empty);
m_webFetchInventoryDescendentsUrl = config.GetString("Cap_WebFetchInventoryDescendents", string.Empty);
if (m_fetchInventoryDescendents2Url != string.Empty || m_webFetchInventoryDescendentsUrl != string.Empty)
m_Enabled = true;
}
@ -111,26 +118,40 @@ namespace OpenSim.Region.ClientStack.Linden
#endregion
public void RegisterCaps(UUID agentID, Caps caps)
private void RegisterCaps(UUID agentID, Caps caps)
{
UUID capID = UUID.Random();
//caps.RegisterHandler("GetTexture", new StreamHandler("GET", "/CAPS/" + capID, ProcessGetTexture));
if (m_URL == "localhost")
if (m_webFetchInventoryDescendentsUrl != "")
RegisterFetchCap(agentID, caps, "WebFetchInventoryDescendents", m_webFetchInventoryDescendentsUrl);
else if (m_fetchInventoryDescendents2Url != "")
RegisterFetchCap(agentID, caps, "FetchInventoryDescendents2", m_fetchInventoryDescendents2Url);
}
private void RegisterFetchCap(UUID agentID, Caps caps, string capName, string url)
{
string capUrl;
if (url == "localhost")
{
m_log.InfoFormat("[WEBFETCHINVENTORYDESCENDANTS]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName);
capUrl = "/CAPS/" + UUID.Random();
WebFetchInvDescHandler webFetchHandler = new WebFetchInvDescHandler(m_InventoryService, m_LibraryService);
IRequestHandler reqHandler = new RestStreamHandler("POST", "/CAPS/" + UUID.Random(), webFetchHandler.FetchInventoryDescendentsRequest);
caps.RegisterHandler("WebFetchInventoryDescendents", reqHandler);
// caps.RegisterHandler("FetchInventoryDescendents2", reqHandler);
IRequestHandler reqHandler
= new RestStreamHandler("POST", capUrl, webFetchHandler.FetchInventoryDescendentsRequest);
caps.RegisterHandler(capName, reqHandler);
}
else
{
m_log.InfoFormat("[WEBFETCHINVENTORYDESCENDANTS]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName);
caps.RegisterHandler("WebFetchInventoryDescendents", m_URL);
// caps.RegisterHandler("FetchInventoryDescendents2", m_URL);
}
}
capUrl = url;
caps.RegisterHandler(capName, capUrl);
}
// m_log.DebugFormat(
// "[WEB FETCH INV DESC MODULE]: Registered capability {0} at {1} in region {2} for {3}",
// capName, capUrl, m_scene.RegionInfo.RegionName, agentID);
}
}
}

View File

@ -573,11 +573,14 @@
Cap_UploadObjectAsset = "localhost"
Cap_ViewerStartAuction = ""
Cap_ViewerStats = ""
; This last one is supported by OpenSim, but may
; lead to poor sim performance if served by the simulators,
; so it is disabled by default.
Cap_WebFetchInventoryDescendents = ""
; The fetch inventory descendents caps are supported by OpenSim, but may
; lead to poor sim performance if served by the simulators,
; so they are disabled by default.
; FetchInventoryDescendents2 is the one used in the latest Linden Lab viewers (from some point in the v2 series and above)
Cap_WebFetchInventoryDescendents = ""
Cap_FetchInventoryDescendents2 = ""
[Chat]
; Controls whether the chat module is enabled. Default is true.