public void Asset_Received(AssetDownload trans, Asset asset)
 {
     var Running = ExportCommand.Exporting;
     var item = SourceItem;
     UUID itemID = item.UUID;
     //if (trans.AssetID != item.AssetUUID) return;
     if (!trans.Success)
     {
         Error = "" + trans.Status;
         if (waiting != null) waiting.Set();
         lock (Running.TaskAssetWaiting)
         {
             ExportTaskAsset exportTaskAsset;
             if (!Running.CompletedTaskItem.Contains(itemID))
             {
                 Request();
                 return;
             }
         }
     }
     Running.Assets_OnReceived(trans, asset);
     //AddRelated(item.AssetUUID, item.AssetType);
     Running.TaskItemComplete(O.ID, itemID, asset.AssetID, asset.AssetType);
     if (waiting != null) waiting.Set();
 }
 void onAsset(AssetDownload transfer,Asset asset)
 {
     Logger.Log("Asset retrieved id "+asset.AssetID.ToString(),Helpers.LogLevel.Debug);
     Logger.Log("target_asset"+this.target_asset.ToString(),Helpers.LogLevel.Debug);
     if(asset.AssetID!=target_asset)
         return;
     new TryGetImage(this.image,asset.AssetID,false);
 }
        void Assets_OnAssetReceived(AssetDownload transfer, Asset asset)
        {
            KeyValuePair<UUID, UUID> kvp;
            Agent agent;
            if (currentDownloads.TryGetValue(transfer.ID, out kvp))
            {
                currentDownloads.Remove(transfer.ID);

                if (server.Agents.TryGetValue(kvp.Key, out agent))
                {
                    if (transfer.Success)
                    {
                        server.Assets.StoreAsset(asset);
                        TransferToClient(asset, agent, kvp.Value);
                    }
                    else
                    {
                        Logger.Log("Request for missing asset " + transfer.AssetID.ToString(), Helpers.LogLevel.Warning);

                        // Asset not found
                        TransferInfoPacket response = new TransferInfoPacket();
                        response.TransferInfo = new TransferInfoPacket.TransferInfoBlock();
                        response.TransferInfo.TransferID = kvp.Value;

                        response.TransferInfo.Params = new byte[20];
                        Buffer.BlockCopy(transfer.AssetID.GetBytes(), 0, response.TransferInfo.Params, 0, 16);
                        Buffer.BlockCopy(Utils.IntToBytes((int)transfer.AssetType), 0, response.TransferInfo.Params, 16, 4);

                        response.TransferInfo.ChannelType = (int)ChannelType.Asset;
                        response.TransferInfo.Size = 0;
                        response.TransferInfo.Status = (int)StatusCode.UnknownSource;
                        response.TransferInfo.TargetType = (int)TargetType.Unknown;

                        server.UDP.SendPacket(agent.Avatar.ID, response, PacketCategory.Asset);
                    }
                }
                else
                {
                    Logger.Log("Asset transfer finished for an untracked agent, ignoring", Helpers.LogLevel.Warning);
                }
            }
            else
            {
                Logger.Log("Asset transfer finished for an untracked download, ignoring", Helpers.LogLevel.Warning);
            }
        }
Exemple #4
0
 private void ProcessAssetReceived(AssetDownload transfer, OpenMetaverse.Asset asset)
 {
     Console.WriteLine("AssetID : {0} AssetType : {1} Channel : {2} ID : {3} SimID : {4} Size : {5} Source : {6 Status : {7} Success : {8} Target : {9} AssetID : {10} Type : {11}",
         transfer.AssetID.ToString(),
         transfer.AssetType.ToString(),
         transfer.Channel.ToString(),
         transfer.ID.ToString(),
         transfer.Simulator.ID.ToString(),
         transfer.Size.ToString(),
         transfer.Source.ToString(),
         transfer.Status.ToString(),
         transfer.Success.ToString(),
         transfer.Target.ToString(),
         asset.AssetID.ToString(),
         asset.AssetType.ToString()
         );
 }
 public static Asset CreateAsset(AssetDownload download, int asset_type)
 {
     Asset asset;
     switch (asset_type)
     {
         case 70:
             asset = new IrrRootAsset(download.AssetID, download.AssetData);
             break;
         case 71:
             asset = new IrrAnimationAsset(download.AssetID, download.AssetData);
             break;
         case 72:
             asset = new IrrMeshAsset(download.AssetID, download.AssetData);
             break;
         default:
             return null;
     }
     return asset;
 }
