esp_http_server: Add httpd_ws_get_fd_info() API to check active WS clients

Added a new API to WebSocket server to test provided socket descriptor if it belongs to active clients for this server and if websocket handshake has been performed

Closes https://github.com/espressif/esp-idf/issues/5602
This commit is contained in:
David Cermak
2020-08-27 16:50:19 +02:00
parent 52d935615c
commit d3801be6d9
2 changed files with 24 additions and 0 deletions

View File

@@ -383,4 +383,15 @@ esp_err_t httpd_ws_get_frame_type(httpd_req_t *req)
return ESP_OK;
}
int httpd_ws_get_fd_info(httpd_handle_t hd, int fd)
{
struct sock_db *sess = httpd_sess_get(hd, fd);
if (sess == NULL) {
return -1;
}
bool is_active_ws = sess->ws_handshake_done && (!sess->ws_close);
return is_active_ws ? 1 : 0;
}
#endif /* CONFIG_HTTPD_WS_SUPPORT */