I like to send a ArrayBuffer from JavaScript to an WebSocket Server, which Returns the Binary back to other Clients in the Network.
My Problem is, that I don't know how to send the ArrayBuffer from JavaScript 1:1 to the Server and from the Server back to the Client.
I tried a simple ByteBuffer, but it sends only one Array Element. Then I tried:
InputStream arrayIO = new ByteArrayInputStream(payloadIO);
ByteBuffer bufferIO = ByteBuffer.allocate(payloadIO.length + 1);
while (arrayIO.available() > 0) {
bufferIO.put((byte) arrayIO.read());
}
for (Session rowIO : sessionsIO.values()) {
if (rowIO.isOpen()) {
rowIO.getRemote().sendBytes(bufferIO);
}
}
Which gives me:
Buffer [0]
0: 0
offset: (...)
parent: (...)
buffer: (...)
byteLength: (...)
byteOffset: (...)
length: (...)
Symbol(Symbol.toStringTag): (...)
__proto__: Uint8Array
On the JavaScript Part.
