[Libwebsockets] How to determine data type received?

Gregory Junker ggjunker at gmail.com
Sat Jan 19 02:53:07 CET 2013

Hi Andy

It looks like the frame_is_binary member of the wsi struct is not actually
being set anywhere. I put breakpoints in parser.c where it looks like it
should be set in the code (as well as the 04-to-07 upgrade switch
statement, on the text and binary frame cases) and none of those are ever

I know the server is sending it properly because binary data I send to a
browser shows up as an array and not a string. It looks like the client
handling is not doing it properly,

I'll fumble around in the code and see if I can figure out why, but wanted
to post a note on this.


On Thu, Jan 17, 2013 at 6:03 PM, "Andy Green (林安廸)" <andy at warmcat.com>wrote:

> On 18/01/13 07:18, the mail apparently from Gregory Junker included:
>  Hi
>> Is there a way to determine the type of data sent by the remote endpoint
>> in the callback function? For example, if the server sends the client
>> (both using libwebsockets) how can I determine whether "in" points to
>> data sent with LWS_WRITE_BINARY or LWS_WRITE_TEXT (apart from putting
>> that info into my data as well)?
> Hi -
> Good point, until now nothing cared, since everything coming out of the
> test javascript is "text".  But the client side of libwebsockets at least
> can send binary.
> I introduced an api
> int lws_frame_is_binary(struct libwebsocket *wsi)
> so you can find out from the receive callback what the frame type you're
> dealing with is.
> http://git.libwebsockets.org/**cgi-bin/cgit/libwebsockets/**commit/?id=**
> 2fd3f2f78f7b22570558b7c68eeb1e**1d99a3a254<http://git.libwebsockets.org/cgi-bin/cgit/libwebsockets/commit/?id=2fd3f2f78f7b22570558b7c68eeb1e1d99a3a254>
> -Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20130118/eff7d003/attachment-0001.html>

More information about the Libwebsockets mailing list