mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
pass ext pointer in ext callback
Signed-off-by: Andy Green <andy@warmcat.com>
This commit is contained in:
parent
6eeadae1ab
commit
46c2ea0d6f
8 changed files with 36 additions and 17 deletions
|
@ -7,7 +7,9 @@
|
|||
|
||||
|
||||
int lws_extension_callback_deflate_stream(
|
||||
struct libwebsocket_context *context, struct libwebsocket *wsi,
|
||||
struct libwebsocket_context *context,
|
||||
struct libwebsocket_extension *ext,
|
||||
struct libwebsocket *wsi,
|
||||
enum libwebsocket_extension_callback_reasons reason,
|
||||
void *user, void *in, size_t len)
|
||||
{
|
||||
|
|
|
@ -11,7 +11,8 @@ struct lws_ext_deflate_stream_conn {
|
|||
};
|
||||
|
||||
extern int lws_extension_callback_deflate_stream(
|
||||
struct libwebsocket_context *context,
|
||||
struct libwebsocket *wsi,
|
||||
enum libwebsocket_extension_callback_reasons reason,
|
||||
struct libwebsocket_context *context,
|
||||
struct libwebsocket_extension *ext,
|
||||
struct libwebsocket *wsi,
|
||||
enum libwebsocket_extension_callback_reasons reason,
|
||||
void *user, void *in, size_t len);
|
||||
|
|
|
@ -435,7 +435,8 @@ handshake_0405(struct libwebsocket *wsi)
|
|||
/* allow him to construct his context */
|
||||
|
||||
ext->callback(wsi->protocol->owning_server,
|
||||
wsi, LWS_EXT_CALLBACK_CONSTRUCT,
|
||||
ext, wsi,
|
||||
LWS_EXT_CALLBACK_CONSTRUCT,
|
||||
wsi->active_extensions_user[
|
||||
wsi->count_active_extensions], NULL, 0);
|
||||
|
||||
|
|
|
@ -182,7 +182,8 @@ libwebsocket_close_and_free_session(struct libwebsocket_context *context,
|
|||
|
||||
for (n = 0; n < wsi->count_active_extensions; n++) {
|
||||
m = wsi->active_extensions[n]->callback(
|
||||
wsi->protocol->owning_server, wsi,
|
||||
wsi->protocol->owning_server,
|
||||
wsi->active_extensions[n], wsi,
|
||||
LWS_EXT_CALLBACK_FLUSH_PENDING_TX,
|
||||
wsi->active_extensions_user[n], &eff_buf, 0);
|
||||
if (m < 0) {
|
||||
|
@ -285,9 +286,10 @@ just_kill_connection:
|
|||
if (!wsi->active_extensions[n]->callback)
|
||||
continue;
|
||||
|
||||
wsi->active_extensions[n]->callback(context, wsi,
|
||||
LWS_EXT_CALLBACK_DESTROY,
|
||||
wsi->active_extensions_user[n], NULL, 0);
|
||||
wsi->active_extensions[n]->callback(context,
|
||||
wsi->active_extensions[n], wsi,
|
||||
LWS_EXT_CALLBACK_DESTROY,
|
||||
wsi->active_extensions_user[n], NULL, 0);
|
||||
|
||||
free(wsi->active_extensions_user[n]);
|
||||
}
|
||||
|
@ -539,7 +541,8 @@ lws_handle_POLLOUT_event(struct libwebsocket_context *context,
|
|||
|
||||
for (n = 0; n < wsi->count_active_extensions; n++) {
|
||||
m = wsi->active_extensions[n]->callback(
|
||||
wsi->protocol->owning_server, wsi,
|
||||
wsi->protocol->owning_server,
|
||||
wsi->active_extensions[n], wsi,
|
||||
LWS_EXT_CALLBACK_PACKET_TX_PRESEND,
|
||||
wsi->active_extensions_user[n], &eff_buf, 0);
|
||||
if (m < 0) {
|
||||
|
@ -1586,9 +1589,11 @@ select_protocol:
|
|||
/* allow him to construct his context */
|
||||
|
||||
ext->callback(wsi->protocol->owning_server,
|
||||
wsi, LWS_EXT_CALLBACK_CLIENT_CONSTRUCT,
|
||||
ext, wsi,
|
||||
LWS_EXT_CALLBACK_CLIENT_CONSTRUCT,
|
||||
wsi->active_extensions_user[
|
||||
wsi->count_active_extensions], NULL, 0);
|
||||
wsi->count_active_extensions],
|
||||
NULL, 0);
|
||||
|
||||
wsi->count_active_extensions++;
|
||||
|
||||
|
@ -1764,9 +1769,11 @@ bail2:
|
|||
more = 0;
|
||||
|
||||
for (n = 0; n < wsi->count_active_extensions; n++) {
|
||||
m = wsi->active_extensions[n]->callback(context, wsi,
|
||||
m = wsi->active_extensions[n]->callback(context,
|
||||
wsi->active_extensions[n], wsi,
|
||||
LWS_EXT_CALLBACK_PACKET_RX_PREPARSE,
|
||||
wsi->active_extensions_user[n], &eff_buf, 0);
|
||||
wsi->active_extensions_user[n],
|
||||
&eff_buf, 0);
|
||||
if (m < 0) {
|
||||
fprintf(stderr, "Extension reports fatal error\n");
|
||||
libwebsocket_close_and_free_session(context, wsi,
|
||||
|
|
|
@ -192,6 +192,7 @@ enum lws_close_status {
|
|||
|
||||
struct libwebsocket;
|
||||
struct libwebsocket_context;
|
||||
struct libwebsocket_extension;
|
||||
|
||||
/* document the generic callback (it's a fake prototype under this) */
|
||||
/**
|
||||
|
@ -394,6 +395,7 @@ extern int callback(struct libwebsocket_context * context,
|
|||
/**
|
||||
* extension_callback() - Hooks to allow extensions to operate
|
||||
* @context: Websockets context
|
||||
* @ext: This extension
|
||||
* @wsi: Opaque websocket instance pointer
|
||||
* @reason: The reason for the call
|
||||
* @user: Pointer to per-session user data allocated by library
|
||||
|
@ -450,6 +452,7 @@ extern int callback(struct libwebsocket_context * context,
|
|||
*/
|
||||
|
||||
extern int extension_callback(struct libwebsocket_context * context,
|
||||
struct libwebsocket_extension *ext,
|
||||
struct libwebsocket *wsi,
|
||||
enum libwebsocket_callback_reasons reason, void *user,
|
||||
void *in, size_t len);
|
||||
|
@ -515,6 +518,7 @@ struct libwebsocket_protocols {
|
|||
struct libwebsocket_extension {
|
||||
const char *name;
|
||||
int (*callback)(struct libwebsocket_context *context,
|
||||
struct libwebsocket_extension *ext,
|
||||
struct libwebsocket *wsi,
|
||||
enum libwebsocket_extension_callback_reasons reason,
|
||||
void *user, void *in, size_t len);
|
||||
|
|
|
@ -1379,7 +1379,8 @@ send_raw:
|
|||
|
||||
for (n = 0; n < wsi->count_active_extensions; n++) {
|
||||
m = wsi->active_extensions[n]->callback(
|
||||
wsi->protocol->owning_server, wsi,
|
||||
wsi->protocol->owning_server,
|
||||
wsi->active_extensions[n], wsi,
|
||||
LWS_EXT_CALLBACK_PACKET_TX_PRESEND,
|
||||
wsi->active_extensions_user[n], &eff_buf, 0);
|
||||
if (m < 0) {
|
||||
|
|
|
@ -228,7 +228,7 @@ enum pending_timeout {
|
|||
|
||||
struct libwebsocket {
|
||||
const struct libwebsocket_protocols *protocol;
|
||||
const struct libwebsocket_extension *
|
||||
struct libwebsocket_extension *
|
||||
active_extensions[LWS_MAX_EXTENSIONS_ACTIVE];
|
||||
void * active_extensions_user[LWS_MAX_EXTENSIONS_ACTIVE];
|
||||
int count_active_extensions;
|
||||
|
|
|
@ -728,6 +728,7 @@ internal polling loop, you can just ignore it.
|
|||
<i>int</i>
|
||||
<b>extension_callback</b>
|
||||
(<i>struct libwebsocket_context *</i> <b>context</b>,
|
||||
<i>struct libwebsocket_extension *</i> <b>ext</b>,
|
||||
<i>struct libwebsocket *</i> <b>wsi</b>,
|
||||
<i>enum libwebsocket_callback_reasons</i> <b>reason</b>,
|
||||
<i>void *</i> <b>user</b>,
|
||||
|
@ -737,6 +738,8 @@ internal polling loop, you can just ignore it.
|
|||
<dl>
|
||||
<dt><b>context</b>
|
||||
<dd>Websockets context
|
||||
<dt><b>ext</b>
|
||||
<dd>This extension
|
||||
<dt><b>wsi</b>
|
||||
<dd>Opaque websocket instance pointer
|
||||
<dt><b>reason</b>
|
||||
|
@ -858,7 +861,7 @@ allows as many protocols as you like to be handled by one server.
|
|||
<h2>struct libwebsocket_extension - An extension we know how to cope with</h2>
|
||||
<b>struct libwebsocket_extension</b> {<br>
|
||||
<i>const char *</i> <b>name</b>;<br>
|
||||
<i>int (*</i><b>callback</b>) <i>(struct libwebsocket_context *context,struct libwebsocket *wsi,enum libwebsocket_extension_callback_reasons reason,void *user, void *in, size_t len)</i>;<br>
|
||||
<i>int (*</i><b>callback</b>) <i>(struct libwebsocket_context *context,struct libwebsocket_extension *ext,struct libwebsocket *wsi,enum libwebsocket_extension_callback_reasons reason,void *user, void *in, size_t len)</i>;<br>
|
||||
<i>size_t</i> <b>per_session_data_size</b>;<br>
|
||||
};<br>
|
||||
<h3>Members</h3>
|
||||
|
|
Loading…
Add table
Reference in a new issue