diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index fcf46744..2efa864e 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -1325,6 +1325,16 @@ lws_get_fops(struct lws_context *context) return &context->fops; } +/** + * lws_get_context - Allow geting lws_context from a Websocket connection + * instance + * + * With this function, users can access context in the callback function. + * Otherwise users may have to declare context as a global variable. + * + * @wsi: Websocket connection instance + */ + LWS_VISIBLE LWS_EXTERN struct lws_context * lws_get_context(const struct lws *wsi) { diff --git a/libwebsockets-api-doc.html b/libwebsockets-api-doc.html index 504f4f55..3500041f 100644 --- a/libwebsockets-api-doc.html +++ b/libwebsockets-api-doc.html @@ -696,6 +696,22 @@ This is never set at the start of a writeable callback, but any write may set it.
+++With this function, users can access context in the callback function. +Otherwise users may have to declare context as a global variable. +