Exemple #6
0
        private void Assets_OnAssetReceived(AssetDownload transfer, Asset asset)
        {
            if (transfer.AssetID == AssetID)
            {
                if (transfer.Success)
                {
                    try
                    {
                        File.WriteAllBytes(String.Format("{0}.{1}", AssetID,
                            assetType.ToString().ToLower()), asset.AssetData);
                        Success = true;
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(ex.Message, Helpers.LogLevel.Error, ex);
                    }
                }

                DownloadHandle.Set();
            }
        }
Exemple #7
0
        void Assets_OnNotecardReceived(AssetDownload transfer, Asset asset)
        {
            if (transfer.Success)
            {
                AssetNotecard n = (AssetNotecard)asset;
                n.Decode();
                AssetNotecard recievedNotecard = n;

                text = string.Empty;

                for (int i = 0; i < n.BodyText.Length; i++)
                {
                    char c = n.BodyText[i];

                    // Special marker for embedded things.
                    if ((int)c == 0xdbc0)
                    {
                        int index = (int)n.BodyText[++i] - 0xdc00;
                        InventoryItem e = n.EmbeddedItems[index];
                        text += " (embedded) ";
                    }
                    else
                    {
                        text += c;
                    }
                }

                // TODO put in controls to stop, back up etc
                StopPosition = 0;
                NextSection();
                control.instance.MainForm.KeyDown +=
                    new System.Windows.Forms.KeyEventHandler(MainForm_KeyPress);
            }
            else
            {
                Talker.Say("Failed to download the notecard.", Talk.BeepType.Bad);
            }
        }
Exemple #8
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>
        public UUID RequestInventoryAsset(UUID assetID, UUID itemID, UUID taskID, UUID ownerID, AssetType type, bool priority)
        {
            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;

            // 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);
            return transfer.ID;
        }
Exemple #9
0
        /**
         * Handle arrival of a sound resource.
         */
        void Assets_OnSoundReceived(AssetDownload transfer, Asset asset)
        {
            if (transfer.Success)
            {
                // If this was a Prefetch, just stop here.
                if (prefetchOnly)
                {
                    return;
                }

                //                Logger.Log("Opening sound " + Id.ToString(), Helpers.LogLevel.Debug);

                // Decode the Ogg Vorbis buffer.
                AssetSound s = asset as AssetSound;
                s.Decode();
                byte[] data = s.AssetData;

                // Describe the data to FMOD
                extraInfo.length = (uint)data.Length;
                extraInfo.cbsize = Marshal.SizeOf(extraInfo);

                invoke(new SoundDelegate(delegate
                {
                    try
                    {
                        // Create an FMOD sound of this Ogg data.
                        FMODExec(system.createSound(
                            data,
                            mode,
                            ref extraInfo,
                            ref sound));

                        // Register for callbacks.
                        RegisterSound(sound);

                        // If looping is requested, loop the entire thing.
                        if (loopSound)
                        {
                            uint soundlen = 0;
                            FMODExec(sound.getLength(ref soundlen, TIMEUNIT.PCM));
                            FMODExec(sound.setLoopPoints(0, TIMEUNIT.PCM, soundlen - 1, TIMEUNIT.PCM));
                            FMODExec(sound.setLoopCount(-1));
                        }

                        // Allocate a channel and set initial volume.  Initially paused.
                        FMODExec(system.playSound(CHANNELINDEX.FREE, sound, true, ref channel));
            #if TRACE_SOUND
                    Logger.Log(
                        String.Format("Channel {0} for {1} assigned to {2}",
                             channel.getRaw().ToString("X"),
                             sound.getRaw().ToString("X"),
                             Id),
                        Helpers.LogLevel.Debug);
            #endif
                        RegisterChannel(channel);

                        FMODExec(channel.setVolume(volumeSetting * AllObjectVolume));

                        // Take note of when the sound is finished playing.
                        FMODExec(channel.setCallback(endCallback));

                        // Set attenuation limits.
                        FMODExec(sound.set3DMinMaxDistance(
                                    1.2f,       // Any closer than this gets no louder
                                    100.0f));     // Further than this gets no softer.

                        // Set the sound point of origin.  This is in SIM coordinates.
                        FMODExec(channel.set3DAttributes(ref position, ref ZeroVector));

                        // Turn off pause mode.  The sound will start playing now.
                        FMODExec(channel.setPaused(false));
                    }
                    catch (Exception ex)
                    {
                        Logger.Log("Error playing sound: ", Helpers.LogLevel.Error, ex);
                    }
                }));
            }
            else
            {
                Logger.Log("Failed to download sound: " + transfer.Status.ToString(),
                                        Helpers.LogLevel.Error);
            }
        }
