Changed the AssetManager.RequestUpload function signature to more closely resemble the RequestAsset function, and added an overload to simplify the call

git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@1336 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
John Hurliman
2007-07-30 08:10:05 +00:00
parent 17ac9f88db
commit cd9b2cef2a
5 changed files with 60 additions and 67 deletions

View File

@@ -140,11 +140,9 @@ namespace SLImageUpload
cmdUpload.Enabled = false;
grpLogin.Enabled = false;
// Generate the Transaction ID and Asset ID
LLUUID transactionid = LLUUID.Random();
txtAssetID.Text = transactionid.Combine(Client.Network.SecureSessionID).ToStringHyphenated();
Assets.RequestUpload(transactionid, AssetType.Texture, UploadData, false, false, true);
LLUUID assetID;
LLUUID transactionid = Assets.RequestUpload(out assetID, AssetType.Texture, UploadData, false, false, true);
txtAssetID.Text = assetID.ToStringHyphenated();
}
}

View File

@@ -48,7 +48,7 @@ namespace SLProxy
public ProxyFrame(string[] args)
{
bool externalPlugin = false;
//bool externalPlugin = false;
this.args = args;
ProxyConfig proxyConfig = new ProxyConfig("SLProxy", "Austin Jennings / Andrew Ortman", args);
@@ -75,7 +75,7 @@ namespace SLProxy
Console.WriteLine("arg '" + sw + "' val '" + val + "'");
if (sw == "--load")
{
externalPlugin = true;
//externalPlugin = true;
LoadPlugin(val);
}
}

View File

@@ -186,7 +186,7 @@ namespace importprimscript
}
CurrentUpload = null;
Assets.RequestUpload(LLUUID.Random(), AssetType.Texture, jp2data, false, false, true);
LLUUID transactionID = Assets.RequestUpload(AssetType.Texture, jp2data, false, false, true);
// The textures are small, 60 seconds should be plenty
UploadEvent.WaitOne(1000 * 60, false);

View File

@@ -1435,15 +1435,12 @@ namespace libsecondlife
private void UploadBake(Baker bake)
{
// Create a transactionID and assetID for this upload
LLUUID transactionID = LLUUID.Random();
LLUUID assetID = transactionID.Combine(Client.Network.SecureSessionID);
// Upload the completed layer data
LLUUID assetID;
LLUUID transactionID = Assets.RequestUpload(out assetID, AssetType.Texture, bake.EncodedBake, true, true, false);
Client.DebugLog("Bake " + bake.BakeType.ToString() + " completed. Uploading asset " + assetID.ToStringHyphenated());
// Upload the completed layer data
Assets.RequestUpload(transactionID, AssetType.Texture, bake.EncodedBake, true, true, false);
// Add it to a pending uploads list
lock (PendingUploads) PendingUploads.Add(assetID, BakeTypeToAgentTextureIndex(bake.BakeType));
}

View File

