diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index 59c954a8..e55da35d 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -133,6 +133,25 @@ libwebsocket_close_and_free_session(struct libwebsocket *wsi) free(wsi); } +/** + * libwebsockets_hangup_on_client() - Server calls to terminate client + * connection + * @this: libwebsockets context + * @fd: Connection socket descriptor + */ + +void +libwebsockets_hangup_on_client(struct libwebsocket_context *this, int fd) +{ + struct libwebsocket *wsi = wsi_from_fd(this, fd); + + if (wsi == NULL) + return; + + libwebsocket_close_and_free_session(wsi); +} + + /** * libwebsockets_get_peer_addresses() - Get client address information * @fd: Connection socket descriptor diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h index 31f28e95..f227073b 100644 --- a/lib/libwebsockets.h +++ b/lib/libwebsockets.h @@ -388,4 +388,7 @@ extern void libwebsockets_get_peer_addresses(int fd, char *name, int name_len, char *rip, int rip_len); +extern void +libwebsockets_hangup_on_client(struct libwebsocket_context *this, int fd); + #endif diff --git a/libwebsockets-api-doc.html b/libwebsockets-api-doc.html index 487b942b..1415ff5e 100644 --- a/libwebsockets-api-doc.html +++ b/libwebsockets-api-doc.html @@ -1,3 +1,16 @@ +