本文整理汇总了C#中OpenMetaverse.AssetDownload类的典型用法代码示例。如果您正苦于以下问题:C# AssetDownload类的具体用法?C# AssetDownload怎么用?C# AssetDownload使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AssetDownload类属于OpenMetaverse命名空间,在下文中一共展示了AssetDownload类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Asset_Received
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();
}
示例2: onAsset
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);
}
示例3: Assets_OnAssetReceived
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);
}
}
示例4: ProcessAssetReceived
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()
);
}
示例5: CreateAsset
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;
}
示例6: Assets_OnAssetReceived
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();
}
}
示例7: Assets_OnNotecardReceived
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);
}
}
示例8: RequestInventoryAsset
/// <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;
}
示例9: Assets_OnSoundReceived
/**
* 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);
}
}
示例10: Assets_OnAssetReceived
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;
}
}
示例11: asset_recieved
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);
}
示例12: Assets_OnAssetReceived
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);
}
}
}
示例13: Assets_OnAssetReceived
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();
}
示例14: SetAsset
public void SetAsset(AssetDownload download, Asset asset)
{
SetAsset(download);
SetAsset(asset);
}
示例15: Assets_OnAssetReceived
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 { }
}