Esempio n. 1
0
        /// <summary>
        /// Request an asset download through the almost deprecated Xfer system
        /// </summary>
        /// <param name="filename">Filename of the asset to request</param>
        /// <param name="deleteOnCompletion">Whether or not to delete the asset
        /// off the server after it is retrieved</param>
        /// <param name="useBigPackets">Use large transfer packets or not</param>
        /// <param name="vFileID">UUID of the file to request, if filename is
        /// left empty</param>
        /// <param name="vFileType">Asset type of <code>vFileID</code>, or
        /// <code>AssetType.Unknown</code> if filename is not empty</param>
        /// <returns></returns>
        public ulong RequestAssetXfer(string filename, bool deleteOnCompletion, bool useBigPackets, LLUUID vFileID, AssetType vFileType)
        {
            LLUUID uuid = LLUUID.Random();
            ulong  id   = uuid.ToULong();

            XferDownload transfer = new XferDownload();

            transfer.XferID    = id;
            transfer.ID        = new LLUUID(id); // Our dictionary tracks transfers with LLUUIDs, so convert the ulong back
            transfer.Filename  = filename;
            transfer.VFileID   = vFileID;
            transfer.AssetType = vFileType;

            // Add this transfer to the dictionary
            lock (Transfers) Transfers[transfer.ID] = transfer;

            RequestXferPacket request = new RequestXferPacket();

            request.XferID.ID       = id;
            request.XferID.Filename = Helpers.StringToField(filename);
            request.XferID.FilePath = 4; // "Cache". This is a horrible thing that hardcodes a file path enumeration in to the
                                         // protocol. For asset downloads we should only ever need this value
            request.XferID.DeleteOnCompletion = deleteOnCompletion;
            request.XferID.UseBigPackets      = useBigPackets;
            request.XferID.VFileID            = vFileID;
            request.XferID.VFileType          = (short)vFileType;

            Client.Network.SendPacket(request);

            return(id);
        }