Can someone please clear up my misconceptions
Note: I'm not using faye just, ws node module and browsers that support websockets but, based on this SO answer: sending a javascript object through websockets with faye
I have two questions:
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. 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). How would sending the client raw binary data be successfully dealt with in the same manner?
Say I have a image (width: 164px height: 164px) and I base64 encode it, then remove the "data:image/png;base64," before sending to the client I have (roughly) a string of 2900 characters in length.
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)4 long array or 430336=((164164)*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?).
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.
I can't imagine how sending as binary would not be a heck of a lot slower?