Exemplo n.º 1
0
        public void SerializeURI()
        {
            OSD llsdUri = OSD.FromUri(new Uri("http://www.testurl.test/"));

            byte[] binaryURISerialized = OSDParser.SerializeLLSDBinary(llsdUri);
            Assert.AreEqual(binaryURI, binaryURISerialized);
        }
Exemplo n.º 2
0
        private void SceneStartHandler(IScene scene)
        {
            #region Scene Registration

            Uri publicSeedCap;
            if (scene.TryGetPublicCapability("public_region_seed_capability", out publicSeedCap))
            {
                scene.ExtraData["PublicSeedCapability"] = OSD.FromUri(publicSeedCap);
            }
            else
            {
                m_log.Warn("Registering scene " + scene.Name + " with the grid service without a public seed capability");
            }

            NameValueCollection requestArgs = new NameValueCollection
            {
                { "RequestMethod", "AddScene" },
                { "SceneID", scene.ID.ToString() },
                { "Name", scene.Name },
                { "MinPosition", scene.MinPosition.ToString() },
                { "MaxPosition", scene.MaxPosition.ToString() },
                { "Address", m_httpServer.HttpAddress.AbsoluteUri },
                { "Enabled", "1" },
                { "ExtraData", OSDParser.SerializeJsonString(scene.ExtraData) }
            };

            OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
            if (!response["Success"].AsBoolean())
            {
                m_log.Warn("Region registration for " + scene.Name + " failed: " + response["Message"].AsString());
            }

            #endregion Scene Registration
        }
        public static OSDMap FromDictionaryUri(Dictionary <Uri, Uri> dict)
        {
            if (dict != null)
            {
                OSDMap map = new OSDMap(dict.Count);
                foreach (KeyValuePair <Uri, Uri> entry in dict)
                {
                    map.Add(entry.Key.ToString(), OSD.FromUri(entry.Value));
                }
                return(map);
            }

            return(new OSDMap(0));
        }
Exemplo n.º 4
0
        private void SendRegionOnline(SceneInfo neighbor)
        {
            // Build the region/online message
            uint regionX, regionY;

            GetRegionXY(m_scene.MinPosition, out regionX, out regionY);

            OSDMap regionOnline = new OSDMap
            {
                { "region_id", OSD.FromUUID(m_scene.ID) },
                { "region_name", OSD.FromString(m_scene.Name) },
                { "region_x", OSD.FromInteger(regionX) },
                { "region_y", OSD.FromInteger(regionY) }
            };

            // Put our public region seed capability into the message
            Uri publicSeedCap;

            if (m_scene.TryGetPublicCapability("public_region_seed_capability", out publicSeedCap))
            {
                regionOnline["public_region_seed_capability"] = OSD.FromUri(publicSeedCap);
            }
            else
            {
                m_log.Warn("Registering scene " + m_scene.Name + " with neighbor " + neighbor.Name + " without a public seed capability");
            }

            // Send the hello notification
            Uri regionOnlineCap;

            if (neighbor.TryGetCapability("region/online", out regionOnlineCap))
            {
                try
                {
                    UntrustedHttpWebRequest.PostToUntrustedUrl(regionOnlineCap, OSDParser.SerializeJsonString(regionOnline));
                    //m_log.Debug(scene.Name + " sent region/online to " + curScene.Name);
                }
                catch (Exception ex)
                {
                    m_log.Warn(m_scene.Name + " failed to send region/online to " + neighbor.Name + ": " +
                               ex.Message);
                }
            }
            else
            {
                m_log.Warn("No region/online capability found for " + neighbor.Name + ", " +
                           m_scene.Name + " is skipping it");
            }
        }
Exemplo n.º 5
0
        public void SerializeURI()
        {
            Uri    uriOne    = new Uri("http://test.org/test test>\\\"/&yes\"", UriKind.RelativeOrAbsolute);
            OSD    llsdOne   = OSD.FromUri(uriOne);
            string sUriOne   = OSDParser.SerializeLLSDNotation(llsdOne);
            OSD    llsdOneDS = OSDParser.DeserializeLLSDNotation(sUriOne);

            Assert.AreEqual(OSDType.URI, llsdOneDS.Type);
            Assert.AreEqual(uriOne, llsdOneDS.AsUri());

            Uri    uriTwo    = new Uri("test/test/near/the/end?test=1", UriKind.RelativeOrAbsolute);
            OSD    llsdTwo   = OSD.FromUri(uriTwo);
            string sUriTwo   = OSDParser.SerializeLLSDNotation(llsdTwo);
            OSD    llsdTwoDS = OSDParser.DeserializeLLSDNotation(sUriTwo);

            Assert.AreEqual(OSDType.URI, llsdTwoDS.Type);
            Assert.AreEqual(uriTwo, llsdTwoDS.AsUri());
        }
