Exemple #1
0
 public void RequestInventoryAsset(InventoryItem item, bool priority, AssetReceivedCallback callback)
 {
     RequestInventoryAsset(item.AssetUUID, item.UUID, UUID.Zero, item.OwnerID, item.AssetType, priority, callback);
 }
Exemple #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="assetID">Use UUID.Zero if you do not have the 
        /// asset ID but have all the necessary permissions</param>
        /// <param name="itemID">The item ID of this asset in the inventory</param>
        /// <param name="taskID">Use UUID.Zero if you are not requesting an 
        /// asset from an object inventory</param>
        /// <param name="ownerID">The owner of this asset</param>
        /// <param name="type">Asset type</param>
        /// <param name="priority">Whether to prioritize this asset download or not</param>
        /// <param name="callback"></param>
        public void RequestInventoryAsset(UUID assetID, UUID itemID, UUID taskID, UUID ownerID, AssetType type, bool priority, AssetReceivedCallback callback)
        {
            AssetDownload transfer = new AssetDownload();
            transfer.ID = UUID.Random();
            transfer.AssetID = assetID;
            //transfer.AssetType = type; // Set in TransferInfoHandler.
            transfer.Priority = 100.0f + (priority ? 1.0f : 0.0f);
            transfer.Channel = ChannelType.Asset;
            transfer.Source = SourceType.SimInventoryItem;
            transfer.Simulator = Client.Network.CurrentSim;
            transfer.Callback = callback;

            // Check asset cache first
            if (callback != null && Cache.HasAsset(assetID))
            {
                byte[] data = Cache.GetCachedAssetBytes(assetID);
                transfer.AssetData = data;
                transfer.Success = true;
                transfer.Status = StatusCode.OK;

                Asset asset = CreateAssetWrapper(type);
                asset.AssetData = data;
                asset.AssetID = assetID;

                try { callback(transfer, asset); }
                catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); }

                return;
            }

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

            // Build the request packet and send it
            TransferRequestPacket request = new TransferRequestPacket();
            request.TransferInfo.ChannelType = (int)transfer.Channel;
            request.TransferInfo.Priority = transfer.Priority;
            request.TransferInfo.SourceType = (int)transfer.Source;
            request.TransferInfo.TransferID = transfer.ID;

            byte[] paramField = new byte[100];
            Buffer.BlockCopy(Client.Self.AgentID.GetBytes(), 0, paramField, 0, 16);
            Buffer.BlockCopy(Client.Self.SessionID.GetBytes(), 0, paramField, 16, 16);
            Buffer.BlockCopy(ownerID.GetBytes(), 0, paramField, 32, 16);
            Buffer.BlockCopy(taskID.GetBytes(), 0, paramField, 48, 16);
            Buffer.BlockCopy(itemID.GetBytes(), 0, paramField, 64, 16);
            Buffer.BlockCopy(assetID.GetBytes(), 0, paramField, 80, 16);
            Buffer.BlockCopy(Utils.IntToBytes((int)type), 0, paramField, 96, 4);
            request.TransferInfo.Params = paramField;

            Client.Network.SendPacket(request, transfer.Simulator);
        }
 /// <summary>
 /// Request an asset download
 /// </summary>
 /// <param name="assetID">Asset UUID</param>
 /// <param name="type">Asset type, must be correct for the transfer to succeed</param>
 /// <param name="priority">Whether to give this transfer an elevated priority</param>
 /// <param name="sourceType">Source location of the requested asset</param>
 /// <param name="transactionID">UUID of the transaction</param>
 /// <param name="callback">The callback to fire when the simulator responds with the asset data</param>
 public void RequestAsset(UUID assetID, AssetType type, bool priority, SourceType sourceType, UUID transactionID, AssetReceivedCallback callback)
 {
     RequestAsset(assetID, UUID.Zero, UUID.Zero, type, priority, sourceType, transactionID, callback);
 }
Exemple #4
0
 /// <summary>
 /// Request an asset download
 /// </summary>
 /// <param name="assetID">Asset UUID</param>
 /// <param name="type">Asset type, must be correct for the transfer to succeed</param>
 /// <param name="priority">Whether to give this transfer an elevated priority</param>
 /// <param name="sourceType">Source location of the requested asset</param>
 /// <param name="callback">The callback to fire when the simulator responds with the asset data</param>
 public void RequestAsset(UUID assetID, AssetType type, bool priority, SourceType sourceType, AssetReceivedCallback callback)
 {
     RequestAsset(assetID, type, priority, sourceType, UUID.Random(), callback);
 }
Exemple #5
0
 /// <summary>
 /// Request an asset download
 /// </summary>
 /// <param name="assetID">Asset UUID</param>
 /// <param name="type">Asset type, must be correct for the transfer to succeed</param>
 /// <param name="priority">Whether to give this transfer an elevated priority</param>
 /// <param name="callback">The callback to fire when the simulator responds with the asset data</param>
 public void RequestAsset(UUID assetID, AssetType type, bool priority, AssetReceivedCallback callback)
 {
     RequestAsset(assetID, type, priority, SourceType.Asset, callback);
 }