Andy Green andy at warmcat.com
Thu Jul 17 00:10:59 CEST 2014

On 17 July 2014 05:48:25 GMT+08:00, lws14 at mordent.com wrote:
>Yes, but the same section says:
>You get an opportunity to initialize user data when called back with
>LWS_CALLBACK_ESTABLISHED reason. So are we supposed to poke into the
>"user" data during ESTABLISHED or during WSI_CREATE? 

"user data" attached to the wsi can only be allocated when the protocol was agreed, because the size of it is defined per-protocol.  So it only becomes available at ESTABLISHED like it says.

There's an alternative client connect api that lets you pass in external user data for the connection.  If you used that, it should be available at CREATE.


>On 7/16/2014 5:16 PM, Andy Green wrote:
>On 17 July 2014 01:38:24 GMT+08:00, lws14 at mordent.com wrote: 
>Hi, In my app, I'm using CLIENT_ESTABLISHED to set user data for
>keeping state (I set it to a pointer to an instance of a "Client"
>object). However, somehow, I'm seeing other callback reasons, like
>CLIENT_WRITEABLE, before CLIENT_ESTABLISHED happens and so my user data
>is empty (because ESTABLISHED hasn't happened yet). Is this supposed to
>happen this way? I thought that CLIENT_ESTABLISHED would be the very
>first ever callback reason we see. 
>No ESTABLISHED refers to the actual websocket protocol becoming
>established, so it only happens after various kinds of http traffic
>have occurred on the wsi / socket. You want a different callback to
>manage the lifecycle, like LWS_CALLBACK_WSI_CREATE
>Thanks, -m _______________________________________________
>Libwebsockets mailing list Libwebsockets at ml.libwebsockets.org
>Libwebsockets mailing list
>Libwebsockets at ml.libwebsockets.org

Sent from my Android device with K-9 Mail. Please excuse my brevity.

More information about the Libwebsockets mailing list