예제 #1
0
        public void RegisterCaps(UUID agentID, Caps caps)
        {
            string hostName = m_scene.RegionInfo.ExternalHostName;
            uint   port     = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port;
            string protocol = "http";

            if (MainServer.Instance.UseSSL)
            {
                hostName = MainServer.Instance.SSLCommonName;
                port     = MainServer.Instance.SSLPort;
                protocol = "https";
            }

            string hgassets = null;

            if (m_UserManagement != null)
            {
                hgassets = m_UserManagement.GetUserServerURL(agentID, "AssetServerURI");
            }

            IExternalCapsModule handler = m_scene.RequestModuleInterface <IExternalCapsModule>();
            string baseURL = String.Format("{0}://{1}:{2}", protocol, hostName, port);

            if (m_GetTextureURL == "localhost")
            {
                string capUrl = "/" + UUID.Random();

                // Register this as a poll service
                PollServiceAssetEventArgs args = new PollServiceAssetEventArgs(capUrl, agentID, m_scene, hgassets);

                //args.Type = PollServiceEventArgs.EventType.Texture;
                MainServer.Instance.AddPollServiceHTTPHandler(args);

                if (handler != null)
                {
                    handler.RegisterExternalUserCapsHandler(agentID, caps, "GetTexture", capUrl);
                }
                else
                {
                    caps.RegisterHandler("GetTexture", baseURL + capUrl);
                }
                m_capsDictTexture[agentID] = capUrl;
            }
            else
            {
                caps.RegisterHandler("GetTexture", m_GetTextureURL);
            }

            //GetMesh
            if (m_GetMeshURL == "localhost")
            {
                string capUrl = "/" + UUID.Random();

                PollServiceAssetEventArgs args = new PollServiceAssetEventArgs(capUrl, agentID, m_scene, hgassets);
                //args.Type = PollServiceEventArgs.EventType.Mesh;
                MainServer.Instance.AddPollServiceHTTPHandler(args);

                if (handler != null)
                {
                    handler.RegisterExternalUserCapsHandler(agentID, caps, "GetMesh", capUrl);
                }
                else
                {
                    caps.RegisterHandler("GetMesh", baseURL + capUrl);
                }
                m_capsDictGetMesh[agentID] = capUrl;
            }
            else if (m_GetMeshURL != string.Empty)
            {
                caps.RegisterHandler("GetMesh", m_GetMeshURL);
            }

            //GetMesh2
            if (m_GetMesh2URL == "localhost")
            {
                string capUrl = "/" + UUID.Random();

                PollServiceAssetEventArgs args = new PollServiceAssetEventArgs(capUrl, agentID, m_scene, hgassets);
                //args.Type = PollServiceEventArgs.EventType.Mesh2;
                MainServer.Instance.AddPollServiceHTTPHandler(args);

                if (handler != null)
                {
                    handler.RegisterExternalUserCapsHandler(agentID, caps, "GetMesh2", capUrl);
                }
                else
                {
                    caps.RegisterHandler("GetMesh2", baseURL + capUrl);
                }
                m_capsDictGetMesh2[agentID] = capUrl;
            }
            else if (m_GetMesh2URL != string.Empty)
            {
                caps.RegisterHandler("GetMesh2", m_GetMesh2URL);
            }

            //ViewerAsset
            if (m_GetAssetURL == "localhost")
            {
                string capUrl = "/" + UUID.Random();

                PollServiceAssetEventArgs args = new PollServiceAssetEventArgs(capUrl, agentID, m_scene, hgassets);
                //args.Type = PollServiceEventArgs.EventType.Asset;
                MainServer.Instance.AddPollServiceHTTPHandler(args);

                if (handler != null)
                {
                    handler.RegisterExternalUserCapsHandler(agentID, caps, "ViewerAsset", capUrl);
                }
                else
                {
                    caps.RegisterHandler("ViewerAsset", baseURL + capUrl);
                }
                m_capsDictGetAsset[agentID] = capUrl;
            }
            else if (m_GetAssetURL != string.Empty)
            {
                caps.RegisterHandler("ViewerAsset", m_GetAssetURL);
            }
        }
예제 #2
0
        private void RegisterCaps(UUID agentID, Caps caps)
        {
            if (m_GetTextureURL == "localhost" || m_GetMeshURL == "localhost" ||
                m_GetMesh2URL == "localhost" || m_ViewerAssetURL == "localhost")
            {
                string capUrl = "/CAPS/" + UUID.Random();

                // Register this as a poll service
                PollServiceAssetEventArgs args = new PollServiceAssetEventArgs(agentID, m_scene);

                args.Type = PollServiceEventArgs.EventType.Texture;
                MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args);

                string hostName = m_scene.RegionInfo.ExternalHostName;
                uint   port     = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port;
                string protocol = "http";

                if (MainServer.Instance.UseSSL)
                {
                    hostName = MainServer.Instance.SSLCommonName;
                    port     = MainServer.Instance.SSLPort;
                    protocol = "https";
                }

                IExternalCapsModule handler = m_scene.RequestModuleInterface <IExternalCapsModule>();

                string cap_url = String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl);

                if (handler != null)
                {
                    if (m_GetTextureURL == "localhost")
                    {
                        handler.RegisterExternalUserCapsHandler(agentID, caps, "GetTexture", capUrl);
                    }
                    if (m_GetMeshURL == "localhost")
                    {
                        handler.RegisterExternalUserCapsHandler(agentID, caps, "GetMesh", capUrl);
                    }
                    if (m_GetMesh2URL == "localhost")
                    {
                        handler.RegisterExternalUserCapsHandler(agentID, caps, "GetMesh2", capUrl);
                    }
                    if (m_ViewerAssetURL == "localhost")
                    {
                        handler.RegisterExternalUserCapsHandler(agentID, caps, "ViewerAsset", capUrl);
                    }
                }
                else
                {
                    if (m_GetTextureURL == "localhost")
                    {
                        caps.RegisterHandler("GetTexture", cap_url);
                    }
                    if (m_GetMeshURL == "localhost")
                    {
                        caps.RegisterHandler("GetMesh", cap_url);
                    }
                    if (m_GetMesh2URL == "localhost")
                    {
                        caps.RegisterHandler("GetMesh2", cap_url);
                    }
                    if (m_ViewerAssetURL == "localhost")
                    {
                        caps.RegisterHandler("ViewerAsset", cap_url);
                    }
                }

                m_pollservices[agentID] = args;
                m_capsDict[agentID]     = capUrl;
            }

            if (m_GetTextureURL != "localhost" && !string.IsNullOrWhiteSpace(m_GetTextureURL))
            {
                caps.RegisterHandler("GetTexture", m_GetTextureURL);
            }
            if (m_GetMeshURL != "localhost" && !string.IsNullOrWhiteSpace(m_GetMeshURL))
            {
                caps.RegisterHandler("GetMesh", m_GetMeshURL);
            }
            if (m_GetMesh2URL != "localhost" && !string.IsNullOrWhiteSpace(m_GetMesh2URL))
            {
                caps.RegisterHandler("GetMesh2", m_GetMesh2URL);
            }
            if (m_ViewerAssetURL != "localhost" && !string.IsNullOrWhiteSpace(m_ViewerAssetURL))
            {
                caps.RegisterHandler("ViewerAsset", m_ViewerAssetURL);
            }
        }