Exemple #10
0
        void Assets_OnAssetReceived(AssetDownload transfer, Asset asset)
        {
            if (InvokeRequired)
            {
                if (!instance.MonoRuntime || IsHandleCreated)
                    BeginInvoke(new MethodInvoker(() => Assets_OnAssetReceived(transfer, asset)));
                return;
            }

            if (transfer.Success)
            {
                AssetNotecard n = (AssetNotecard)asset;
                n.Decode();
                receivedNotecard = n;

                string noteText = string.Empty;
                rtbContent.Clear();

                for (int i = 0; i < n.BodyText.Length; i++)
                {
                    char c = n.BodyText[i];

                    if ((int)c == 0xdbc0)
                    {
                        int index = (int)n.BodyText[++i] - 0xdc00;
                        InventoryItem e = n.EmbeddedItems[index];
                        rtbContent.AppendText(noteText);
                        rtbContent.InsertLink(e.Name, string.Format("radegast://embeddedasset/{0}", index));
                        noteText = string.Empty;
                    }
                    else
                    {
                        noteText += c;
                    }
                }

                rtbContent.Text += noteText;

                if (n.EmbeddedItems != null && n.EmbeddedItems.Count > 0)
                {
                    tbtnAttachments.Enabled = true;
                    tbtnAttachments.Visible = true;
                    foreach (InventoryItem item in n.EmbeddedItems)
                    {
                        int ix = InventoryConsole.GetItemImageIndex(item.AssetType.ToString().ToLower());
                        ToolStripMenuItem titem = new ToolStripMenuItem(item.Name);

                        if (ix != -1)
                        {
                            titem.Image = frmMain.ResourceImages.Images[ix];
                            titem.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
                        }
                        else
                        {
                            titem.DisplayStyle = ToolStripItemDisplayStyle.Text;
                        }

                        titem.Name = item.UUID.ToString(); ;
                        titem.Tag = item;
                        titem.Click += new EventHandler(attachmentMenuItem_Click);

                        var saveToInv = new ToolStripMenuItem("Save to inventory");
                        saveToInv.Click += (object xsender, EventArgs xe) =>
                            {
                                client.Inventory.RequestCopyItemFromNotecard(UUID.Zero,
                                    notecard.UUID,
                                    client.Inventory.FindFolderForType(item.AssetType),
                                    item.UUID,
                                    Inventory_OnInventoryItemCopied);
                            };

                        titem.DropDownItems.Add(saveToInv);
                        tbtnAttachments.DropDownItems.Add(titem);
                    }
                }
                UpdateStatus("OK");
                rtbContent.Focus();
            }
            else
            {
                UpdateStatus("Failed");
                rtbContent.Text = "Failed to download notecard. " + transfer.Status;
            }
        }
 void asset_recieved(AssetDownload transfer, Asset asset)
 {
     Logger.Log("Asset retrieved id " + asset.AssetID.ToString(),Helpers.LogLevel.Debug);
     Logger.Log("target_asset" + this.target_asset.ToString(),Helpers.LogLevel.Debug);
     if (transfer_id != transfer.ID)
         return;
     shownote(asset);
 }
