Пример #1
0
        /// <summary>
        /// Handle a texture request.  This involves creating a texture sender and placing it on the
        /// previously passed in shared queue.
        /// </summary>
        /// <param name="e"></param>
        public void HandleTextureRequest(TextureRequestArgs e)
        {
            TextureSender.TextureSender textureSender;

            //TODO: should be working out the data size/ number of packets to be sent for each discard level
            if ((e.DiscardLevel >= 0) || (e.Priority != 0))
            {
                lock (m_textureSenders)
                {
                    if (m_textureSenders.TryGetValue(e.RequestedAssetID, out textureSender))
                    {
                        // If we've received new non UUID information for this request and it hasn't dispatched
                        // yet, then update the request accordingly.
                        textureSender.UpdateRequest(e.DiscardLevel, e.PacketNumber);
                    }
                    else
                    {
                        //                        m_log.DebugFormat("[TEXTURE]: Received a request for texture {0}", e.RequestedAssetID);

                        if (!foundTextureLimitStrategy.AllowRequest(e.RequestedAssetID))
                        {
                            //                            m_log.DebugFormat(
                            //                                "[TEXTURE]: Refusing request for {0} from client {1}",
                            //                                e.RequestedAssetID, m_client.AgentId);

                            return;
                        }
                        else if (!missingTextureLimitStrategy.AllowRequest(e.RequestedAssetID))
                        {
                            if (missingTextureLimitStrategy.IsFirstRefusal(e.RequestedAssetID))
                            {
                                if (StatsManager.SimExtraStats != null)
                                    StatsManager.SimExtraStats.AddBlockedMissingTextureRequest();

                                // Commenting out this message for now as it causes too much noise with other
                                // debug messages.
                                //                                m_log.DebugFormat(
                                //                                    "[TEXTURE]: Dropping requests for notified missing texture {0} for client {1} since we have received more than {2} requests",
                                //                                    e.RequestedAssetID, m_client.AgentId, MAX_ALLOWED_TEXTURE_REQUESTS);
                            }

                            return;
                        }

                        m_scene.StatsReporter.AddPendingDownloads(1);

                        TextureSender.TextureSender requestHandler = new TextureSender.TextureSender(m_client, e.DiscardLevel, e.PacketNumber);
                        m_textureSenders.Add(e.RequestedAssetID, requestHandler);

                        m_scene.CommsManager.AssetCache.GetAsset(e.RequestedAssetID, TextureCallback, 
                            AssetRequestInfo.GenericNetRequest());
                    }
                }
            }
            else
            {
                lock (m_textureSenders)
                {
                    if (m_textureSenders.TryGetValue(e.RequestedAssetID, out textureSender))
                    {
                        textureSender.Cancel = true;
                    }
                }
            }
        }
        /// <summary>
        /// Start the process of requesting a given texture.
        /// </summary>
        /// <param name="sender"> </param>
        /// <param name="e"></param>
        public void TextureRequest(Object sender, TextureRequestArgs e)
        {
            IClientAPI client = (IClientAPI)sender;

            if (e.Priority == 1016001f) // Preview
            {
                if (client.Scene is Scene)
                {
                    Scene scene = (Scene)client.Scene;

                    ScenePresence sp = scene.GetScenePresence(client.AgentId);
                    if (sp == null) // Deny unknown user
                        return;

                    IInventoryService invService = scene.InventoryService;
                    if (invService.GetRootFolder(client.AgentId) == null) // Deny no inventory
                        return;

                    // Diva 2009-08-13: this test doesn't make any sense to many devs
                    //if (profile.UserProfile.GodLevel < 200 && profile.RootFolder.FindAsset(e.RequestedAssetID) == null) // Deny if not owned
                    //{
                    //    m_log.WarnFormat("[TEXTURE]: user {0} doesn't have permissions to texture {1}");
                    //    return;
                    //}

                    m_log.Debug("Texture preview");
                }
            }

            UserTextureDownloadService textureService;

            if (TryGetUserTextureService(client, out textureService))
            {
                textureService.HandleTextureRequest(e);
            }
        }
Пример #3
0
        /// <summary>
        /// Start the process of requesting a given texture.
        /// </summary>
        /// <param name="sender"> </param>
        /// <param name="e"></param>
        public void TextureRequest(Object sender, TextureRequestArgs e)
        {
            IClientAPI client = (IClientAPI)sender;

            if (e.Priority == 1016001f) // Preview
            {
                if (client.Scene is Scene)
                {
                    Scene scene = (Scene)client.Scene;

                    CachedUserInfo profile = scene.CommsManager.UserService.GetUserDetails(client.AgentId);
                    if (profile == null) // Deny unknown user
                        return;

                    if (profile.UserProfile.GodLevel < 200 && profile.FindItem(e.RequestedAssetID) == null) // Deny if not owned
                        return;

                    m_log.Debug("Texture preview");
                }
            }

            UserTextureDownloadService textureService;

            if (TryGetUserTextureService(client, out textureService))
            {
                textureService.HandleTextureRequest(e);
            }
        }
