Example usage for com.google.gwt.typedarrays.shared TypedArrays createArrayBuffer

List of usage examples for com.google.gwt.typedarrays.shared TypedArrays createArrayBuffer

Introduction

In this page you can find the example usage for com.google.gwt.typedarrays.shared TypedArrays createArrayBuffer.

Prototype

public static ArrayBuffer createArrayBuffer(int length) 

Source Link

Document

Create a new ArrayBuffer of length bytes.

Usage

From source file:org.plugination.connect.html.HtmlWebSocket.java

License:Apache License

@Override
public void send(ByteBuffer data) {
    int limit = data.limit();
    ArrayBuffer buffer = TypedArrays.createArrayBuffer(limit);
    Uint8Array arrayBuffer = TypedArrays.createUint8Array(buffer);
    for (int i = 0; i < limit; i++) {
        arrayBuffer.set(i, data.get(i));
    }//from ww w  .ja  v  a2 s  .  c  o  m
    ws.send(buffer);
}