[Libwebsockets] A question about close frame ctroll for ws client in libwebsockets
huangkaicheng at huawei.com
Fri Mar 13 05:24:43 CET 2020
We use libwebsockets as ws client. We want to know that how to get the reason code and descption if ws server send close frame with close_staus and buffer . We found the interface “lws_close_reason ” about send to close frame in libwebsocket.h
* lws_close_reason - Set reason and aux data to send with Close packet
* If you are going to return nonzero from the callback
* requesting the connection to close, you can optionally
* call this to set the reason the peer will be told if
* \param wsi: The websocket connection to set the close reason on
* \param status: A valid close status from websocket standard
* \param buf: NULL or buffer containing up to 124 bytes of auxiliary data
* \param len: Length of data in \param buf to send
LWS_VISIBLE LWS_EXTERN void
lws_close_reason(struct lws *wsi, enum lws_close_status status,
unsigned char *buf, size_t len);
but we does not found how to get reason when ws client receive close frame.
as ws client ,how to get close status and buf? Can callback reason about “LWS_CALLBACK_CLOSED” get close status ? if not, how to get it. Please help answer for me. Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libwebsockets