Esempio n. 1
0
        public byte[] HandleFetchLib(Stream request, UUID AgentID)
        {
            try
            {
                //MainConsole.Instance.DebugFormat("[InventoryCAPS]: Received FetchLib request for {0}", AgentID);

                OSDMap requestmap = (OSDMap) OSDParser.DeserializeLLSDXml(request);

                OSDArray foldersrequested = (OSDArray) requestmap["items"];

                OSDMap map = new OSDMap {{"agent_id", OSD.FromUUID(AgentID)}};
                OSDArray items = new OSDArray();

                foreach (OSDArray item in foldersrequested.Cast<OSDMap>().Select(requestedFolders => requestedFolders["item_id"].AsUUID()).Select(item_id => m_inventoryService.GetItem(UUID.Zero, item_id)).Where(item => item != null && item.Count > 0))
                {
                    items.Add(item[0]);
                }
                map.Add("items", items);

                byte[] response = OSDParser.SerializeLLSDXmlBytes(map);
                map.Clear();
                return response;
            }
            catch (Exception ex)
            {
                MainConsole.Instance.Warn("[InventoryCaps]: SERIOUS ISSUE! " + ex);
            }
            OSDMap rmap = new OSDMap();
            rmap["items"] = new OSDArray();
            return OSDParser.SerializeLLSDXmlBytes(rmap);
        }
Esempio n. 2
0
        public byte[] HandleFetchInventory(Stream request, UUID AgentID)
        {
            try
            {
                //MainConsole.Instance.DebugFormat("[InventoryCAPS]: Received FetchInventory request for {0}", AgentID);

                OSDMap requestmap = (OSDMap) OSDParser.DeserializeLLSDXml(request);
                if (requestmap["items"].Type == OSDType.Unknown)
                    return MainServer.BadRequest;
                OSDArray foldersrequested = (OSDArray) requestmap["items"];

                OSDMap map = new OSDMap {{"agent_id", OSD.FromUUID(AgentID)}};
                //We have to send the agent_id in the main map as well as all the items

                OSDArray items = new OSDArray();
#if (!ISWIN)
                foreach (OSDMap requestedFolders in foldersrequested)
                {
                    UUID itemId = requestedFolders["item_id"].AsUUID();
                    OSDArray item = m_inventoryService.GetItem(itemId);
                    if (item != null && item.Count > 0)
                    {
                        items.Add(item[0]);
                    }
                }
#else
                foreach (OSDArray item in foldersrequested.Cast<OSDMap>().Select(requestedFolders => requestedFolders["item_id"].AsUUID()).Select(item_id => m_inventoryService.GetItem(item_id)).Where(item => item != null && item.Count > 0))
                {
                    items.Add(item[0]);
                }
#endif
                map.Add("items", items);

                byte[] response = OSDParser.SerializeLLSDXmlBytes(map);
                map.Clear();
                return response;
            }
            catch (Exception ex)
            {
                MainConsole.Instance.Warn("[InventoryCaps]: SERIOUS ISSUE! " + ex);
            }
            OSDMap rmap = new OSDMap();
            rmap["items"] = new OSDArray();
            return OSDParser.SerializeLLSDXmlBytes(rmap);
        }
        public byte [] HandleFetchLib (Stream request, UUID agentID)
        {
            try {
                //MainConsole.Instance.DebugFormat("[InventoryCAPS]: Received FetchLib request for {0}", agentID);
                OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml (HttpServerHandlerHelpers.ReadFully (request));
                if (requestmap ["items"].Type == OSDType.Unknown) {
                    MainConsole.Instance.Error ("[InventoryCAPS]: Call to 'FetchLib' with missing 'items' parameter");
                    return MainServer.BadRequest;
                }
                OSDArray foldersrequested = (OSDArray)requestmap ["items"];
                OSDMap map = new OSDMap { { "agent_id", OSD.FromUUID (agentID) } };
                OSDArray items = new OSDArray ();

                foreach (
                    OSDArray item in
                        foldersrequested.Cast<OSDMap> ()
                                        .Select (requestedFolders => requestedFolders ["item_id"].AsUUID ())
                                        .Select (item_id => m_inventoryService.GetOSDItem (UUID.Zero, item_id))
                                        .Where (item => item != null && item.Count > 0)) {
                    items.Add (item [0]);
                }
                map.Add ("items", items);

                byte [] response = OSDParser.SerializeLLSDXmlBytes (map);
                map.Clear ();
                return response;

            } catch (Exception ex) {
                MainConsole.Instance.Warn ("[InventoryCAPS]: SERIOUS ISSUE! " + ex);
            }

            OSDMap rmap = new OSDMap ();
            rmap ["items"] = new OSDArray ();
            return OSDParser.SerializeLLSDXmlBytes (rmap);
        }
Esempio n. 4
0
        /// <summary>
        /// Serialize all the registered Components into a string to be saved later
        /// </summary>
        /// <param name="obj">The object to serialize</param>
        /// <returns>The serialized string</returns>
        public string SerializeComponents (ISceneChildEntity obj)
        {
            OSDMap ComponentsBody = new OSDMap();
            //Run through the list of components and serialize them
            foreach (IComponent component in m_components.Values)
            {
                //Add the componet to the map by its name
                OSD o = component.GetState(obj.UUID, true);
                if(o != null && o.Type != OSDType.Unknown)
                    ComponentsBody.Add(component.Name, o);
            }
            string result = OSDParser.SerializeJsonString(ComponentsBody);
            ComponentsBody.Clear();

            return result;
        }
Esempio n. 5
0
        /// <summary>
        /// Serialize all the registered Components into a string to be saved later
        /// </summary>
        /// <param name="obj">The object to serialize</param>
        /// <returns>The serialized string</returns>
        public string SerializeComponents(SceneObjectPart obj)
        {
            OSDMap ComponentsBody = new OSDMap();
            //Run through the list of components and serialize them
            foreach (IComponent component in m_components.Values)
            {
                //Add the componet to the map by its name
                OSD o = component.GetState(obj.UUID);
                if(o != null)
                    ComponentsBody.Add(component.Name, o);
            }
            string result = OSDParser.SerializeJsonString(ComponentsBody);
            ComponentsBody.Clear();

            return result;
        }