mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
Add callback LWS_CALLBACK_SERVER_NEW_CLIENT_INSTANTIATED
Add a new callback LWS_CALLBACK_SERVER_NEW_CLIENT_INSTANTIATED which is called just after a LWS server accepts a new client connection and add it into into the client list. The new client connection information is now available and the user can set any relevant property (eg. timeouts).
This commit is contained in:
parent
22f7150b56
commit
2e4ccc056c
2 changed files with 19 additions and 0 deletions
|
@ -165,6 +165,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,6 +555,14 @@ struct libwebsocket_extension;
|
|||
* 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.
|
||||
|
|
10
lib/server.c
10
lib/server.c
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue