title: Send audio over WebSocket
body: <p>I'm implementig <code>getUserMedia()</code> to record audio messages. I want to record the audio and then pass it using websocket to another peer. How I can accomplish this?I've searched on SO and I've found only some interesting question, but nothing that can guide me to a working solution. I'm using Pusher API for the websocket part of my app. 
  Here is the code I'm testing.</p>
  
  <pre><code>$(document).on("click", ".audio-chat",function(){
    console.log('clicked');
    var channel = $('input[name="channelName"]').val();
    navigator.mediaDevices.getUserMedia({
      audio: true
    })
    .then(function(stream){
      var mediaRecorder = new MediaRecorder(stream);
      mediaRecorder.start();
      console.log(mediaRecorder.state);
      console.log("recorder started");
  
      mediaRecorder.ondataavailable = function(e) {
        chunks.push(e.data);
        console.log(chunks);
      }
      setTimeout(function(){
        mediaRecorder.stop();
        console.log(mediaRecorder.state);
        console.log("recorder stopped");
        var blob = new Blob(chunks, {'type':'audio/webm; codecs=opus'});
        //console.log(blob);
        chunks = [];
        const audioUrl = window.URL.createObjectURL(blob);
        var data = {channel:channel,message:audioUrl,socketId:socketId}
        $.post('api/message.php', data);
      }, 10000);
    });
  });
  </code></pre>