title: Read uint8array directly from uWebsockets server
body: <p>I am trying use the uWebSockets library to read binary ArrayBuffer data sent from a web client.</p>
  
  <p>I found a question on the repo issues that describes this for the case of text/blob data, but I want to parse uint8array data coming in from the web client:</p>
  
  <ul>
  <li><p><a href="https://gist.github.com/WesThorburn/581d8b7a0ed70bc386b8c388336ad318" rel="nofollow noreferrer">https://gist.github.com/WesThorburn/581d8b7a0ed70bc386b8c388336ad318</a></p></li>
  <li><p><a href="https://github.com/uNetworking/uWebSockets/issues/508" rel="nofollow noreferrer">https://github.com/uNetworking/uWebSockets/issues/508</a></p></li>
  </ul>
  
  <p>I am using the very simple example client:</p>
  
  <pre><code>int main()
  {
      uWS::Hub h;
  
      h.onMessage([](uWS::WebSocket&lt;uWS::SERVER&gt; *ws, char *message, size_t length, uWS::OpCode opCode) {
          uint8_t messageString [length]; //Create char array with length of message length
          cout &lt;&lt; "length: " &lt;&lt; length &lt;&lt; endl;
          for (int i = 0; i &lt; length; i++) { //Iterate through each character in the message
            messageString[i] = (uint8_t)message[i];   //Add message character to messageString
          }
          cout &lt;&lt; "Message: " &lt;&lt; &amp;messageString[1] &lt;&lt; endl;
  
          ws-&gt;send (message, length, opCode);
      });
  
      h.listen (3000);
      h.run();
  }
  </code></pre>
  
  <p>and on the client side I do:</p>
  
  <pre><code> {
       ws = new WebSocket(wsUri);
       ws.binaryType = "arraybuffer";
       ws.onopen     = function (evt) { onOpen(evt) };
       ws.onclose    = function (evt) { onClose(evt) };
       ws.onmessage  = function (evt) { onMessage(evt) };
       ws.onerror    = function (evt) { onError(evt) };
   }
  </code></pre>
  
  <p>and send a <code>uint8array</code> down the socket.  The text/blob example does not work, trying to read it as a <code>uint8_t</code> array does not work, I cannot for the life of me figure out how to read this so that the data is usable.  Note that the echo back to the client does however work - I get back what I put in.</p>