Exemple #12
0
        private void Assets_OnAssetReceived(AssetDownload asset, Asset blah)
        {
            lock (CurrentDownloads)
            {
                // see if we have this in our transfer list
                QueuedDownloadInfo r =
                    CurrentDownloads.Find(delegate(QueuedDownloadInfo q) { return q.AssetID == asset.AssetID; });

                if (r != null && r.AssetID == asset.AssetID)
                {
                    if (asset.Success)
                    {
                        // create the directory to put this in
                        Directory.CreateDirectory(Path.GetDirectoryName(r.FileName));

                        // write out the file
                        File.WriteAllBytes(r.FileName, asset.AssetData);
                        Logger.DebugLog(Name + " Wrote: " + r.FileName, Client);
                        TextItemsTransferred++;
                    }
                    else
                    {
                        TextItemErrors++;
                        WriteLine("{0}: Download of asset {1} ({2}) failed with status {3}", Name, r.FileName,
                                  r.AssetID.ToString(), asset.Status.ToString());
                    }

                    // remove the entry
                    CurrentDownloads.Remove(r);
                }
            }
        }
Exemple #13
0
        void Assets_OnAssetReceived(AssetDownload transfer, Asset asset)
        {
            if (InvokeRequired)
            {
                if (!instance.MonoRuntime || IsHandleCreated)
                    BeginInvoke(new MethodInvoker(() => Assets_OnAssetReceived(transfer, asset)));
                return;
            }

            if (!transfer.Success || asset.AssetType != AssetType.LSLText)
            {
                lblScripStatus.Text = rtb.Text = "Failed to download.";
                return;
            }
            else
                lblScripStatus.Text = rtb.Text = "OK";

            asset.Decode();
            rtb.Text = ((AssetScriptText)asset).Source;
            lineNubersForRtb.Invalidate();
            SetTitle();
        }
Exemple #14
0
 public void SetAsset(AssetDownload download, Asset asset)
 {
     SetAsset(download);
     SetAsset(asset);
 }
Exemple #15
0
 public void SetAsset(AssetDownload download)
 {
     bool xferFailed = !download.Success;
     PullServerAsset = xferFailed;
     NeedsRequest = xferFailed;
     if (download.Success)
     {
         AssetType = download.AssetType;
         AssetData = download.AssetData;
         AssetID = UUIDNonZero(AssetID, download.AssetID, download.ID);
     }
 }
Exemple #16
0
 public void Assets_OnAssetReceived(AssetDownload transfer, Asset asset, UUID inventoryID)
 {
     if (asset == null && transfer != null)
     {
         Hashtable hash = new Hashtable();
         hash.Add("MessageType", "AssetReceived");
         hash.Add("Success", false);
         hash.Add("InventoryID", inventoryID);
         if (transfer != null)
         {
             hash.Add("TransferID", transfer.AssetID);
             hash.Add("AssetID", transfer.AssetID);
             hash.Add("Error", transfer.Status.ToString());
             hash.Add("AssetType", transfer.AssetType);
         }
         enqueue(hash);
         return;
     }
     if (transfer == null)
     {
         Hashtable hash = new Hashtable();
         hash.Add("MessageType", "NullTransfer");
         hash.Add("InventoryID", inventoryID);
         enqueue(hash);
         return;
     }
     try
     {
         Hashtable hash = new Hashtable();
         hash.Add("MessageType", "AssetReceived");
         hash.Add("InventoryID", inventoryID);
         hash.Add("Success", transfer.Success);
         if (!transfer.Success)
         {
             hash.Add("AssetData", "Could not download asset: " + transfer.Status.ToString());
         }
         else
         {
             switch (asset.AssetType)
             {
                 case AssetType.Notecard:
                 case AssetType.LSLText:
                     hash.Add("AssetData", Utils.BytesToString(asset.AssetData));
                     break;
                 case AssetType.Bodypart:
                     {
                         AssetBodypart part = (AssetBodypart)asset;
                         hash.Add("Creator", part.Creator);
                         hash.Add("Description", part.Description);
                         hash.Add("Textures", part.Textures);
                         hash.Add("Params", part.Params);
                         hash.Add("Permissions", part.Permissions);
                         hash.Add("Owner", part.Owner);
                     }
                     break;
             }
         }
         hash.Add("AssetType", transfer.AssetType);
         hash.Add("AssetID", transfer.AssetID);
         hash.Add("TransferID", transfer.ID);
         enqueue(hash);
     }
     catch { }
 }