@@ -398,78 +398,76 @@ namespace libsecondlife
}
}
public LLUUID RequestUpload(AssetType type, byte[] data, bool tempFile, bool storeLocal,
bool isPriority)
{
LLUUID assetID;
return RequestUpload(out assetID, type, data, tempFile, storeLocal, isPriority);
}
/// <summary>
/// Initiate an asset upload
/// </summary>
/// <param name="transactionID">Usually a randomly generated UUID</param>
/// <param name="transactionID">The ID this asset will have if the
/// upload succeeds</param>
/// <param name="type">Asset type to upload this data as</param>
/// <param name="data">Raw asset data to upload</param>
/// <param name="tempFile">Whether this is a temporary file or not</param>
/// <param name="storeLocal">Whether to store this asset on the local
/// simulator or the grid-wide asset server</param>
/// <param name="isPriority">Give this upload a higher priority</param>
/// <returns>The asset ID the new file will have once the upload is
/// complete</returns>
public LLUUID RequestUpload(LLUUID transactionID, AssetType type, byte[] data, bool tempFile, bool storeLocal,
/// <returns>The transaction ID of this transfer</returns>
public LLUUID RequestUpload(out LLUUID assetID, AssetType type, byte[] data, bool tempFile, bool storeLocal,
bool isPriority)
{
if (!Transfers.ContainsKey(transactionID))
AssetUpload upload = new AssetUpload();
upload.AssetData = data;
upload.AssetType = type;
upload.ID = LLUUID.Random();
assetID = upload.ID.Combine(Client.Network.SecureSessionID);
upload.AssetID = assetID;
upload.Size = data.Length;
upload.XferID = 0;
// Build and send the upload packet
AssetUploadRequestPacket request = new AssetUploadRequestPacket();
request.AssetBlock.StoreLocal = storeLocal;
request.AssetBlock.Tempfile = tempFile;
request.AssetBlock.TransactionID = upload.ID;
request.AssetBlock.Type = (sbyte)type;
if (data.Length + 100 < Settings.MAX_PACKET_SIZE)
{
AssetUpload upload = new AssetUpload();
upload.AssetData = data;
upload.AssetType = type;
upload.ID = transactionID;
upload.AssetID = ((transactionID == LLUUID.Zero) ? transactionID : transactionID.Combine(Client.Network.SecureSessionID));
upload.Size = data.Length;
upload.XferID = 0;
Client.Log(
String.Format("Beginning asset upload [Single Packet], ID: {0}, AssetID: {1}, Size: {2}",
upload.ID.ToStringHyphenated(), upload.AssetID.ToStringHyphenated(), upload.Size),
Helpers.LogLevel.Info);
// Build and send the upload packet
AssetUploadRequestPacket request = new AssetUploadRequestPacket();
request.AssetBlock.StoreLocal = storeLocal;
request.AssetBlock.Tempfile = tempFile;
request.AssetBlock.TransactionID = upload.ID;
request.AssetBlock.Type = (sbyte)type;
if (data.Length + 100 < Settings.MAX_PACKET_SIZE)
{
Client.Log(
String.Format("Beginning asset upload [Single Packet], ID: {0}, AssetID: {1}, Size: {2}",
upload.ID.ToStringHyphenated(), upload.AssetID.ToStringHyphenated(), upload.Size),
Helpers.LogLevel.Info);
// The whole asset will fit in this packet, makes things easy
request.AssetBlock.AssetData = data;
upload.Transferred = data.Length;
}
else
{
Client.Log(
String.Format("Beginning asset upload [Multiple Packets], ID: {0}, AssetID: {1}, Size: {2}",
upload.ID.ToStringHyphenated(), upload.AssetID.ToStringHyphenated(), upload.Size),
Helpers.LogLevel.Info);
// Asset is too big, send in multiple packets
request.AssetBlock.AssetData = new byte[0];
}
//Client.DebugLog(request.ToString());
// Add this upload to the Transfers dictionary using the assetID as the key.
// Once the simulator assigns an actual identifier for this upload it will be
// removed from Transfers and reinserted with the proper identifier
lock (Transfers) Transfers[upload.AssetID] = upload;
Client.Network.SendPacket(request);
return upload.AssetID;
// The whole asset will fit in this packet, makes things easy
request.AssetBlock.AssetData = data;
upload.Transferred = data.Length;
}
else
{
Client.Log("RequestUpload() called for an asset we are already uploading, ignoring",
Client.Log(
String.Format("Beginning asset upload [Multiple Packets], ID: {0}, AssetID: {1}, Size: {2}",
upload.ID.ToStringHyphenated(), upload.AssetID.ToStringHyphenated(), upload.Size),
Helpers.LogLevel.Info);
return LLUUID.Zero;
// Asset is too big, send in multiple packets
request.AssetBlock.AssetData = new byte[0];
}
//Client.DebugLog(request.ToString());
// Add this upload to the Transfers dictionary using the assetID as the key.
// Once the simulator assigns an actual identifier for this upload it will be
// removed from Transfers and reinserted with the proper identifier
lock (Transfers) Transfers[upload.AssetID] = upload;
Client.Network.SendPacket(request);
return upload.ID;
}
private void SendNextUploadPacket(AssetUpload upload)