1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-16 00:00:07 +01:00

lws_callback_vhost_protocols

This gives protocols a way to talk to each other via per-vhost callbacks,
one per protocol (including the sender).

Signed-off-by: Andy Green <andy@warmcat.com>
This commit is contained in:
Andy Green 2016-06-15 10:46:58 +08:00
parent 6cd27e8186
commit 3f17a8e252
2 changed files with 28 additions and 0 deletions

View file

@ -907,6 +907,31 @@ lws_callback_all_protocol_vhost(struct lws_vhost *vh,
return 0;
}
/**
* lws_callback_vhost_protocols() - Callback all protocols enabled on a vhost
* with the given reason
*
* @wsi: wsi whose vhost will get callbacks
* @reason: Callback reason index
* @in: in argument to callback
* @len: len argument to callback
*
* This is useful when informing all fellow enabled protocols on a vhost about
* a vhost-wide event, eg, creation or deletion of an account
*/
LWS_VISIBLE LWS_EXTERN int
lws_callback_vhost_protocols(struct lws *wsi, int reason, void *in, int len)
{
int n;
for (n = 0; n < wsi->vhost->count_protocols; n++)
if (wsi->vhost->protocols[n].callback(wsi, reason, NULL, in, len))
return 1;
return 0;
}
#if LWS_POSIX
/**

View file

@ -2071,6 +2071,9 @@ LWS_VISIBLE LWS_EXTERN int
lws_callback_all_protocol_vhost(struct lws_vhost *vh,
const struct lws_protocols *protocol, int reason);
LWS_VISIBLE LWS_EXTERN int
lws_callback_vhost_protocols(struct lws *wsi, int reason, void *in, int len);
LWS_VISIBLE LWS_EXTERN int
lws_get_socket_fd(struct lws *wsi);