use of com.google.gwt.typedarrays.shared.Uint8Array in project playn by threerings.
the class HtmlWebSocket method send.
@Override
public void send(ByteBuffer data) {
int len = data.limit();
// TODO(haustein) Sending the view directly does not work for some reason.
// May be a chrome issue...?
// Object trick = data;
// ArrayBufferView ta = ((HasArrayBufferView) trick).getTypedArray();
// Int8Array view = Int8Array.create(ta.getBuffer(), ta.getByteOffset(), len)
// ws.send(view);
ArrayBuffer buf = TypedArrays.createArrayBuffer(len);
Uint8Array view = TypedArrays.createUint8Array(buf);
for (int i = 0; i < len; i++) {
view.set(i, data.get(i));
}
ws.send(buf);
}
use of com.google.gwt.typedarrays.shared.Uint8Array in project actor-platform by actorapp.
the class WebSocketConnection method doSend.
@Override
public void doSend(byte[] data) {
// Log.d(TAG, "doSend");
if (isClosed) {
return;
}
Uint8Array push = TypedArrays.createUint8Array(data.length);
for (int i = 0; i < data.length; i++) {
push.set(i, data[i]);
}
send(push);
}
Aggregations