Exemplo n.º 1
0
        private void GetEnvironmentSettings(IOSHttpResponse response, UUID agentID)
        {
            // m_log.DebugFormat("[{0}]: Environment GET handle for agentID {1} in region {2}",
            //      Name, agentID, caps.RegionName);

            ViewerEnvironment VEnv = null;
            ScenePresence     sp   = m_scene.GetScenePresence(agentID);

            if (sp != null && sp.Environment != null)
            {
                VEnv = sp.Environment;
            }
            else
            {
                if (m_scene.RegionInfo.EstateSettings.AllowEnvironmentOverride)
                {
                    ILandObject land = m_scene.LandChannel.GetLandObject(sp.AbsolutePosition.X, sp.AbsolutePosition.Y);
                    if (land != null && land.LandData != null && land.LandData.Environment != null)
                    {
                        VEnv = land.LandData.Environment;
                    }
                }
                if (VEnv == null)
                {
                    VEnv = GetRegionEnvironment();
                }
            }

            //OSD d = VEnv.ToWLOSD(UUID.Zero, regionID);
            //string env = OSDParser.SerializeLLSDXmlString(d);

            //if (String.IsNullOrEmpty(env))
            byte[] envBytes = VEnv.ToCapWLBytes(UUID.Zero, regionID);
            if (envBytes == null)
            {
                StringBuilder sb = LLSDxmlEncode.Start();
                LLSDxmlEncode.AddArray(sb);
                LLSDxmlEncode.AddMap(sb);
                LLSDxmlEncode.AddElem("messageID", UUID.Zero, sb);
                LLSDxmlEncode.AddElem("regionID", regionID, sb);
                LLSDxmlEncode.AddEndMap(sb);
                LLSDxmlEncode.AddEndArray(sb);
                response.RawBuffer = LLSDxmlEncode.EndToNBBytes(sb);
            }
            else
            {
                response.RawBuffer = envBytes;
            }

            response.StatusCode = (int)HttpStatusCode.OK;
        }
Exemplo n.º 2
0
        public Hashtable GetEvents(UUID requestID, UUID pAgentId)
        {
            if (DebugLevel >= 2)
            {
                m_log.WarnFormat("POLLED FOR EQ MESSAGES BY {0} in {1}", pAgentId, m_scene.Name);
            }

            Queue <byte[]> queue = GetQueue(pAgentId);

            if (queue == null)
            {
                return(NoAgent(requestID, pAgentId));
            }

            byte[]        element = null;
            List <byte[]> elements;

            int  totalSize  = 0;
            int  thisID     = 0;
            bool negativeID = false;

            lock (queue)
            {
                if (queue.Count == 0)
                {
                    return(NoEvents(requestID, pAgentId));
                }

                lock (m_ids)
                    thisID = m_ids[pAgentId];

                if (thisID < 0)
                {
                    negativeID = true;
                    thisID     = -thisID;
                }

                elements = new List <byte[]>(queue.Count + 2);
                elements.Add(EventHeader);

                while (queue.Count > 0)
                {
                    element = queue.Dequeue();
                    // add elements until a marker is found
                    // so they get into a response
                    if (element == null)
                    {
                        break;
                    }

                    if (DebugLevel > 0)
                    {
                        LogOutboundDebugMessage(element, pAgentId);
                    }

                    elements.Add(element);
                    totalSize += element.Length;
                }
            }

            lock (m_ids)
            {
                if (element == null && negativeID)
                {
                    Random rnd = new Random(Environment.TickCount);
                    m_ids[pAgentId] = rnd.Next(30000000);
                }
                else
                {
                    m_ids[pAgentId] = thisID + 1;
                }
            }

            if (totalSize == 0)
            {
                return(NoEvents(requestID, pAgentId));
            }

            totalSize += EventHeader.Length;

            StringBuilder sb = new StringBuilder(1024);

            LLSDxmlEncode.AddEndArray(sb); // events array
            LLSDxmlEncode.AddElem("id", thisID, sb);
            LLSDxmlEncode.AddEndMap(sb);
            element = LLSDxmlEncode.EndToNBBytes(sb);
            elements.Add(element);
            totalSize += element.Length;

            Hashtable responsedata = new Hashtable();

            responsedata["int_response_code"] = 200;
            responsedata["content_type"]      = "application/xml";

            //temporary
            byte[] finalData = new byte[totalSize];
            int    dst       = 0;

            for (int i = 0; i < elements.Count; ++i)
            {
                byte[] src = elements[i];
                Array.Copy(src, 0, finalData, dst, src.Length);
                dst += src.Length;
            }

            responsedata["bin_response_data"] = finalData;
            responsedata["keepaliveTimeout"]  = KEEPALIVE;

            return(responsedata);
        }
Exemplo n.º 3
0
        private void GetExtEnvironmentSettings(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, UUID agentID)
        {
            int parcelid = -1;

            if (httpRequest.Query.Count > 0)
            {
                if (httpRequest.Query.ContainsKey("parcelid"))
                {
                    Int32.TryParse((string)httpRequest.Query["parcelid"], out parcelid);
                }
            }

            ViewerEnvironment VEnv = null;
            ScenePresence     sp   = m_scene.GetScenePresence(agentID);

            if (sp != null && sp.Environment != null)
            {
                //if (parcelid == -1)
                VEnv = sp.Environment;
                //else
                //{
                //    OSD def = ViewerEnvironment.DefaultToOSD(regionID, parcelid);
                //    httpResponse.RawBuffer = OSDParser.SerializeLLSDXmlToBytes(def);
                //    httpResponse.StatusCode = (int)HttpStatusCode.OK;
                //    return;
                //}
            }
            else if (parcelid == -1)
            {
                VEnv = GetRegionEnvironment();
            }
            else
            {
                if (m_scene.RegionInfo.EstateSettings.AllowEnvironmentOverride)
                {
                    ILandObject land = m_scene.LandChannel.GetLandObject(parcelid);
                    if (land != null && land.LandData != null && land.LandData.Environment != null)
                    {
                        VEnv = land.LandData.Environment;
                    }
                }
                if (VEnv == null)
                {
                    OSD def = ViewerEnvironment.DefaultToOSD(regionID, parcelid);
                    httpResponse.RawBuffer  = OSDParser.SerializeLLSDXmlToBytes(def);
                    httpResponse.StatusCode = (int)HttpStatusCode.OK;
                    return;
                }
            }

            //OSDMap map = new OSDMap();
            //OSDMap cenv = (OSDMap)VEnv.ToOSD();
            //cenv["parcel_id"] = parcelid;
            //cenv["region_id"] = regionID;
            //map["environment"] = cenv;
            //map["parcel_id"] = parcelid;
            //map["success"] = true;

            //string env = OSDParser.SerializeLLSDXmlString(map);

            //if (String.IsNullOrEmpty(env))
            byte[] envBytes = VEnv.ToCapBytes(regionID, parcelid);
            if (envBytes == null)
            {
                StringBuilder sb = LLSDxmlEncode.Start();
                LLSDxmlEncode.AddArray(sb);
                LLSDxmlEncode.AddMap(sb);
                LLSDxmlEncode.AddElem("messageID", UUID.Zero, sb);
                LLSDxmlEncode.AddElem("regionID", regionID, sb);
                LLSDxmlEncode.AddEndMap(sb);
                LLSDxmlEncode.AddEndArray(sb);
                httpResponse.RawBuffer = LLSDxmlEncode.EndToNBBytes(sb);
            }
            else
            {
                httpResponse.RawBuffer = envBytes;
            }

            httpResponse.StatusCode = (int)HttpStatusCode.OK;
        }