lws_callback_all_protocol_vhost_args

This commit is contained in:
Andy Green 2017-08-05 10:38:59 +08:00
parent 040b408029
commit 93a5b586a3
2 changed files with 38 additions and 8 deletions

View file

@ -1056,8 +1056,9 @@ lws_callback_all_protocol(struct lws_context *context,
}
LWS_VISIBLE int
lws_callback_all_protocol_vhost(struct lws_vhost *vh,
const struct lws_protocols *protocol, int reason)
lws_callback_all_protocol_vhost_args(struct lws_vhost *vh,
const struct lws_protocols *protocol, int reason,
void *argp, size_t len)
{
struct lws_context *context = vh->context;
struct lws_context_per_thread *pt = &context->pt[0];
@ -1069,9 +1070,10 @@ lws_callback_all_protocol_vhost(struct lws_vhost *vh,
wsi = wsi_from_fd(context, pt->fds[n].fd);
if (!wsi)
continue;
if (wsi->vhost == vh && wsi->protocol == protocol)
protocol->callback(wsi, reason, wsi->user_space,
NULL, 0);
if (wsi->vhost == vh && (wsi->protocol == protocol ||
!protocol))
wsi->protocol->callback(wsi, reason,
wsi->user_space, argp, len);
}
pt++;
}
@ -1079,6 +1081,13 @@ lws_callback_all_protocol_vhost(struct lws_vhost *vh,
return 0;
}
LWS_VISIBLE int
lws_callback_all_protocol_vhost(struct lws_vhost *vh,
const struct lws_protocols *protocol, int reason)
{
return lws_callback_all_protocol_vhost_args(vh, protocol, reason, NULL, 0);
}
LWS_VISIBLE LWS_EXTERN int
lws_callback_vhost_protocols(struct lws *wsi, int reason, void *in, int len)
{

View file

@ -3974,10 +3974,11 @@ lws_callback_all_protocol(struct lws_context *context,
/**
* lws_callback_all_protocol_vhost() - Callback all connections using
* the given protocol with the given reason
* the given protocol with the given reason. This is
* deprecated since v2.4: use lws_callback_all_protocol_vhost_args
*
* \param vh: Vhost whose connections will get callbacks
* \param protocol: Which protocol to match
* \param protocol: Which protocol to match. NULL means all.
* \param reason: Callback reason index
*
* - Which: connections using this protocol on GIVEN VHOST ONLY
@ -3986,7 +3987,27 @@ lws_callback_all_protocol(struct lws_context *context,
*/
LWS_VISIBLE LWS_EXTERN int
lws_callback_all_protocol_vhost(struct lws_vhost *vh,
const struct lws_protocols *protocol, int reason);
const struct lws_protocols *protocol, int reason)
LWS_WARN_DEPRECATED;
/**
* lws_callback_all_protocol_vhost_args() - Callback all connections using
* the given protocol with the given reason and args
*
* \param vh: Vhost whose connections will get callbacks
* \param protocol: Which protocol to match. NULL means all.
* \param reason: Callback reason index
* \param argp: Callback "in" parameter
* \param len: Callback "len" parameter
*
* - Which: connections using this protocol on GIVEN VHOST ONLY
* - When: now
* - What: reason
*/
LWS_VISIBLE int
lws_callback_all_protocol_vhost_args(struct lws_vhost *vh,
const struct lws_protocols *protocol, int reason,
void *argp, size_t len);
/**
* lws_callback_vhost_protocols() - Callback all protocols enabled on a vhost