//Separate thread private void Assets_OnAssetReceived(AssetDownload transfer, Asset asset) { if (transfer.ID != transferID) return; string notecardContent; if (!transfer.Success) { notecardContent = "Unable to download item. You may not have the correct permissions."; BeginInvoke(new OnSetNotecardText(SetNotecardText), new object[] { notecardContent, true }); return; } notecardContent = Helpers.FieldToUTF8String(transfer.AssetData); BeginInvoke(new OnSetNotecardText(SetNotecardText), new object[] { notecardContent, false }); }
//Separate thread private void Assets_OnAssetReceived(AssetDownload transfer, Asset asset) { if (transfer.ID != transferID) return; string scriptContent; if (!transfer.Success) { scriptContent = "Unable to download script. Make sure you have the proper permissions!"; BeginInvoke(new OnSetScriptText(SetScriptText), new object[] { scriptContent, true }); return; } receivedAsset = (AssetScriptText)asset; scriptContent = Helpers.FieldToUTF8String(transfer.AssetData); BeginInvoke(new OnSetScriptText(SetScriptText), new object[] { scriptContent, false }); }
public LLUUID RequestUpload(Asset asset, bool tempFile, bool storeLocal, bool isPriority) { if (asset.AssetData == null) throw new ArgumentException("Can't upload an asset with no data (did you forget to call Encode?)"); LLUUID assetID; LLUUID transferID = RequestUpload(out assetID, asset.AssetType, asset.AssetData, tempFile, storeLocal, isPriority); asset.AssetID = assetID; return transferID; }
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.TransferID == asset.ID; }); if (r != null && r.TransferID == asset.ID) { 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++; Console.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); } } }
//Separate thread private void Assets_OnAssetReceived(AssetDownload transfer, Asset asset) { if (transfer.ID != transferID) { Console.WriteLine("[SLMIV]: Assets_OnAssetReceived=transfer:" + transfer.AssetID.ToStringHyphenated() + " != transferID:" + transferID.ToString());//Debug return; } if (!transfer.Success) { notecardContent = "Unable to download item. You may not have the correct permissions."; client.Log("[SLMIV] Unable to download AssetID: " + transferID.ToString() + " You may not have the correct permissions.", Helpers.LogLevel.Info); return; } else { notecardContent = Helpers.FieldToUTF8String(transfer.AssetData); //client.Log("[SLMIV] Received AssetID: " + transfer.AssetID.UUID.ToString(), Helpers.LogLevel.Info);//NO:asset.AssetID.UUID.ToString(),asset.AssetID.ToStringHyphenated()NO:transfer.ID.ToStringHyphenated(), NO:transferID.ToString() Console.WriteLine("[SLMIV]: Received AssetID: " + transfer.AssetID.UUID.ToString());//Debug } }
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; Client.DebugLog("Downloaded wearable asset " + kvp.Value.Asset.Name); if (!kvp.Value.Asset.Decode()) { Client.Log("Failed to decode asset:" + Environment.NewLine + Helpers.FieldToUTF8String(asset.AssetData), Helpers.LogLevel.Error); } lock (AgentTextures) { foreach (KeyValuePair<AppearanceManager.TextureIndex, LLUUID> texture in kvp.Value.Asset.Textures) { if (texture.Value != DEFAULT_AVATAR_TEXTURE) // this texture is not meant to be displayed { Client.DebugLog("Setting " + texture.Key + " to " + texture.Value); AgentTextures[(int)texture.Key] = texture.Value; } } } } else { Client.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 WearablesDownloadedEvent.Set(); } }
public void Assets_OnAssetReceived(AssetDownload transfer, Asset asset) { if (asset == null && transfer != null) { Hashtable hash = new Hashtable(); hash.Add("MessageType", "AssetReceived"); hash.Add("Success", false); if (transfer != null) { hash.Add("TransferID", transfer.ID); 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"); enqueue(hash); return; } try { Hashtable hash = new Hashtable(); hash.Add("MessageType", "AssetReceived"); 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", Helpers.FieldToUTF8String(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 { } }