title: How does websocket binary image transport work?
body: <p>Can someone please clear up my misconceptions</p>
  <p>Note: I'm not using faye just, ws node module and browsers that support websockets but, based on this SO answer: <a href="https://stackoverflow.com/questions/13028604/sending-a-javascript-object-through-websockets-with-faye#answer-13034191">sending a javascript object through websockets with faye</a></p>
  <p>I have two questions:</p>
  <p>I don't see how a HTML/JavaScript client side application would know where two put the image.. Say the client sent a websocket message for the background image for div#div123 (there could be many locations for which to put the requested image). When the client receives an message back from the server it might not necessarily be from the original call (for div123) , it might be the response for say div6 or div158, or it might even be a response from a totally different call all together. <em>Normally, when I call my server; I tell it the query and then when it sends the response it sends back the answer with the question (so the client knows what the answer is for).</em> <strong>How would sending the client raw binary data be successfully dealt with in the same manner?</strong></p>
  <hr />
  <p>Say I have a image (width: 164px height: 164px) and I base64 encode it, then remove the &quot;data:image/png;base64,&quot; before sending to the client I have (roughly) a string of 2900 characters in length.</p>
  <p>Whereas if I was to get the image data as an RBGA array (0-255,0-255,0-255,0-255) for each pixel that would be a 107584=(164*164)<em>4 long array or 430336=((164</em>164)*16) characters long as a string (commas included). I can't imagine how long it would be in binary (maybe times those numbers by 8?).</p>
  <p>I've read SO posts that suggest base64 encoding then turning that into binary but that sounds like they are creating something with 33% overhead then turning it into even more numbers.</p>
  <p><strong>I can't imagine how sending as binary would not be a heck of a lot slower?</strong></p>