/// <remarks>This request blocks until the response from the simulator arrives
/// or timeoutMS is exceeded</remarks>
public List<InventoryBase> GetTaskInventory(final UUID objectID, long objectLocalID, int timeoutMS) throws InterruptedException, UnsupportedEncodingException
{
final String[] filename = new String[]{null};
final AutoResetEvent taskReplyEvent = new AutoResetEvent(false);
EventObserver<TaskInventoryReplyEventArgs> callback = new EventObserver<TaskInventoryReplyEventArgs>()
// delegate(Object sender, TaskInventoryReplyEventArgs e)
{
@Override
public void handleEvent(Observable o,
TaskInventoryReplyEventArgs e) {
if (e.getItemID().equals(objectID))
{
filename[0] = e.getAssetFilename();
taskReplyEvent.set();
}
}
};
onTaskInventoryReply.addObserver(callback);
RequestTaskInventory(objectLocalID);
if (taskReplyEvent.waitOne(timeoutMS))
{
onTaskInventoryReply.deleteObserver(callback);
if (!Utils.isNullOrEmpty(filename[0]))
{
final byte[][] assetData = new byte[][]{null};
final BigInteger[] xferID = new BigInteger[]{new BigInteger("0")};
final AutoResetEvent taskDownloadEvent = new AutoResetEvent(false);
EventObserver<XferReceivedEventArgs> xferCallback = new EventObserver<XferReceivedEventArgs>()
// delegate(Object sender, XferReceivedEventArgs e)
{
@Override
public void handleEvent(Observable o,
XferReceivedEventArgs e) {
if (e.getXfer().XferID.equals(xferID[0]))
{
assetData[0] = e.getXfer().AssetData;
taskDownloadEvent.set();
}}
};
Client.assets.registerOnXferReceived(xferCallback);
// Start the actual asset xfer
xferID[0] = Client.assets.RequestAssetXfer(filename[0], true, false, UUID.Zero, AssetType.Unknown, true);
if (taskDownloadEvent.waitOne(timeoutMS))
{
Client.assets.unregisterOnXferReceived(xferCallback);
String taskList = Utils.bytesWithTrailingNullByteToString(assetData[0]);
return ParseTaskInventory(taskList);