Пример #1
0
 public AgentInventoryApi.AgentInventory GetLibraryInventory(
     ScriptInstance instance,
     ViewerAgentAccessor agent,
     int circuitCode,
     LSLKey libraryAgentId,
     LSLKey rootFolderID,
     HashtableApi.Hashtable seedResponse) =>
 GetLibraryInventory(instance, agent, circuitCode, libraryAgentId, rootFolderID, seedResponse, VC_AGENT_INVENTORY_FULL_AISV3);
Пример #2
0
        public HashtableApi.Hashtable CapsUpdateTaskInventory(ScriptInstance instance, string uri, LSLKey objectid, LSLKey itemid, string contentType, ByteArrayApi.ByteArray assetData)
        {
            HashtableApi.Hashtable res = new HashtableApi.Hashtable();
            lock (instance)
            {
                Map result;
                using (Stream s = new HttpClient.Post(uri,
                                                      new HttpClient.LlsdXmlRequest(new Map
                {
                    { "task_id", objectid.AsUUID },
                    { "item_id", itemid.AsUUID },
                }))
                {
                    TimeoutMs = 20000
                }.ExecuteStreamRequest())
                {
                    result = (Map)LlsdXml.Deserialize(s);
                }

                res["result"] = result["state"].ToString();
                if (result["state"].ToString() == "upload")
                {
                    string uploader_uri = res["uploader"].ToString();

                    using (Stream s = new HttpClient.Post(
                               uploader_uri,
                               contentType,
                               assetData.Length, (Stream sd) => sd.Write(assetData.Data, 0, assetData.Length))
                    {
                        TimeoutMs = 20000
                    }.ExecuteStreamRequest())
                    {
                        result = (Map)LlsdXml.Deserialize(s);
                    }
                    res["result"] = result["state"].ToString();
                    if (result["state"].ToString() == "complete")
                    {
                        res["assetid"] = new LSLKey(result["new_asset"].AsUUID);
                    }
                    if (result.ContainsKey("compiled"))
                    {
                        res["compiled"] = ((bool)result["compiled"].AsBoolean).ToLSLBoolean();
                    }
                    if (result.ContainsKey("errors"))
                    {
                        res.Add("errors", (AnArray)result["errors"]);
                    }
                }
            }

            return(res);
        }
Пример #3
0
        public HashtableApi.Hashtable SeedRequest(
            ScriptInstance instance,
            string seedCaps,
            AnArray elements)
        {
            lock (instance)
            {
                byte[] post;

                using (var ms = new MemoryStream())
                {
                    LlsdXml.Serialize(elements, ms);
                    post = ms.ToArray();
                }

                Map resdata;

                try
                {
                    using (Stream res = new HttpClient.Post(seedCaps, "application/llsd+xml", post.Length, (Stream req) => req.Write(post, 0, post.Length)).ExecuteStreamRequest())
                    {
                        resdata = LlsdXml.Deserialize(res) as Map;
                    }
                }
                catch
                {
                    return(new HashtableApi.Hashtable());
                }

                if (null == resdata)
                {
                    return(new HashtableApi.Hashtable());
                }

                var result = new HashtableApi.Hashtable();
                foreach (KeyValuePair <string, IValue> kvp in resdata)
                {
                    result.Add(kvp.Key, kvp.Value);
                }
                return(result);
            }
        }
Пример #4
0
        public AgentInventoryApi.AgentInventory GetAgentInventory(
            ScriptInstance instance,
            ViewerAgentAccessor agent,
            LSLKey rootFolderID,
            HashtableApi.Hashtable seedResponse,
            int inventoryOption)
        {
            lock (instance)
            {
                ViewerConnection vc;
                ViewerCircuit    viewerCircuit;
                if (m_Clients.TryGetValue(agent.AgentID, out vc) &&
                    vc.ViewerCircuits.TryGetValue((uint)agent.CircuitCode, out viewerCircuit))
                {
                    IValue value;
                    string aisv3_agent_uri                      = seedResponse.TryGetValue("InventoryAPIv3", out value) ? value.ToString() : string.Empty;
                    string fetchinventory2_agent_uri            = seedResponse.TryGetValue("FetchInventory2", out value) ? value.ToString() : string.Empty;
                    string fetchinventorydescendents2_agent_uri = seedResponse.TryGetValue("FetchInventoryDescendents2", out value) ? value.ToString() : string.Empty;
                    string createinventorycategory_agent_uri    = seedResponse.TryGetValue("CreateInventoryCategory", out value) ? value.ToString() : string.Empty;

                    if (inventoryOption >= VC_AGENT_INVENTORY_FULL_AISV3 && !string.IsNullOrEmpty(aisv3_agent_uri))
                    {
                        return(new AgentInventoryApi.AgentInventory(instance, new AISv3ClientConnector(aisv3_agent_uri), new UGUI(viewerCircuit.AgentID), false));
                    }

                    if (inventoryOption >= VC_AGENT_INVENTORY_FETCH_CAPS && !string.IsNullOrEmpty(fetchinventory2_agent_uri) &&
                        !string.IsNullOrEmpty(fetchinventorydescendents2_agent_uri))
                    {
                        if (inventoryOption >= VC_AGENT_INVENTORY_FETCH_AND_CREATE_CAPS && !string.IsNullOrEmpty(createinventorycategory_agent_uri))
                        {
                            return(new AgentInventoryApi.AgentInventory(instance, new InventoryV2Client(viewerCircuit, fetchinventorydescendents2_agent_uri, fetchinventory2_agent_uri, createinventorycategory_agent_uri, rootFolderID), new UGUI(viewerCircuit.AgentID), false));
                        }

                        return(new AgentInventoryApi.AgentInventory(instance, new InventoryV2Client(viewerCircuit, fetchinventorydescendents2_agent_uri, fetchinventory2_agent_uri, rootFolderID), new UGUI(viewerCircuit.AgentID), false));
                    }

                    return(new AgentInventoryApi.AgentInventory(instance, new LLUDPInventoryClient(viewerCircuit, rootFolderID), new UGUI(viewerCircuit.AgentID), false));
                }

                return(new AgentInventoryApi.AgentInventory());
            }
        }
Пример #5
0
 public AgentInventoryApi.AgentInventory GetAgentInventory(
     ScriptInstance instance,
     ViewerAgentAccessor agent,
     LSLKey rootFolderID,
     HashtableApi.Hashtable seedResponse) =>
 GetAgentInventory(instance, agent, rootFolderID, seedResponse, VC_AGENT_INVENTORY_FULL_AISV3);