[Libwebsockets] regarding getting binary data in javascript web client

Rob Agar rob at engineeredarts.co.uk
Mon Jul 11 11:59:58 CEST 2016


Hi Suman

If you want to access the actual bytes of binary messages in your 
javascript, you need to tell it to convert the blob into an ArrayBuffer, 
like so:

     var ws = new WebSocket("ws://....");
     ws.binaryType = 'arraybuffer';

hth
Rob

On 11/07/16 10:52, Suman.Patro-TRN wrote:
>
> Hello ,
>
>             I would like to use LWS_WRITE_BINARYin lws_write in the 
> webserver and get data in the javascript client . I use websockets 
> connection in the javascript client. When I tried the above scenario, 
> I get [object blob] on the html page. Do I need to take some 
> additional efforts at the javascript client or is this the javascript  
> issue? Is it true that javascript client does not understand byte? if 
> javascript does not understand byte, then should Xmlhttprequest is to 
> be used? but as per my knowledge xmlhttprequest is used with long 
> polling technique and not websockets.Are my understanding on this 
> topic correct?
>
> Thanks and regards,
>
> Suman
>
> *Larsen & Toubro Limited *
>
> *www.larsentoubro.com*
>
> This Email may contain confidential or privileged information for the 
> intended recipient (s). If you are not the intended recipient, please 
> do not use or disseminate the information, notify the sender and 
> delete it from your system.
>
>
>
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> http://libwebsockets.org/mailman/listinfo/libwebsockets

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20160711/0c7d5ae2/attachment-0001.html>


More information about the Libwebsockets mailing list