Exemplo n.º 6
0
        private void FillOutRezAgentResponse(User user, Uri seedCapability, Vector3 startPosition, Vector3 lookAt, ref OSDMap responseMap)
        {
            IPAddress externalAddress = m_lludp.MasqueradeAddress ?? m_lludp.Address;
            uint      regionX, regionY;

            GetRegionXY(m_scene.MinPosition, out regionX, out regionY);

            responseMap["connect"]  = OSD.FromBoolean(true);
            responseMap["agent_id"] = OSD.FromUUID(user.ID);
            responseMap["sim_host"] = OSD.FromString(externalAddress.ToString());
            responseMap["sim_port"] = OSD.FromInteger(m_lludp.Port);
            responseMap["region_seed_capability"] = OSD.FromUri(seedCapability);
            responseMap["position"] = OSD.FromVector3(startPosition);
            responseMap["look_at"]  = OSD.FromVector3(lookAt);

            // Region information
            responseMap["region_id"] = OSD.FromUUID(m_scene.ID);
            responseMap["region_x"]  = OSD.FromInteger(regionX);
            responseMap["region_y"]  = OSD.FromInteger(regionY);
        }
Exemplo n.º 7
0
        private void PublicSeedHandler(IHttpClientContext context, IHttpRequest request, IHttpResponse response)
        {
            OSDMap responseMap = new OSDMap();

            // Return all of the public capabilities for this region
            OSDMap capabilities = new OSDMap();

            lock (m_publicCapabilities)
            {
                foreach (KeyValuePair <string, Uri> kvp in m_publicCapabilities)
                {
                    if (kvp.Key != "public_region_seed_capability")
                    {
                        capabilities[kvp.Key] = OSD.FromUri(kvp.Value);
                    }
                }
            }

            responseMap["capabilities"] = capabilities;

            WebUtil.SendJSONResponse(response, responseMap);
        }
Exemplo n.º 8
0
        private void SeedCapabilityHandler(Capability cap, IHttpClientContext context, IHttpRequest request, IHttpResponse response)
        {
            OSDArray seedCapRequest = null;

            try { seedCapRequest = OSDParser.Deserialize(request.Body) as OSDArray; }
            catch (Exception ex)
            {
                m_log.Warn("Failed to deserialize incoming seed capability request: " + ex.Message);
                response.Status = HttpStatusCode.BadRequest;
                return;
            }

            if (seedCapRequest != null)
            {
                User user;
                if (m_userClient.TryGetUser(cap.OwnerID, out user))
                {
                    //m_log.Debug("Received a seed capability request from " + user.Name + ": " + OSDParser.SerializeJsonString(seedCapRequest));

                    // Put all of the requested capabilities into a dictionary
                    Dictionary <string, Uri> capabilities = new Dictionary <string, Uri>(seedCapRequest.Count);
                    for (int i = 0; i < seedCapRequest.Count; i++)
                    {
                        capabilities[seedCapRequest[i].AsString()] = null;
                    }

                    // Special handling for EventQueueGet since we set "sendResponseAfterCallback=false" for it
                    m_scene.Capabilities.TryAssignCapability(user.ID, capabilities, false, m_scene.ID, "EventQueueGet");

                    // Create all of the capabilities we support, if they were requested
                    List <string> capNames = new List <string>(capabilities.Keys);
                    foreach (string capName in capNames)
                    {
                        m_scene.Capabilities.TryAssignCapability(user.ID, capabilities, true, m_scene.ID, capName);
                    }

                    // Build the response
                    OSDMap responseMap = new OSDMap(capabilities.Count);
                    foreach (KeyValuePair <string, Uri> kvp in capabilities)
                    {
                        if (kvp.Value != null)
                        {
                            responseMap[kvp.Key] = OSD.FromUri(kvp.Value);
                        }
                    }

                    m_log.Debug("Returning " + responseMap.Count + " capabilities to " + user.Name + " from the seed capability");

                    // Send the response
                    WebUtil.SendXMLResponse(response, responseMap);
                }
                else
                {
                    m_log.Warn("Received a seed capability request from an unknown agent " + cap.OwnerID);
                    response.Status = HttpStatusCode.NotFound;
                }
            }
            else
            {
                m_log.Warn("Failed to deserialize incoming seed capability request");
                response.Status = HttpStatusCode.BadRequest;
            }
        }