[Libwebsockets] callback pointer

Trey Weaver treyweaver at fastmail.net
Fri May 14 21:23:15 CEST 2021

What is the best way to pass a pointer to a callback?

I want to set up a pointer to a class (i'm using c++) an retrieve that pointer when I get a callback.

I tried setting up the *protocols[0].user = this*; 

And I tried:
*lws_context_creation_info.user = this;*

And then looked at the *user data on the call back, but the pointers did not match.

I then looked at using: 
*lws_client_connect_info.opaque_user_data = this.*
and then use in the call back 

This worked ok, and I probably could live with it but I miss the pointer for the first three messages when I set up the context and first connect

These are the message that have no value from: ws_get_opaque_user_data(wsi);


I was wondered if there was a better way.

Trey Weaver
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20210514/4b519476/attachment.htm>

More information about the Libwebsockets mailing list