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

Fix documentation for LWS_CALLBACK_FILTER_NETWORK_CONNECTION

At the time callback LWS_CALLBACK_FILTER_NETWORK_CONNECTION is called,
there is no client connection information yet, so the parameter wsi
still pointing to the main server connection. Add an description of
this behavior to the documentation.
This commit is contained in:
Alexandre Erwin Ittner 2014-02-06 23:15:51 -02:00 committed by Andy Green
parent af8694d203
commit d578f57f7f
2 changed files with 25 additions and 5 deletions

View file

@ -172,6 +172,7 @@ enum libwebsocket_callback_reasons {
LWS_CALLBACK_HTTP_WRITEABLE,
LWS_CALLBACK_FILTER_NETWORK_CONNECTION,
LWS_CALLBACK_FILTER_HTTP_CONNECTION,
LWS_CALLBACK_SERVER_NEW_CLIENT_INSTANTIATED,
LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION,
LWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERTS,
LWS_CALLBACK_OPENSSL_LOAD_EXTRA_SERVER_VERIFY_CERTS,
@ -554,12 +555,21 @@ struct libwebsocket_extension;
* the server at network level; the connection is accepted but then
* passed to this callback to decide whether to hang up immediately
* or not, based on the client IP. @in contains the connection
* socket's descriptor. Return non-zero to terminate
* the connection before sending or receiving anything.
* Because this happens immediately after the network connection
* from the client, there's no websocket protocol selected yet so
* this callback is issued only to protocol 0.
* socket's descriptor. Since the client connection information is
* not available yet, @wsi still pointing to the main server socket.
* Return non-zero to terminate the connection before sending or
* receiving anything. Because this happens immediately after the
* network connection from the client, there's no websocket protocol
* selected yet so this callback is issued only to protocol 0.
*
* LWS_CALLBACK_SERVER_NEW_CLIENT_INSTANTIATED: A new client just had
* been connected, accepted, and instantiated into the pool. This
* callback allows setting any relevant property to it. Because this
* happens immediately after the instantiation of a new client,
* there's no websocket protocol selected yet so this callback is
* issued only to protocol 0. Only @wsi is defined, pointing to the
* new client, and the return value is ignored.
*
* LWS_CALLBACK_FILTER_HTTP_CONNECTION: called when the request has
* been received and parsed from the client, but the response is
* not sent yet. Return non-zero to disallow the connection.

View file

@ -282,6 +282,16 @@ int lws_server_socket_service(struct libwebsocket_context *context,
new_wsi->sock = accept_fd;
/*
* A new connection was accepted. Give the user a chance to
* set properties of the newly created wsi. There's no protocol
* selected yet so we issue this to protocols[0]
*/
(context->protocols[0].callback)(context, new_wsi,
LWS_CALLBACK_SERVER_NEW_CLIENT_INSTANTIATED, NULL, NULL, 0);
#ifdef LWS_OPENSSL_SUPPORT
new_wsi->ssl = NULL;
if (!context->use_ssl) {