function myFunction(){

      for(var y = 0; y < imageHeight; y++) {
  
        // loop through each column
        for(var x = 0; x < imageWidth; x++) {
            
           var red = data[((imageWidth * y) + x) * 4];
           var green = data[((imageWidth * y) + x) * 4 + 1];
           var blue = data[((imageWidth * y) + x) * 4 + 2];
           var alpha = data[((imageWidth * y) + x) * 4 + 3];
           var pinRed = 4 + ( x * 3 );
           var pinGreen = 3 + ( x *3 );
           var pinBlue = 2 + ( x *3 );
           socket.send( "d"+pinRed+' '+ red +"\r");
           socket.send( "d"+pinGreen+' '+ green +"\r");
           socket.send( "d"+pinBlue+' '+ blue +"\r");
        }
      }

}

function initNodeSocket() {

  
        var imageObj = new Image();
    imageObj.onload = function() {
          drawImage(this);
    };
    imageObj.src = '4pixels2.jpg';
//  Map implementation differences to single reference
window.WebSocket = window.WebSocket || window.MozWebSocket;		
//  Instantiate the web socket
socket = new WebSocket( 'ws://'+ "localhost:8080" );
//  Attach event handlers
//  socket.onmessage = onMessageReceived;

} Démarrer le lien avec node lorsque la page est chargée. window.onload = initNodeSocket;