title: Audio Chat using socketio
body: <p>I am new in nodejs.
   I am working on voice chat application , in the application client can speak and his sound will broadcasted (using nodejs server) to other clients , I used socketio to send sound from microphone to server, but I did not know how receiver sound in client, Can any one help me?</p>
  
  <p>Client code for send voice (I do not know if this true way to send voice from microphone):</p>
  
  <pre><code>navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
  navigator.getUserMedia( {audio:true}, gotStream , onError ); 
     function gotStream(stream) 
     {
                  var context;
                  if (window.AudioContext) {
                      context = new AudioContext();
                  } else {
                      context = new webkitAudioContext();
                  }
                var  mediastream = context.createMediaStreamSource(stream);
                  var bufferSize = 2048;
                  var myscriptnode = context.createScriptProcessor(bufferSize, 1, 1);
                  myscriptnode.onaudioprocess = function (event) {
                      var recordedData = event.inputBuffer.getChannelData(0);
                      socket.emit('broadcast', recordedData);
                  };
  
                  mediastream.connect(myscriptnode);
                  myscriptnode.connect(context.destination);
  
        }
  
  
        function onError()
         {
  
         }
  </code></pre>
  
  <p>Server code for receiver from client:</p>
  
  <pre><code>socket.on('broadcast', function(data){
          socket.emit('broadcast', data);
      });
  </code></pre>
  
  <p>Client code to recive sound: </p>
  
  <pre><code>  socket.on('broadcast', function(data){
        // I do not know what I must do here      
      });
  </code></pre>