Introduce async websocket stop

This commit is contained in:
2025-05-28 15:44:39 +02:00
parent a6fe9525e1
commit 3be87562ad
2 changed files with 72 additions and 1 deletions
@@ -215,6 +215,38 @@ esp_err_t esp_websocket_client_start(esp_websocket_client_handle_t client);
*/
esp_err_t esp_websocket_client_stop(esp_websocket_client_handle_t client);
/**
* @brief Initiate an asynchronus stop of the WebSocket connection without
* websocket closing handshake
*
* This API initiates a non-blocking asynchronus stop of ws client. This will
* close TCP connection later directly without sending close frames. This is
* method is similar to esp_websocket_client_stop() but does not block the calling
* task. It is required to then later periodically call
* esp_websocket_client_is_already_stopped() to find out when its done and to
* finalize the closing of the websocket client.
*
* Notes:
* - Cannot be called from the websocket event handler
*
* @param[in] client The client
*
* @return esp_err_t
*/
esp_err_t esp_websocket_client_initiate_stop(esp_websocket_client_handle_t client);
/**
* @brief After an asynchronus stop was initiated, this method returns if it is done already.
* If this method returns true, it also performed some final cleanup. It should then not
* be called anymore unless esp_websocket_client_initiate_stop() is called again.
*
* @param[in] client The client
*
* @return
* - bool if it is done or not
*/
bool esp_websocket_client_is_already_stopped(esp_websocket_client_handle_t client);
/**
* @brief Destroy the WebSocket connection and free all resources.
* This function must be the last function to call for an session.