public void GetAttachmentResources(final EventObserver<AttachmentResourcesCallbackArg> callback)
{
try
{
URI url = Client.network.getCurrentSim().Caps.CapabilityURI("AttachmentResources");
CapsHttpClient request = new CapsHttpClient(url);
request.addRequestCompleteObserver(new EventObserver<CapsHttpRequestCompletedArg>()
{
public void handleEvent(Observable arg0, CapsHttpRequestCompletedArg arg1) {
// System.out.println("RequestCompletedObserver called ...");
CapsHttpRequestCompletedArg rcha = (CapsHttpRequestCompletedArg) arg1;
try
{
if (rcha.getResult() == null || rcha.getError() != null)
{
callback.handleEvent(null, new AttachmentResourcesCallbackArg(false, null));
}
AttachmentResourcesMessage info = AttachmentResourcesMessage.FromOSD(rcha.getResult());
callback.handleEvent(null, new AttachmentResourcesCallbackArg(true, info));
}
catch (Exception ex)
{
JLogger.error("Failed fetching AttachmentResources" + Utils.getExceptionStackTraceAsString(ex));
callback.handleEvent(null, new AttachmentResourcesCallbackArg(false, null));
}
}
}
);
// request.OnComplete += delegate(CapsHttpClient client, OSD result, Exception error)
// {
// try
// {
// if (result == null || error != null)
// {
// callback(false, null);
// }
// AttachmentResourcesMessage info = AttachmentResourcesMessage.FromOSD(result);
// callback(true, info);
//
// }
// catch (Exception ex)
// {
// JLogger.error("Failed fetching AttachmentResources" + Utils.getExceptionStackTraceAsString(ex));
// callback(false, null);
// }
// };
request.BeginGetResponse(Client.settings.CAPS_TIMEOUT);
}
catch (Exception ex)
{
JLogger.error("Failed fetching AttachmentResources" + Utils.getExceptionStackTraceAsString(ex));
callback.handleEvent(null, new AttachmentResourcesCallbackArg(false, null));