mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-08 04:02:27 +00:00
Added more convenient functions for sending data to websocket
This commit is contained in:
@@ -1603,6 +1603,11 @@ typedef struct httpd_ws_frame {
|
||||
size_t len; /*!< Length of the WebSocket data */
|
||||
} httpd_ws_frame_t;
|
||||
|
||||
/**
|
||||
* @brief Transfer complete callback
|
||||
*/
|
||||
typedef void (*transfer_complete_cb)(esp_err_t err, int socket, void *arg);
|
||||
|
||||
/**
|
||||
* @brief Receive and parse a WebSocket frame
|
||||
*
|
||||
@@ -1663,6 +1668,35 @@ esp_err_t httpd_ws_send_frame_async(httpd_handle_t hd, int fd, httpd_ws_frame_t
|
||||
*/
|
||||
httpd_ws_client_info_t httpd_ws_get_fd_info(httpd_handle_t hd, int fd);
|
||||
|
||||
/**
|
||||
* @brief Sends data to to specified websocket synchronously
|
||||
*
|
||||
* @param[in] handle Server instance data
|
||||
* @param[in] socket Socket descriptor
|
||||
* @param[in] frame Websocket frame
|
||||
* @return
|
||||
* - ESP_OK : On successful
|
||||
* - ESP_FAIL : When socket errors occurs
|
||||
* - ESP_ERR_NO_MEM : Unable to allocate memory
|
||||
*/
|
||||
esp_err_t httpd_ws_send_data(httpd_handle_t handle, int socket, httpd_ws_frame_t *frame);
|
||||
|
||||
/**
|
||||
* @brief Sends data to to specified websocket asynchronously
|
||||
*
|
||||
* @param[in] handle Server instance data
|
||||
* @param[in] socket Socket descriptor
|
||||
* @param[in] frame Websocket frame
|
||||
* @param[in] callback Callback invoked after sending data
|
||||
* @param[in] arg User data passed to provided callback
|
||||
* @return
|
||||
* - ESP_OK : On successful
|
||||
* - ESP_FAIL : When socket errors occurs
|
||||
* - ESP_ERR_NO_MEM : Unable to allocate memory
|
||||
*/
|
||||
esp_err_t httpd_ws_send_data_async(httpd_handle_t handle, int socket, httpd_ws_frame_t *frame,
|
||||
transfer_complete_cb callback, void *arg);
|
||||
|
||||
#endif /* CONFIG_HTTPD_WS_SUPPORT */
|
||||
/** End of WebSocket related stuff
|
||||
* @}
|
||||
|
Reference in New Issue
Block a user