UploadBakedTextureMessage message2 = new UploadBakedTextureMessage();
message2.Deserialize((OSDMap)result2);
if (message2.Request.State.equals("complete"))
{
callback.execute(new BakedTextureUploadedCallbackArgs(((UploaderRequestComplete)message2.Request).AssetID));
}
}
return null;
}
});
upload.BeginGetResponse(textureData, "application/octet-stream", Client.settings.CAPS_TIMEOUT);
return null;
}
}
}
JLogger.warn("Bake upload failed during uploader retrieval");
callback.execute(new BakedTextureUploadedCallbackArgs(UUID.Zero));
return null;
}
};
request.setRequestCompleteDelegate(requestCompleteDelegate);
request.BeginGetResponse(new OSDMap(), OSDFormat.Xml, Client.settings.CAPS_TIMEOUT);
// request.OnComplete +=
// delegate(CapsClient client, OSD result, Exception error)
// {
// if (error == null && result is OSDMap)
// {
// UploadBakedTextureMessage message = new UploadBakedTextureMessage();
// message.Deserialize((OSDMap)result);
//
// if (message.Request.State == "upload")
// {
// Uri uploadUrl = ((UploaderRequestUpload)message.Request).Url;
//
// if (uploadUrl != null)
// {
// // POST the asset data
// CapsClient upload = new CapsClient(uploadUrl);
// upload.OnComplete +=
// delegate(CapsClient client2, OSD result2, Exception error2)
// {
// if (error2 == null && result2 is OSDMap)
// {
// UploadBakedTextureMessage message2 = new UploadBakedTextureMessage();
// message2.Deserialize((OSDMap)result2);
//
// if (message2.Request.State == "complete")
// {
// callback(((UploaderRequestComplete)message2.Request).AssetID);
// return;
// }
// }
//
// Logger.Log("Bake upload failed during asset upload", Helpers.LogLevel.Warning, Client);
// callback(UUID.Zero);
// };
// upload.BeginGetResponse(textureData, "application/octet-stream", Client.Settings.CAPS_TIMEOUT);
// return;
// }
// }
// }
//
// Logger.Log("Bake upload failed during uploader retrieval", Helpers.LogLevel.Warning, Client);
// callback(UUID.Zero);
// };
// request.BeginGetResponse(new OSDMap(), OSDFormat.Xml, Client.Settings.CAPS_TIMEOUT);
}
else
{
JLogger.info("UploadBakedTexture not available, falling back to UDP method");
final MethodDelegate<Void, BakedTextureUploadedCallbackArgs> uploadCallback = callback;
threadPool.execute(new Runnable(){
public void run()
{
final UUID transactionID = UUID.Random();
final AutoResetEvent uploadEvent = new AutoResetEvent(false);
EventObserver<AssetUploadEventArgs> udpCallback = new EventObserver<AssetUploadEventArgs>()
{
@Override
public void handleEvent(Observable sender,
AssetUploadEventArgs e) {
if (e.getUpload().ID.equals(transactionID))
{
uploadEvent.set();
uploadCallback.execute(new BakedTextureUploadedCallbackArgs(e.getUpload().Success ? e.getUpload().AssetID : UUID.Zero));
}
}
};
onAssetUploaded.addObserver(udpCallback);
boolean success;
try
{
UploadRequestResult uploadResult = RequestUpload(AssetType.Texture, textureData, true, transactionID);
success = uploadEvent.waitOne(Client.settings.TRANSFER_TIMEOUT);
}
catch (Exception e)
{
JLogger.warn(e);
success = false;
}
onAssetUploaded.deleteObserver(udpCallback);
if (!success)
uploadCallback.execute(new BakedTextureUploadedCallbackArgs(UUID.Zero));
}
});
// Logger.Log("UploadBakedTexture not available, falling back to UDP method", Helpers.LogLevel.Info, Client);
//