[Libwebsockets] [libwebsockets] Add some getters. (#56)

"Andy Green (林安廸)" andy at warmcat.com
Sat Feb 15 09:10:59 CET 2014


On 14/02/14 00:23, the mail apparently from MacGritsch included:
> Can we add some getters to imitate
> libwebsocket_callback_on_writable_all_protocol without using the private
> header (to go trough all connections and check if a flag is set in the
> user_space):

I'm not a big fan of these kind of accessor, they expose as much about 
the implementation as just giving access to the vars.

How about a library api that does a different (new) callback for all wsi 
in a protocol?  Is that actually what you want or can it be done a 
similar way if not?

-Andy

> HEADER:
> LWS_VISIBLE void *
> libwebsockets_get_user_space(struct libwebsocket *wsi);
>
> LWS_VISIBLE int
> libwebsockets_get_fd_count(struct libwebsocket_context *context);
>
> LWS_VISIBLE struct libwebsocket *
> libwebsockets_get_wsi_at_index(struct libwebsocket_context *context, int
> index);
>
> IMPLEMENTATION:
>
> LWS_VISIBLE void *
> libwebsockets_get_user_space(struct libwebsocket *wsi)
> {
> if (!wsi->protocol)
> return NULL;
>
> |if (!wsi->protocol->per_session_data_size)
>      return NULL;
>
> return wsi->user_space;
> |
>
> }
>
> LWS_VISIBLE int
> libwebsockets_get_fd_count(struct libwebsocket_context *context)
> {
> return context->fds_count;
> }
>
> LWS_VISIBLE struct libwebsocket *
> libwebsockets_get_wsi_at_index(struct libwebsocket_context *context, int
> index)
> {
> if (index >= context->fds_count)
> {
> return NULL;
> }
>
> |return context->lws_lookup[context->fds[index].fd];
> |
>
> }
>
>> Reply to this email directly or view it on GitHub
> <https://github.com/warmcat/libwebsockets/issues/56>.
>




More information about the Libwebsockets mailing list