com.google.gwt.xhr.client.XMLHttpRequest.getResponseArrayBuffer()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(2.7k)|赞(0)|评价(0)|浏览(128)

本文整理了Java中com.google.gwt.xhr.client.XMLHttpRequest.getResponseArrayBuffer()方法的一些代码示例,展示了XMLHttpRequest.getResponseArrayBuffer()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLHttpRequest.getResponseArrayBuffer()方法的具体详情如下:
包路径:com.google.gwt.xhr.client.XMLHttpRequest
类名称:XMLHttpRequest
方法名:getResponseArrayBuffer

XMLHttpRequest.getResponseArrayBuffer介绍

[英]Get the response as an ArrayBuffer.
[中]作为ArrayBuffer获取响应。

代码示例

代码示例来源:origin: libgdx/libgdx

@Override
  public void onReadyStateChange (XMLHttpRequest xhr) {
    if (xhr.getReadyState() == XMLHttpRequest.DONE) {
      if (xhr.getStatus() != 200) {
        listener.onFailure();
      } else {
        Int8Array data = TypedArrays.createInt8Array(xhr.getResponseArrayBuffer());
        listener.onSuccess(new Blob(data));
      }
    }
  }
});

代码示例来源:origin: libgdx/libgdx

@Override
  public void onReadyStateChange (XMLHttpRequest xhr) {
    if (xhr.getReadyState() == XMLHttpRequest.DONE) {
      if (xhr.getStatus() != 200) {
        listener.onFailure();
      } else {
        Int8Array data = TypedArrays.createInt8Array(xhr.getResponseArrayBuffer());
        listener.onSuccess(new Blob(data));
      }
    }
  }
});

代码示例来源:origin: io.playn/playn-html

public ByteBuffer apply (XMLHttpRequest xhr) {
  return TypedArrayHelper.wrap(xhr.getResponseArrayBuffer());
 }
});

代码示例来源:origin: playn/playn

public ByteBuffer apply (XMLHttpRequest xhr) {
  return TypedArrayHelper.wrap(xhr.getResponseArrayBuffer());
 }
});

代码示例来源:origin: thothbot/parallax

@Override
  public void onReadyStateChange (XMLHttpRequest xhr) {
    if (xhr.getReadyState() == XMLHttpRequest.DONE) {
      if (xhr.getStatus() != 200) {
        listener.onFailure();
      } else {
        Int8Array data = TypedArrays.createInt8Array(xhr.getResponseArrayBuffer());
        listener.onSuccess(new Blob(data));
      }
    }
  }
});

代码示例来源:origin: com.badlogicgames.gdx/gdx-backend-gwt

@Override
  public void onReadyStateChange (XMLHttpRequest xhr) {
    if (xhr.getReadyState() == XMLHttpRequest.DONE) {
      if (xhr.getStatus() != 200) {
        listener.onFailure();
      } else {
        Int8Array data = TypedArrays.createInt8Array(xhr.getResponseArrayBuffer());
        listener.onSuccess(new Blob(data));
      }
    }
  }
});

代码示例来源:origin: sriharshachilakapati/SilenceEngine

@Override
public void readBinaryFile(FilePath file, UniCallback<DirectBuffer> onComplete, UniCallback<Throwable> onError)
{
  // Create a XMLHttpRequest to load the file into a direct buffer
  XMLHttpRequest request = XMLHttpRequest.create();
  request.open("GET", file.getAbsolutePath());
  // Set to read as ArrayBuffer and attach a handler
  request.setResponseType(XMLHttpRequest.ResponseType.ArrayBuffer);
  request.setOnReadyStateChange(xhr ->
  {
    if (request.getReadyState() == XMLHttpRequest.DONE)
    {
      if (request.getStatus() == 200)
        // Invoke the onComplete handler
        onComplete.invoke(new GwtDirectBuffer(request.getResponseArrayBuffer()));
      else
        onError.invoke(new SilenceException("Error fetching the file: " + request.getStatusText()));
    }
  });
  // Send the request
  request.send();
}

相关文章