unity-websocket-webgl icon indicating copy to clipboard operation
unity-websocket-webgl copied to clipboard

Support for length param when sending to avoid allocating byte array.

Open johnou opened this issue 6 years ago • 2 comments

We can exploit the fact the WebGL implementation takes a byte array and length ( instance.ws.send(HEAPU8.buffer.slice(bufferPtr, bufferPtr + length)); ) and allow the application to write to a buffer then pass that into the websocket send function instead of always allocating a new byte array eg.

int outputBytes;
while ((outputBytes = _tls.ReadOutput(_outgoingBuffer, 0, _outgoingBuffer.Length)) > 0)
{
  _socket.Send(_outgoingBuffer, outputBytes);
}

johnou avatar Nov 10 '19 10:11 johnou

ptal @jirihybek cc @endel

johnou avatar Nov 10 '19 14:11 johnou

@jirihybek poke, wdyt?

johnou avatar Dec 19 '19 16:12 johnou