change FetchInventory2 region handler
parent
bfcbdc8a93
commit
7e2ed9ee2b
|
@ -25,12 +25,12 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using System.Net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenMetaverse.StructuredData;
|
using OpenMetaverse.StructuredData;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Capabilities;
|
|
||||||
using OpenSim.Framework.Servers.HttpServer;
|
using OpenSim.Framework.Servers.HttpServer;
|
||||||
using OpenSim.Services.Interfaces;
|
using OpenSim.Services.Interfaces;
|
||||||
using OSDArray = OpenMetaverse.StructuredData.OSDArray;
|
using OSDArray = OpenMetaverse.StructuredData.OSDArray;
|
||||||
|
@ -107,5 +107,51 @@ namespace OpenSim.Capabilities.Handlers
|
||||||
LLSDxmlEncode.AddEndMap(lsl);
|
LLSDxmlEncode.AddEndMap(lsl);
|
||||||
return LLSDxmlEncode.End(lsl);
|
return LLSDxmlEncode.End(lsl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void FetchInventorySimpleRequest(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, OSDMap requestmap)
|
||||||
|
{
|
||||||
|
//m_log.DebugFormat("[FETCH INVENTORY HANDLER]: Received FetchInventory capability request {0}", request);
|
||||||
|
|
||||||
|
OSDArray itemsRequested = (OSDArray)requestmap["items"];
|
||||||
|
|
||||||
|
UUID[] itemIDs = new UUID[itemsRequested.Count];
|
||||||
|
int i = 0;
|
||||||
|
foreach (OSDMap osdItemId in itemsRequested)
|
||||||
|
{
|
||||||
|
itemIDs[i++] = osdItemId["item_id"].AsUUID();
|
||||||
|
}
|
||||||
|
|
||||||
|
InventoryItemBase[] items = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
items = m_inventoryService.GetMultipleItems(m_agentID, itemIDs);
|
||||||
|
}
|
||||||
|
catch{ }
|
||||||
|
|
||||||
|
StringBuilder lsl = LLSDxmlEncode.Start(4096);
|
||||||
|
LLSDxmlEncode.AddMap(lsl);
|
||||||
|
|
||||||
|
LLSDxmlEncode.AddElem("agent_id", m_agentID, lsl);
|
||||||
|
|
||||||
|
if (items == null || items.Length == 0)
|
||||||
|
{
|
||||||
|
LLSDxmlEncode.AddEmptyArray("items", lsl);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LLSDxmlEncode.AddArray("items", lsl);
|
||||||
|
foreach (InventoryItemBase item in items)
|
||||||
|
{
|
||||||
|
if (item != null)
|
||||||
|
item.ToLLSDxml(lsl, 0xff);
|
||||||
|
}
|
||||||
|
LLSDxmlEncode.AddEndArray(lsl);
|
||||||
|
}
|
||||||
|
|
||||||
|
LLSDxmlEncode.AddEndMap(lsl);
|
||||||
|
httpResponse.RawBuffer = Util.UTF8.GetBytes(LLSDxmlEncode.End(lsl));
|
||||||
|
httpResponse.StatusCode = (int)HttpStatusCode.OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,30 +110,15 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
|
|
||||||
private void RegisterCaps(UUID agentID, Caps caps)
|
private void RegisterCaps(UUID agentID, Caps caps)
|
||||||
{
|
{
|
||||||
RegisterFetchCap(agentID, caps, "FetchInventory2", m_fetchInventory2Url);
|
if (m_fetchInventory2Url == "localhost")
|
||||||
}
|
|
||||||
|
|
||||||
private void RegisterFetchCap(UUID agentID, Caps caps, string capName, string url)
|
|
||||||
{
|
{
|
||||||
string capUrl;
|
|
||||||
|
|
||||||
if (url == "localhost")
|
|
||||||
{
|
|
||||||
capUrl = "/CAPS/" + UUID.Random();
|
|
||||||
|
|
||||||
FetchInventory2Handler fetchHandler = new FetchInventory2Handler(m_inventoryService, agentID);
|
FetchInventory2Handler fetchHandler = new FetchInventory2Handler(m_inventoryService, agentID);
|
||||||
|
caps.RegisterSimpleHandler("FetchInventory2",
|
||||||
IRequestHandler reqHandler
|
new SimpleOSDMapHandler("POST", "/" + UUID.Random(), fetchHandler.FetchInventorySimpleRequest));
|
||||||
= new RestStreamHandler(
|
|
||||||
"POST", capUrl, fetchHandler.FetchInventoryRequest, capName, agentID.ToString());
|
|
||||||
|
|
||||||
caps.RegisterHandler(capName, reqHandler);
|
|
||||||
}
|
}
|
||||||
else
|
else if(!string.IsNullOrWhiteSpace(m_fetchInventory2Url))
|
||||||
{
|
{
|
||||||
capUrl = url;
|
caps.RegisterHandler("FetchInventory2", m_fetchInventory2Url);
|
||||||
|
|
||||||
caps.RegisterHandler(capName, capUrl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// m_log.DebugFormat(
|
// m_log.DebugFormat(
|
||||||
|
|
Loading…
Reference in New Issue