[Libwebsockets] How to determine data type received?

"Andy Green (林安廸)" andy at warmcat.com
Fri Jan 18 03:03:41 CET 2013


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=2fd3f2f78f7b22570558b7c68eeb1e1d99a3a254

-Andy



More information about the Libwebsockets mailing list