Exemple #17
0
 public void Asset_ReceivedCallback(AssetDownload transfer,Asset asset)
 {
     if (wear == "save")
     {
         SaveAsset((AssetWearable) asset);
     }
 }
Exemple #18
0
 void Assets_OnAssetReceived(AssetDownload transfer, OpenMetaverse.Asset asset)
 {
     lock (processQueue) processQueue.Enqueue(new QueueBase(new AssetManager.AssetReceivedCallback(ProcessAssetReceived), transfer, asset));
 }
Exemple #19
0
        void Assets_OnAssetReceived(AssetDownload transfer, Asset asset)
        {
            if (InvokeRequired)
            {
                Invoke(new MethodInvoker(() => Assets_OnAssetReceived(transfer, asset)));
                return;
            }

            if (transfer.Success)
            {
                Logger.Log("Animation " + anim + " download success " + asset.AssetData.Length + " bytes.", Helpers.LogLevel.Debug);
                pnlSave.Visible = true;
                animData = asset.AssetData;
            }
            else
            {
                Logger.Log("Animation " + anim + " download failed.", Helpers.LogLevel.Debug);
                Visible = false;
                Dispose();
            }
        }
Exemple #20
0
        void Assets_OnAssetReceived(AssetDownload transfer, Asset asset)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new MethodInvoker(delegate() { Assets_OnAssetReceived(transfer, asset); }));
                return;
            }

            if (!transfer.Success)
            {
                tlblStatus.Text = "Download failed";
                return;
            }

            tlblStatus.Text = "OK";
            tbtnPlay.Enabled = true;

            gestureAsset = (AssetGesture)asset;
            if (gestureAsset.Decode())
            {
                for (int i = 0; i < gestureAsset.Sequence.Count; i++)
                {
                    rtbInfo.AppendText(gestureAsset.Sequence[i].ToString().Trim() + Environment.NewLine);
                }
            }
        }
Exemple #21
0
 void Assets_OnAssetReceived(AssetDownload transfer, Asset asset)
 {
     if (transfer.Success && asset.AssetType == AssetType.Landmark)
     {
         decodedLandmark = (AssetLandmark)asset;
         decodedLandmark.Decode();
         localPosition = decodedLandmark.Position;
         client.Grid.RequestRegionHandle(decodedLandmark.RegionID);
     }
 }
