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);
}
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.