[Libwebsockets] libwebsocket_is_final_fragment(wsi) is always returning 1; How to find end of the message?
andy at warmcat.com
Wed Oct 29 15:15:39 CET 2014
On 29 October 2014 22:05:53 GMT+08:00, satya gowtham kudupudi <satyagowtham.k at gmail.com> wrote:
>I'm making single call websocket.send(myMsg). myMsg is only 34
>length. But LWS_CALLBACK_RECEIVE has to be touched 4 times to receive
>complete message and every time libwebsocket_is_final_fragment(wsi) is
Well, then there is one fragment being sent. And that fragment is the final one.
How many times pieces of it appear at the callback has nothing to do with how many logical fragments were sent or how many packets were sent.
What you should be doing is looking at LWS_VISIBLE LWS_EXTERN size_t
libwebsockets_remaining_packet_payload(struct libwebsocket *wsi); to find out how the chunk you just got called back on fits into the fragment. If there's still more to come, even if this is the final fragment we're in, more of the final fragment is yet to appear at the callback.
Only when you see 0 remaining AND fin is set, you know you just had the last bytes of the message.
>libwebsocketserver used to go fine with old chrome version few months
>though I faced same problem with the IE then.
>Now google chrome too giving same problem.
>I think there is a little change in the latest libwebsockets protocol.
More information about the Libwebsockets