Пример #4
0
        public void EnqueueReq(TextureRequestArgs newRequest)
        {
            //newRequest is the properties of our new texture fetch request.
            //Basically, here is where we queue up "new" requests..
            // .. or modify existing requests to suit.

            //Make sure we're not shutting down..
            if (!m_shuttingdown)
            {

                //Do we already know about this UUID?
                if (m_imagestore.ContainsKey(newRequest.RequestedAssetID))
                {
                    //Check the packet sequence to make sure this isn't older than 
                    //one we've already received

                    J2KImage imgrequest = m_imagestore[newRequest.RequestedAssetID];

                    // This is the inbound request sequence number. We can ignore
                    // "old" ones.

                    if (newRequest.requestSequence > imgrequest.m_lastSequence)
                    {

                        imgrequest.m_lastSequence = newRequest.requestSequence;

                        //Check the priority

                        double priority = imgrequest.m_requestedPriority;
                        if (priority != newRequest.Priority)
                        {
                            //Remove the old priority
                            m_priorities.Remove(imgrequest.m_designatedPriorityKey);
                            //Assign a new unique priority
                            imgrequest.m_requestedPriority = newRequest.Priority;
                            imgrequest.m_designatedPriorityKey = AssignPriority(newRequest.RequestedAssetID, newRequest.Priority);
                        }

                        //Update the requested discard level
                        imgrequest.m_requestedDiscardLevel = newRequest.DiscardLevel;

                        //Update the requested packet number
                        imgrequest.m_requestedPacketNumber = newRequest.PacketNumber;

                        //Check if this will create an outstanding texture request
                        bool activated = imgrequest.m_completedSendAtCurrentDiscardLevel;
                        //Run an update

                        imgrequest.RunUpdate();

                        if (activated && !imgrequest.m_completedSendAtCurrentDiscardLevel && imgrequest.m_decoded)
                        {
                            Interlocked.Increment(ref m_outstandingtextures);
                        }
                    }
                }
                else
                {
                    J2KImage imgrequest = new J2KImage(this);

                    //Assign our missing substitute
                    imgrequest.m_MissingSubstitute = m_missingsubstitute;

                    //Assign our decoder module
                    imgrequest.m_j2kDecodeModule = m_j2kDecodeModule;

                    //Assign our asset cache module
                    imgrequest.m_assetCache = m_assetCache;

                    //Assign a priority based on our request
                    imgrequest.m_designatedPriorityKey = AssignPriority(newRequest.RequestedAssetID, newRequest.Priority);

                    //Assign the requested discard level
                    imgrequest.m_requestedDiscardLevel = newRequest.DiscardLevel;

                    //Assign the requested packet number
                    imgrequest.m_requestedPacketNumber = newRequest.PacketNumber;

                    //Assign the requested priority
                    imgrequest.m_requestedPriority = newRequest.Priority;

                    //Assign the asset uuid
                    imgrequest.m_requestedUUID = newRequest.RequestedAssetID;

                    m_imagestore.Add(imgrequest.m_requestedUUID, imgrequest);

                    //Run an update
                    imgrequest.RunUpdate();

                }
            }
        }
Пример #5
0
        public void TestMissingImage()
        {
            TestHelpers.InMethod();
//            XmlConfigurator.Configure();

            TextureRequestArgs args = new TextureRequestArgs();
            args.RequestedAssetID = m_testImageAsset.FullID;
            args.DiscardLevel = 0;
            args.PacketNumber = 1;
            args.Priority = 5;
            args.requestSequence = 1;

            llim.EnqueueReq(args);
            llim.ProcessImageQueue(20);

            Assert.That(tc.SentImageDataPackets.Count, Is.EqualTo(0));
            Assert.That(tc.SentImageNotInDatabasePackets.Count, Is.EqualTo(1));
        }
Пример #6
0
        public void TestDiscardImage()
        {
            TestHelpers.InMethod();
//            XmlConfigurator.Configure();

            scene.AssetService.Store(m_testImageAsset);

            TextureRequestArgs args = new TextureRequestArgs();
            args.RequestedAssetID = m_testImageAsset.FullID;
            args.DiscardLevel = 0;
            args.PacketNumber = 1;
            args.Priority = 5;
            args.requestSequence = 1;
            llim.EnqueueReq(args);

            // Now create a discard request
            TextureRequestArgs discardArgs = new TextureRequestArgs();
            discardArgs.RequestedAssetID = m_testImageAsset.FullID;
            discardArgs.DiscardLevel = -1;
            discardArgs.PacketNumber = 1;
            discardArgs.Priority = 0;
            discardArgs.requestSequence = 2;
            llim.EnqueueReq(discardArgs);

            llim.ProcessImageQueue(20);

            Assert.That(tc.SentImageDataPackets.Count, Is.EqualTo(0));
        }