[Libwebsockets] How to retain info from LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION
griscom at suitable.com
Wed Sep 18 02:57:53 CEST 2013
You, sir, are cranking. Many thanks.
At 8:54 AM +0800 9/18/13, Andy Green (ó-à¿úN) wrote:
>On 18/09/13 04:25, the mail apparently from Daniel Griscom included:
>>I know the LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION callback is meant for
>>the server to examine the incoming connection's headers and allow or
>>deny the connection based on the header values. This is also the only
>>place the header values are available, since they are then immediately
>>Problem: I want to retain information from the headers for use in the
>>ensuing connection. For example, I want to save the WSI_TOKEN_GET_URI
>>value and then handle the connection differently based on the URI. But,
>>the void *user parameter of the callback, which later is used to
>>maintain connection-specific information, is used for a pointer to the
>>requested websocket protocol.
>>How can I save the header information for later use in the connection?
>>Can I depend that, if I allow the connection in the
>>LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION callback, the next
>>LWS_CALLBACK_ESTABLISHED callback will always be for the same connection
>>P.S. It looks like the API documentation for the
>>LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION callback is incorrect. It claims
>>that the user pointer is to an array of struct lws_tokens, but that
>>seems to not be true. user points to a string giving the requested
>>protocol, and the actual headers are accessed through the struct
>>libwebsocket pointer (as shown in the accompanying
>Right... this should fix it
>Previously this callback happens before the
>user_space is allocated, I changed it to exist
>now and use the "user" callback parameter.
>The docs are corrected with an explanation of
>how to find the headers and changelog updated in
>The header data will still get deleted after
>this, but you have a chance to copy it into your
>user struct now.
Daniel T. Griscom griscom at suitable.com
Suitable Systems http://www.suitable.com/
1 Centre Street, Suite 204 (781) 665-0053
Wakefield, MA 01880-2400
More information about the Libwebsockets