Exemple #22
0
 private Asset WrapAsset(AssetDownload download)
 {
     Asset asset = CreateAssetWrapper(download.AssetType);
     if (asset != null)
     {
         asset.AssetID = download.AssetID;
         asset.AssetData = download.AssetData;
         return asset;
     }
     else
     {
         return null;
     }
 }
        private void Assets_OnAssetReceived(AssetDownload download, Asset asset)
        {
            lock (Wearables.Dictionary)
            {
                // Check if this is a wearable we were waiting on
                foreach (KeyValuePair<WearableType,WearableData> kvp in Wearables.Dictionary)
                {
                    if (kvp.Value.Item.AssetUUID == download.AssetID)
                    {
                        // Make sure the download succeeded
                        if (download.Success)
                        {
                            kvp.Value.Asset = (AssetWearable)asset;

                            Log.DebugLog("Downloaded wearable asset " + kvp.Value.Asset.Name);

                            if (!kvp.Value.Asset.Decode())
                            {
                                Log.Log("Failed to decode asset:" + Environment.NewLine +
                                    Utils.BytesToString(asset.AssetData), Helpers.LogLevel.Error);
                            }

                            lock (AgentTextures)
                            {
                                foreach (KeyValuePair<AppearanceManager.TextureIndex, UUID> texture in kvp.Value.Asset.Textures)
                                {
                                    if (texture.Value != DEFAULT_AVATAR_TEXTURE) // this texture is not meant to be displayed
                                    {
                                        Log.DebugLog("Setting " + texture.Key + " to " + texture.Value);
                                        AgentTextures[(int)texture.Key] = texture.Value;
                                    }
                                }
                            }
                        }
                        else
                        {
                            Log.Log("Wearable " + kvp.Key + "(" + download.AssetID.ToString() + ") failed to download, " +
                                download.Status.ToString(), Helpers.LogLevel.Warning);
                        }

                        break;
                    }
                }
            }

            if (AssetDownloads.Count > 0)
            {
                // Dowload the next wearable in line
                PendingAssetDownload pad = AssetDownloads.Dequeue();
                Assets.RequestAsset(pad.Id, pad.Type, true);
            }
            else
            {
                // Everything is downloaded
                if (OnAgentWearables != null)
                {
                    try { OnAgentWearables(); }
                    catch (Exception e) { Log.Log(e.Message, Helpers.LogLevel.Error, e); }
                }

                WearablesDownloadedEvent.Set();
            }
        }
 public void OnDownloaded(AssetDownload transfer, Asset asset)
 {
     if (transfer.AssetID != NewID) return;
     if (assetType == AssetType.Texture && !asset.Decode())
     {
         Difference(asset.AssetData, AssetData);
         asset.AssetData = AssetData;
         if (false)
         {
             Inventory.RemoveItem(NewItemID);
             NewItemID = UUID.Zero;
             NewID = UUID.Zero;
             UploadAssetData(false);
             /*Inventory.RequestCreateItemFromAsset(AssetData, "" + OldID, ProgressString,
                                                  assetType, inventoryType,
                                                  GetAssetUploadsFolder(),
                                                  Permissions.FullPermissions,
                                                  InvItemCreated);*/
             //UpdateAsset(AssetData);
             return;
         }
     }
     if (!transfer.Success)
     {
         Importing.Error(ExportCommand.Exporting.LocalFailure, "bad transfer on " + this);
     }
     else
     {
         WriteProgress();
     }
     _NewItem = asset;
     NewUUID2OBJECT[NewID] = this;
     UUID2OBJECT[OldID] = this;
     AssetUploaded.Set();
 }
Exemple #25
0
        void animRecievedCallback(AssetDownload transfer, Asset asset)
        {

            if (InvokeRequired)
            {
                BeginInvoke(new MethodInvoker(() => animRecievedCallback(transfer, asset)));
                return;
            }

            if (transfer.Success)
            {
                skeleton.addanimation(asset, transfer.ID, null);
            }
            else
            {
                int nofails = 1;
                if (AssetFetchFailCount.TryGetValue(transfer.AssetID, out nofails))
                {
                    nofails++;
                }

                AssetFetchFailCount[transfer.AssetID] = nofails;

            }


        }
        //Separate thread
        private void Assets_OnAssetReceived(AssetDownload transfer, Asset asset)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new MethodInvoker(delegate()
                    {
                        Assets_OnAssetReceived(transfer, asset);
                    }
                ));

                return;
            }

            //if (transfer.AssetType != AssetType.Notecard) return;

            if (!transfer.Success)
            {
                notecardContent = "Unable to download notecard.";
                SetNotecardText(notecardContent, false);
                return;
            }

            receivedAsset = (AssetNotecard)asset;
            notecardContent = Utils.BytesToString(transfer.AssetData);

            SetNotecardText(notecardContent, false);
        }
Exemple #27
0
 private void assetReceivedCallback(AssetDownload transfer, Asset asset)
 {
     if (OnAssetReceived != null)
     {
         OnAssetReceived(transfer, asset);
     }
 }
Exemple #28
0
        public void Asset_ReceivedCallback(AssetDownload transfer, Asset asset)
        {
            lock (Manager.AssetsReceived)
                Manager.AssetsReceived[asset.AssetID] = true;

//            if (wear == "save")
//            {
//                SaveAsset((AssetWearable) asset);
//            }
        }
Exemple #29
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);
        }
 void animRecievedCallback(AssetDownload transfer, Asset asset)
 {
     if (transfer.Success)
     {
         skeleton.addanimation(asset, transfer.ID, null);
     }
 }